// Rollup to complain for non-ESM targets, so we use separate entries for
// esm vs. non-esm builds.
if (isCompatPackage && (isBrowserESMBuild || isBundlerESMBuild)) {
- entryFile = /runtime$/.test(format)
- ? `src/esm-runtime.ts`
- : `src/esm-index.ts`
+ entryFile = `esm-${entryFile}`
+ }
+ entryFile = 'src/' + entryFile
+
+ return {
+ input: resolve(entryFile),
+ // Global and Browser ESM builds inlines everything so that they can be
+ // used alone.
+ external: resolveExternal(),
+ plugins: [
+ json({
+ namedExports: false
+ }),
+ alias({
+ entries
+ }),
+ enumPlugin,
+ ...resolveReplace(),
+ esbuild({
+ tsconfig: path.resolve(__dirname, 'tsconfig.json'),
+ sourceMap: output.sourcemap,
+ minify: false,
+ target: isServerRenderer || isNodeBuild ? 'es2019' : 'es2015',
+ define: resolveDefine()
+ }),
+ ...resolveNodePlugins(),
+ ...plugins
+ ],
+ output,
+ onwarn(msg, warn) {
- if (!/Circular/.test(msg.message)) {
++ if (msg.code !== 'CIRCULAR_DEPENDENCY') {
+ warn(msg)
+ }
+ },
+ treeshake: {
+ moduleSideEffects: false
+ }
}
function resolveDefine() {
return nodePlugins
}
-
- return {
- input: resolve(entryFile),
- // Global and Browser ESM builds inlines everything so that they can be
- // used alone.
- external: resolveExternal(),
- plugins: [
- json({
- namedExports: false
- }),
- alias({
- entries
- }),
- enumPlugin,
- ...resolveReplace(),
- esbuild({
- tsconfig: path.resolve(__dirname, 'tsconfig.json'),
- sourceMap: output.sourcemap,
- minify: false,
- target: isServerRenderer || isNodeBuild ? 'es2019' : 'es2015',
- define: resolveDefine()
- }),
- ...resolveNodePlugins(),
- ...plugins
- ],
- output,
- onwarn: (msg, warn) => {
- if (msg.code !== 'CIRCULAR_DEPENDENCY') {
- warn(msg)
- }
- },
- treeshake: {
- moduleSideEffects: false
- }
- }
}
- /**
- * @param {Format} format
- */
- function createProductionConfig(format) {
+ function createProductionConfig(/** @type {PackageFormat} */ format) {
return createConfig(format, {
- file: resolve(`dist/${name}.${format}.prod.js`),
- format: outputConfigs[format].format
+ ...outputConfigs[format],
+ file: resolve(`dist/${name}.${format}.prod.js`)
})
}