Skip to content

Commit 2cbe3e5

Browse files
feat(core): allow output bundle as es6 module (yarn run build --env libraryTargetModule)
1 parent 39aeb57 commit 2cbe3e5

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

build/webpack.config.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,20 @@ const configure = ({name, vueTarget}) => (env = {}, { mode = 'production', confi
3030
noPresetEnv = !isProd,
3131
noCompress = !isProd,
3232
noSourceMap = !isProd,
33+
libraryTargetModule = false,
3334
} = env;
3435

3536
const genSourcemap = false;
3637

37-
console.log('config', { targetsBrowsers, noPresetEnv, noCompress, noSourceMap, genSourcemap, vueTarget });
38+
console.log('config', { targetsBrowsers, noPresetEnv, noCompress, noSourceMap, genSourcemap, libraryTargetModule, vueTarget });
3839

3940
return {
4041
name,
42+
43+
experiments: {
44+
outputModule: libraryTargetModule,
45+
},
46+
4147
entry: [
4248
'regenerator-runtime',
4349
Path.resolve(__dirname, '../src/index.ts'),
@@ -46,9 +52,15 @@ const configure = ({name, vueTarget}) => (env = {}, { mode = 'production', confi
4652
output: {
4753
path: distPath,
4854
filename: `vue${ vueTarget }-sfc-loader.js`,
49-
library: {
50-
type: 'umd',
51-
name: `vue${ vueTarget }-sfc-loader`,
55+
...libraryTargetModule ? {
56+
57+
libraryTarget: 'module',
58+
} : {
59+
60+
library: {
61+
type: 'umd',
62+
name: `vue${ vueTarget }-sfc-loader`,
63+
},
5264
},
5365
environment: {
5466
// doc: https://webpack.js.org/configuration/output/#outputenvironment

0 commit comments

Comments
 (0)