Skip to content

Commit

Permalink
feat: add browser ESM build
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Dec 12, 2018
1 parent 17296aa commit 861abf4
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions scripts/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,24 @@ const builds = {
format: 'es',
banner
},
// Runtime+compiler CommonJS build (ES Modules)
// Runtime+compiler ES modules build (for bundlers)
'web-full-esm': {
entry: resolve('web/entry-runtime-with-compiler.js'),
dest: resolve('dist/vue.esm.js'),
format: 'es',
alias: { he: './entity-decoder' },
banner
},
// Runtime+compiler ES modules build (for direct import in browser)
'web-full-esm-browser': {
entry: resolve('web/entry-runtime-with-compiler.js'),
dest: resolve('dist/vue.esm.browser.js'),
format: 'es',
transpile: false,
env: 'development',
alias: { he: './entity-decoder' },
banner
},
// runtime-only build (Browser)
'web-runtime-dev': {
entry: resolve('web/entry-runtime.js'),
Expand Down Expand Up @@ -205,7 +215,6 @@ function genConfig (name) {
__VERSION__: version
}),
flow(),
buble(),
alias(Object.assign({}, aliases, opts.alias))
].concat(opts.plugins || []),
output: {
Expand All @@ -227,6 +236,10 @@ function genConfig (name) {
}))
}

if (opts.transpile !== false) {
config.plugins.push(buble())
}

Object.defineProperty(config, '_name', {
enumerable: false,
value: name
Expand Down

3 comments on commit 861abf4

@AndreasCag
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about build without transpilation and without compiler?

It would be useful for modern mode.

@anthonygore
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps the browser module bundle should use the extension .mjs. Makes no difference to functionality but Google is recommending it.

@CarterLi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about build without transpilation and without compiler?

It would be useful for modern mode.

I agree. Browsers that support ESM should support all ES2015 features natively.

Please sign in to comment.