Skip to content

Commit

Permalink
Change fork modules to use production only when NODE_ENV explicitly s…
Browse files Browse the repository at this point in the history
…et to production (#7065)
  • Loading branch information
etrepum authored Jan 19, 2025
1 parent 46c9c2f commit d319b07
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,19 +353,19 @@ function forkModuleContent(
if (target === 'cjs') {
lines.push(
`'use strict'`,
`const ${outputFileName} = process.env.NODE_ENV === 'development' ? require('${devFileName}') : require('${prodFileName}');`,
`const ${outputFileName} = process.env.NODE_ENV !== 'production' ? require('${devFileName}') : require('${prodFileName}');`,
`module.exports = ${outputFileName};`,
);
} else {
if (target === 'esm') {
lines.push(
`import * as modDev from '${devFileName}';`,
`import * as modProd from '${prodFileName}';`,
`const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;`,
`const mod = process.env.NODE_ENV !== 'production' ? modDev : modProd;`,
);
} else if (target === 'node') {
lines.push(
`const mod = await (process.env.NODE_ENV === 'development' ? import('${devFileName}') : import('${prodFileName}'));`,
`const mod = await (process.env.NODE_ENV !== 'production' ? import('${devFileName}') : import('${prodFileName}'));`,
);
}
for (const name of exports) {
Expand Down

0 comments on commit d319b07

Please sign in to comment.