1.1.1 • Published 5 years ago
static-import-webpack-plugin v1.1.1
static-import-webpack-plugin
Moves static import in webpack bundle to top level by using special comment /* webpackIgnore: true */
.
With combination esm-webpack-plugin allow to generate EcmaScript module.
Install
npm install --save-dev static-import-webpack-plugin
Usage
Webpack Config
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
// /src/unicorn.js
export default 'unicorn'
// /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
Development
Example
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