Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaces Terser/Babel. Improves Build Time #6920

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Refactor buildTarget function and swcOptions
marklundin committed Sep 9, 2024
commit 91d8edbc3c524cf9ea2081aeb22d59d753b5ad28
32 changes: 2 additions & 30 deletions utils/rollup-build-target.mjs
Original file line number Diff line number Diff line change
@@ -36,34 +36,6 @@ const TREESHAKE_IGNORE_REGEXES = [
/polyfill/
];

const STRIP_FUNCTIONS = [
'Debug.assert',
'Debug.assertDeprecated',
'Debug.assertDestroyed',
'Debug.call',
'Debug.deprecated',
'Debug.warn',
'Debug.warnOnce',
'Debug.error',
'Debug.errorOnce',
'Debug.log',
'Debug.logOnce',
'Debug.removed',
'Debug.trace',
'DebugHelper.setName',
'DebugHelper.setLabel',
'DebugHelper.setDestroyed',
'DebugGraphics.toString',
'DebugGraphics.clearGpuMarkers',
'DebugGraphics.pushGpuMarker',
'DebugGraphics.popGpuMarker',
'WebgpuDebug.validate',
'WebgpuDebug.memory',
'WebgpuDebug.internal',
'WebgpuDebug.end',
'WorldClustersDebug.render'
];

const BANNER = {
debug: ' (DEBUG)',
release: ' (RELEASE)',
@@ -206,7 +178,7 @@ function buildTarget({ moduleFormat, buildType, bundleState, input = 'src/index.
const target = {
input: release.output.file,
plugins: [
swc({ swc: swcOptions(isDebug, isUMD, isMin)}),
swc({ swc: swcOptions(isDebug, isUMD, isMin) })
],
output: {
plugins: getOutPlugins(),
@@ -246,7 +218,7 @@ function buildTarget({ moduleFormat, buildType, bundleState, input = 'src/index.
isUMD ? dynamicImportLegacyBrowserSupport() : undefined,
!isDebug ? shaderChunks() : undefined,
isDebug ? engineLayerImportValidation(input) : undefined,
swc({ swc: swcOptions(isDebug, isUMD, isMin)}),
swc({ swc: swcOptions(isDebug, isUMD, isMin) }),
!isUMD ? dynamicImportBundlerSuppress() : undefined,
!isDebug ? spacesToTabs() : undefined
]
19 changes: 13 additions & 6 deletions utils/rollup-swc-options.mjs
Original file line number Diff line number Diff line change
@@ -10,22 +10,29 @@
*/
function swcOptions(isDebug, isUMD, minify) {
return {
minify: minify,
minify,
module: {
type: 'es6' // Keep ES module syntax (equivalent to Babel's modules: false)
},
jsc: {
'parser': {
'syntax': 'ecmascript'
},
minify: {
format: {
comments: isDebug ? 'all' : false
comments: isDebug ? 'some' : false
},
compress: minify && isDebug ? {
drop_console: false
drop_console: false,
pure_funcs: []
} : undefined
},
externalHelpers: false
},
env: isUMD ? {
env: {
loose: true,
targets: isUMD ? 'fully supports webgl, > 0.1%, not dead' : undefined
} : undefined
targets: isUMD ? 'fully supports webgl, > 0.1%, not dead' : 'chrome 63'
}
};

}