By default, each package will be built in multiple distribution formats as specified in the `buildOptions.formats` field in its `package.json`. These can be overwritten via the `-f` flag. The following formats are supported:
- **`global`**: for direct use via `<script>` in the browser. The global variable exposed is specified via the `buildOptions.name` field in a package's `package.json`.
-- **`esm`**: for use with bundlers.
-- **`esm-browser`**: for in-browser usage via native ES modules import (`<script type="module">`)
+- **`esm-bundler`**: for use with bundlers like `webpack`, `rollup` and `parcel`.
+- **`esm`**: for usage via native ES modules imports (in browser via `<script type="module">`, or via Node.js native ES modules support in the future)
- **`cjs`**: for use in Node.js via `require()`.
For example, to build `runtime-core` with the global build only:
let hasTSChecked = false
const configs = {
- esm: {
+ 'esm-bundler': {
file: resolve(`dist/${name}.esm-bundler.js`),
format: `es`
},
file: resolve(`dist/${name}.global.js`),
format: `iife`
},
- 'esm-browser': {
- file: resolve(`dist/${name}.esm-browser.js`),
+ esm: {
+ file: resolve(`dist/${name}.esm.js`),
format: `es`
}
}
-const defaultFormats = ['esm', 'cjs']
+const defaultFormats = ['esm-bundler', 'cjs']
const inlineFormats = process.env.FORMATS && process.env.FORMATS.split(',')
const packageFormats = inlineFormats || packageOptions.formats || defaultFormats
const packageConfigs = process.env.PROD_ONLY
if (format === 'cjs' && packageOptions.prod !== false) {
packageConfigs.push(createProductionConfig(format))
}
- if (format === 'global' || format === 'esm-browser') {
+ if (format === 'global' || format === 'esm') {
packageConfigs.push(createMinifiedConfig(format))
}
})
process.env.__DEV__ === 'false' || /\.prod\.js$/.test(output.file)
const isGlobalBuild = /\.global(\.prod)?\.js$/.test(output.file)
const isBundlerESMBuild = /\.esm-bundler\.js$/.test(output.file)
- const isBrowserESMBuild = /esm-browser(\.prod)?\.js$/.test(output.file)
+ const isRawESMBuild = /esm(\.prod)?\.js$/.test(output.file)
const isRuntimeCompileBuild = /vue\./.test(output.file)
if (isGlobalBuild) {
// Global and Browser ESM builds inlines everything so that they can be
// used alone.
external:
- isGlobalBuild || isBrowserESMBuild
+ isGlobalBuild || isRawESMBuild
? []
: knownExternals.concat(Object.keys(pkg.dependencies || [])),
plugins: [
createReplacePlugin(
isProductionBuild,
isBundlerESMBuild,
- (isGlobalBuild || isBrowserESMBuild) &&
+ (isGlobalBuild || isRawESMBuild) &&
!packageOptions.enableNonBrowserBranches,
isRuntimeCompileBuild
),
!isProduction,
// this is only used during tests
__TEST__: isBundlerESMBuild ? `(process.env.NODE_ENV === 'test')` : false,
- // If the build is expected to run directly in the browser (global / esm-browser builds)
+ // If the build is expected to run directly in the browser (global / esm builds)
__BROWSER__: isBrowserBuild,
// support compile in browser?
__RUNTIME_COMPILE__: isRuntimeCompileBuild,
const formats = args.formats || args.f
const devOnly = args.devOnly || args.d
const prodOnly = !devOnly && (args.prodOnly || args.p)
-const buildTypes = args.t || args.types
+const isRelease = args.release
+const buildTypes = args.t || args.types || isRelease
const buildAllMatching = args.all || args.a
const lean = args.lean || args.l
const commit = execa.sync('git', ['rev-parse', 'HEAD']).stdout.slice(0, 7)
const pkgDir = path.resolve(`packages/${target}`)
const pkg = require(`${pkgDir}/package.json`)
+ // only build published packages for release
+ if (isRelease && pkg.private) {
+ return
+ }
+
// if building a specific format, do not remove dist.
if (!formats) {
await fs.remove(`${pkgDir}/dist`)