const packageOptions = pkg.buildOptions || {}
const name = packageOptions.filename || path.basename(packageDir)
+const banner = `/**
+* ${pkg.name} v${masterVersion}
+* (c) 2018-present Yuxi (Evan) You and Vue contributors
+* @license MIT
+**/`
+
const [enumPlugin, enumDefines] = inlineEnums()
/** @type {Record<PackageFormat, OutputOptions>} */
(isGlobalBuild || isBrowserESMBuild || isBundlerESMBuild) &&
!packageOptions.enableNonBrowserBranches
- output.banner = `/**
-* ${pkg.name} v${masterVersion}
-* (c) 2018-present Yuxi (Evan) You and Vue contributors
-* @license MIT
-**/`
+ output.banner = banner
output.exports = isCompatPackage ? 'auto' : 'named'
if (isCJSBuild) {
{
name: 'swc-minify',
- async renderChunk(
- contents,
- _,
- { format, sourcemap, sourcemapExcludeSources },
- ) {
- const { code, map } = await minifySwc(contents, {
+ async renderChunk(contents, _, { format }) {
+ const { code } = await minifySwc(contents, {
module: format === 'es',
+ format: {
+ comments: false,
+ },
compress: {
ecma: 2016,
pure_getters: true,
},
safari10: true,
mangle: true,
- sourceMap: !!sourcemap,
- inlineSourcesContent: !sourcemapExcludeSources,
})
- return { code, map: map || null }
+ return { code: banner + code, map: null }
},
},
],
const packageOptions = pkg.buildOptions || {}
const name = packageOptions.filename || path.basename(packageDir)
+ const banner = `/**!
+ * ${pkg.name} v${masterVersion}
+ * (c) 2018-present Yuxi (Evan) You and Vue contributors
+ * @license MIT
+ **/`
+
/** @type {Record<PackageFormat, import('rolldown').OutputOptions>} */
const outputConfigs = {
'esm-bundler': {
(isGlobalBuild || isBrowserESMBuild || isBundlerESMBuild) &&
!packageOptions.enableNonBrowserBranches
- output.banner = `/**
- * ${pkg.name} v${masterVersion}
- * (c) 2018-present Yuxi (Evan) You and Vue contributors
- * @license MIT
- **/`
-
+ output.banner = banner
output.exports = isCompatPackage ? 'auto' : 'named'
if (isCJSBuild) {
output.esModule = true
[
{
name: 'swc-minify',
- async renderChunk(
- contents,
- _,
- {
- format,
- sourcemap,
- // @ts-expect-error not supported yet
- sourcemapExcludeSources,
- },
- ) {
- const { code, map } = await minifySwc(contents, {
+ async renderChunk(contents, _, { format }) {
+ const { code } = await minifySwc(contents, {
module: format === 'es',
+ format: {
+ comments: false,
+ },
compress: {
ecma: 2016,
pure_getters: true,
},
safari10: true,
mangle: true,
- sourceMap: !!sourcemap,
- inlineSourcesContent: !sourcemapExcludeSources,
})
- return { code, map: map || null }
+ // swc removes banner
+ return { code: banner + code, map: null }
},
},
],
const defines = Object.create(null)
// 1. grep for files with exported enum
- const { stdout } = spawnSync('git', ['grep', `export enum`])
+ const { stdout } = spawnSync('git', ['grep', `enum `])
const files = [
...new Set(
stdout
/** @type {Set<string>} */
const enumIds = new Set()
for (const node of res.program.body) {
+ let decl
+ if (node.type === 'TSEnumDeclaration') {
+ decl = node
+ }
if (
node.type === 'ExportNamedDeclaration' &&
node.declaration &&
node.declaration.type === 'TSEnumDeclaration'
) {
- const decl = node.declaration
+ decl = node.declaration
+ }
+
+ if (decl) {
const id = decl.id.name
if (enumIds.has(id)) {
throw new Error(