https://github.com/unlight/static-import-webpack-plugin
Duck taped solution to move static imports in webpack bundle to top level by using special comment
https://github.com/unlight/static-import-webpack-plugin
ecmascript-import static-import webpack-plugin
Last synced: 8 months ago
JSON representation
Duck taped solution to move static imports in webpack bundle to top level by using special comment
- Host: GitHub
- URL: https://github.com/unlight/static-import-webpack-plugin
- Owner: unlight
- License: mit
- Created: 2019-08-20T22:02:58.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-31T21:47:35.000Z (almost 7 years ago)
- Last Synced: 2024-04-25T18:02:01.270Z (about 2 years ago)
- Topics: ecmascript-import, static-import, webpack-plugin
- Language: TypeScript
- Homepage:
- Size: 42 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# static-import-webpack-plugin
Duck taped solution to move static imports in webpack bundle to top level
by using special comment `/* webpackIgnore: true */`.
With combination [esm-webpack-plugin](https://github.com/purtuga/esm-webpack-plugin) allow to generate EcmaScript module.
See example at https://github.com/unlight/webhive/tree/microfrontend/src/webhive.frontend
## Install
```sh
npm install --save-dev static-import-webpack-plugin
```
## Usage
### Webpack Config
```js
const StaticImportWebpackPlugin = require('static-import-webpack-plugin');
// Add to plugins array
plugins: [
new StaticImportWebpackPlugin(),
],
// Other config settings
entry: './src/entry.js',
output: {
libraryTarget: 'var',
library: '$lib',
}
```
### Code
```js
// /src/unicorn.js
export default 'unicorn'
```
```js
// /src/entry.js
import pokemon /* webpackIgnore: true */ from './pokemon';
import unicorn from './unicorn';
```
### Output
```
import pokemon from './pokemon';
var $lib = ... // webpackBootstrap + bundled unicorn
```
## Related Projects
- https://github.com/purtuga/esm-webpack-plugin
## Development
### Example
```sh
npx ts-node node_modules/webpack/bin/webpack.js --config example/webpack.config.js
```
```
node --inspect-brk c:/nodejs/node_modules/ts-node/dist/bin.js node_modules/webpack/bin/webpack.js --config example/webpack.config.js
```