Skip to content

Commit 5ae5af8

Browse files
committed
build: improve code simplicity
1 parent d13caed commit 5ae5af8

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

rollup.config.js

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ if (!process.env.TARGET) {
77
throw new Error('TARGET package must be specified via --environment flag.')
88
}
99

10-
const masterVersion =
11-
process.env.NEXT_VERSION || require('./package.json').version
1210
const packagesDir = path.resolve(__dirname, 'packages')
1311
const pkgDir = path.resolve(packagesDir, process.env.TARGET)
1412
const name = path.basename(pkgDir)
1513
const resolve = (file) => path.resolve(pkgDir, file)
1614
const pkg = require(resolve(`package.json`))
1715
const packageOptions = pkg.buildOptions || {}
16+
const masterVersion = process.env.NEXT_VERSION || pkg.version
1817

1918
// ensure TS checks only once for each build
2019
let hasTSChecked = false
@@ -117,15 +116,15 @@ function createConfig(format, output, plugins = []) {
117116
const nodePlugins =
118117
format !== 'cjs'
119118
? [
120-
require('@rollup/plugin-node-resolve').nodeResolve({
121-
preferBuiltins: true,
122-
}),
123-
require('@rollup/plugin-commonjs')({
124-
sourceMap: false,
125-
}),
126-
require('rollup-plugin-node-builtins')(),
127-
require('rollup-plugin-node-globals')(),
128-
]
119+
require('@rollup/plugin-node-resolve').nodeResolve({
120+
preferBuiltins: true,
121+
}),
122+
require('@rollup/plugin-commonjs')({
123+
sourceMap: false,
124+
}),
125+
require('rollup-plugin-node-builtins')(),
126+
require('rollup-plugin-node-globals')(),
127+
]
129128
: []
130129

131130
const shouldEmitDeclarations = process.env.TYPES != null && !hasTSChecked
@@ -197,9 +196,9 @@ function createReplacePlugin(
197196
__VERSION__: `"${masterVersion}"`,
198197
__DEV__: isBundlerESMBuild
199198
? // preserve to be handled by bundlers
200-
`(process.env.NODE_ENV !== 'production')`
199+
`(process.env.NODE_ENV !== 'production')`
201200
: // hard coded dev/prod builds
202-
!isProduction,
201+
!isProduction,
203202
// this is only used during Vue's internal tests
204203
__TEST__: false,
205204
// If the build is expected to run directly in the browser (global / esm builds)
@@ -218,11 +217,11 @@ function createReplacePlugin(
218217
: false,
219218
...(isProduction && isBrowserBuild
220219
? {
221-
'context.onError(': `/*#__PURE__*/ context.onError(`,
222-
'emitError(': `/*#__PURE__*/ emitError(`,
223-
'createCompilerError(': `/*#__PURE__*/ createCompilerError(`,
224-
'createDOMCompilerError(': `/*#__PURE__*/ createDOMCompilerError(`,
225-
}
220+
'context.onError(': `/*#__PURE__*/ context.onError(`,
221+
'emitError(': `/*#__PURE__*/ emitError(`,
222+
'createCompilerError(': `/*#__PURE__*/ createCompilerError(`,
223+
'createDOMCompilerError(': `/*#__PURE__*/ createDOMCompilerError(`,
224+
}
226225
: {}),
227226
}
228227
// allow inline overrides like

0 commit comments

Comments
 (0)