From e9d2488ea1012c0b460008e6aef5dde2e45778d0 Mon Sep 17 00:00:00 2001 From: Mark Lundin Date: Fri, 6 Sep 2024 14:26:21 +0100 Subject: [PATCH 1/8] Add SWC plugin for Rollup --- package-lock.json | 241 ++++++++++++++++++++++++++++++++- package.json | 2 + utils/rollup-babel-options.mjs | 42 ++---- utils/rollup-build-target.mjs | 19 ++- 4 files changed, 269 insertions(+), 35 deletions(-) diff --git a/package-lock.json b/package-lock.json index 781e4da004c..abd07835c24 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "playcanvas", - "version": "2.0.0-dev", + "version": "2.1.0-dev", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "playcanvas", - "version": "2.0.0-dev", + "version": "2.1.0-dev", "license": "MIT", "dependencies": { "@types/webxr": "^0.5.16", @@ -21,8 +21,10 @@ "@rollup/plugin-babel": "^6.0.4", "@rollup/plugin-node-resolve": "^15.2.3", "@rollup/plugin-strip": "^3.0.4", + "@rollup/plugin-swc": "^0.4.0", "@rollup/plugin-terser": "^0.4.4", "@rollup/pluginutils": "^5.1.0", + "@swc/core": "^1.7.23", "c8": "^9.1.0", "chai": "^5.1.0", "eslint": "^8.57.0", @@ -2141,6 +2143,28 @@ } } }, + "node_modules/@rollup/plugin-swc": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-swc/-/plugin-swc-0.4.0.tgz", + "integrity": "sha512-oAtqXa8rOl7BOK1Rz3rRxI+LIL53S9SqO2KSq2UUUzWgOgXg6492Jh5mL2mv/f9cpit8zFWdwILuVeozZ0C8mg==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "smob": "^1.4.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "@swc/core": "^1.3.0", + "rollup": "^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, "node_modules/@rollup/plugin-terser": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/@rollup/plugin-terser/-/plugin-terser-0.4.4.tgz", @@ -2449,6 +2473,219 @@ "integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg==", "dev": true }, + "node_modules/@swc/core": { + "version": "1.7.23", + "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.7.23.tgz", + "integrity": "sha512-VDNkpDvDlreGh2E3tlDj8B3piiuLhhQA/7rIVZpiLUvG1YpucAa6N7iDXA7Gc/+Hah8spaCg/qvEaBkCmcIYCQ==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "@swc/counter": "^0.1.3", + "@swc/types": "^0.1.12" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/swc" + }, + "optionalDependencies": { + "@swc/core-darwin-arm64": "1.7.23", + "@swc/core-darwin-x64": "1.7.23", + "@swc/core-linux-arm-gnueabihf": "1.7.23", + "@swc/core-linux-arm64-gnu": "1.7.23", + "@swc/core-linux-arm64-musl": "1.7.23", + "@swc/core-linux-x64-gnu": "1.7.23", + "@swc/core-linux-x64-musl": "1.7.23", + "@swc/core-win32-arm64-msvc": "1.7.23", + "@swc/core-win32-ia32-msvc": "1.7.23", + "@swc/core-win32-x64-msvc": "1.7.23" + }, + "peerDependencies": { + "@swc/helpers": "*" + }, + "peerDependenciesMeta": { + "@swc/helpers": { + "optional": true + } + } + }, + "node_modules/@swc/core-darwin-arm64": { + "version": "1.7.23", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.7.23.tgz", + "integrity": "sha512-yyOHPfti6yKlQulfVWMt7BVKst+SyEZYCWuQSGMn1KgmNCH/bYufRWfQXIhkGSj44ZkEepJmsJ8tDyIb4k5WyA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-darwin-x64": { + "version": "1.7.23", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.7.23.tgz", + "integrity": "sha512-GzqHwQ0Y1VyjdI/bBKFX2GKm5HD3PIB6OhuAQtWZMTtEr2yIrlT0YK2T+XKh7oIg31JwxGBeQdBk3KTI7DARmQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm-gnueabihf": { + "version": "1.7.23", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.7.23.tgz", + "integrity": "sha512-qwX4gB41OS6/OZkHcpTqLFGsdmvoZyffnJIlgB/kZKwH3lfeJWzv6vx57zXtNpM/t7GoQEe0VZUVdmNjxSxBZw==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-gnu": { + "version": "1.7.23", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.7.23.tgz", + "integrity": "sha512-TsrbUZdMaUwzI7+g/8rHPLWbntMKYSu5Bn5IBSqVKPeyqaXxNnlIUnWXgXcUcRAc+T+Y8ADfr7EiFz9iz5DuSA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-musl": { + "version": "1.7.23", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.7.23.tgz", + "integrity": "sha512-JEdtwdthazKq4PBz53KSubwwK8MvqODAihGSAzc8u3Unq4ojcvaS8b0CwLBeD+kTQ78HpxOXTt3DsFIxpgaCAA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-x64-gnu": { + "version": "1.7.23", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.7.23.tgz", + "integrity": "sha512-V51gFPWaVAHbI1yg9ahsoya3aB4uawye3SZ5uQWgcP7wdCdiv60dw4F5nuPJf5Z1oXD3U/BslXuamv8Oh9vXqQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-x64-musl": { + "version": "1.7.23", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.7.23.tgz", + "integrity": "sha512-BBqQi4+UdeRqag3yM4IJjaHG4yc1o3l9ksENHToE0o/u2DT0FY5+K/DiYGZLC1JHbSFzNqRCYsa7DIzRtZ0A1A==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-arm64-msvc": { + "version": "1.7.23", + "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.7.23.tgz", + "integrity": "sha512-JPk6pvCKncL6bXG7p+NLZf8PWx4FakVvKNdwGeMrYunb+yk1IZf7qf9LJk8+GDGF5QviDXPs8opZrTrfsW80fA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-ia32-msvc": { + "version": "1.7.23", + "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.7.23.tgz", + "integrity": "sha512-2Whxi8d+bLQBzJcQ5qYPHlk02YYVGsMVav0fWk+FnX2z1QRREIu1L1xvrpi7gBpjXp6BIU40ya8GiKeekNT2bg==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-x64-msvc": { + "version": "1.7.23", + "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.7.23.tgz", + "integrity": "sha512-82fARk4/yJ40kwWKY/gdKDisPdtgJE9jgpl/vkNG3alyJxrCzuNM7+CtiKoYbXLeqM8GQTS3wlvCaJu9oQ8dag==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/counter": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.3.tgz", + "integrity": "sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==", + "dev": true + }, + "node_modules/@swc/types": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/@swc/types/-/types-0.1.12.tgz", + "integrity": "sha512-wBJA+SdtkbFhHjTMYH+dEH1y4VpfGdAc2Kw/LK09i9bXd/K6j6PkDcFCEzb6iVfZMkPRrl/q0e3toqTAJdkIVA==", + "dev": true, + "dependencies": { + "@swc/counter": "^0.1.3" + } + }, "node_modules/@types/cookie": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz", diff --git a/package.json b/package.json index 29ae77c7dcc..61ed4fd51cd 100644 --- a/package.json +++ b/package.json @@ -123,8 +123,10 @@ "@rollup/plugin-babel": "^6.0.4", "@rollup/plugin-node-resolve": "^15.2.3", "@rollup/plugin-strip": "^3.0.4", + "@rollup/plugin-swc": "^0.4.0", "@rollup/plugin-terser": "^0.4.4", "@rollup/pluginutils": "^5.1.0", + "@swc/core": "^1.7.23", "c8": "^9.1.0", "chai": "^5.1.0", "eslint": "^8.57.0", diff --git a/utils/rollup-babel-options.mjs b/utils/rollup-babel-options.mjs index 944e10d2c8b..d8b57e8543b 100644 --- a/utils/rollup-babel-options.mjs +++ b/utils/rollup-babel-options.mjs @@ -1,38 +1,24 @@ -/** @typedef {import('@rollup/plugin-babel').RollupBabelInputPluginOptions} RollupBabelInputPluginOptions */ +/** @typedef {import('@swc/core').Options} SWCOptions */ /** - * The options for babel(...) plugin. + * The options for swc(...) plugin. * - * @param {boolean} isDebug - Whether the build is for debug. * @param {boolean} isUMD - Whether the build is for UMD. - * @returns {RollupBabelInputPluginOptions} The babel options. + * @returns {SWCOptions} The swc options. */ -function babelOptions(isDebug, isUMD) { +function swcOptions(isUMD, minify) { return { - babelHelpers: 'bundled', - babelrc: false, - comments: isDebug, - compact: false, - minified: false, - presets: [ - [ - '@babel/preset-env', { - bugfixes: !isUMD, - loose: true, // DECPRECATED IN BABEL 8 - modules: false, - targets: { - esmodules: !isUMD, - browsers: isUMD ? [ - 'fully supports webgl', - '> 0.1%', - 'not dead' - ] : undefined - } - } - ] - ] + minify, + jsc: { + minify: minify ? { mangle: true } : undefined, + externalHelpers: false + }, + env: { + loose: true, + targets: isUMD ? 'fully supports webgl, > 0.1%, not dead' : undefined + } }; } -export { babelOptions }; +export { swcOptions }; diff --git a/utils/rollup-build-target.mjs b/utils/rollup-build-target.mjs index 07fa2019e77..afb0965ca20 100644 --- a/utils/rollup-build-target.mjs +++ b/utils/rollup-build-target.mjs @@ -1,8 +1,7 @@ // official package plugins -import { babel } from '@rollup/plugin-babel'; import resolve from '@rollup/plugin-node-resolve'; import strip from '@rollup/plugin-strip'; -import terser from '@rollup/plugin-terser'; +import swc from '@rollup/plugin-swc'; // unoffical package plugins import jscc from 'rollup-plugin-jscc'; @@ -17,7 +16,7 @@ import { treeshakeIgnore } from './plugins/rollup-treeshake-ignore.mjs'; import { version, revision } from './rollup-version-revision.mjs'; import { getBanner } from './rollup-get-banner.mjs'; -import { babelOptions } from './rollup-babel-options.mjs'; +import { swcOptions } from './rollup-babel-options.mjs'; import { dirname, resolve as pathResolve } from 'path'; import { fileURLToPath } from 'url'; @@ -125,7 +124,7 @@ function getJSCCOptions(buildType, isUMD) { */ function getOutPlugins() { const plugins = [ - terser() + // terser() ]; if (process.env.treemap) { @@ -246,7 +245,17 @@ function buildTarget({ moduleFormat, buildType, bundleState, input = 'src/index. !isDebug ? shaderChunks() : undefined, isDebug ? engineLayerImportValidation(input) : undefined, !isDebug ? strip({ functions: STRIP_FUNCTIONS }) : undefined, - babel(babelOptions(isDebug, isUMD)), + swc({ swc: swcOptions(isUMD, isMin)}), + // swc({ swc: { + // jsc: { + // externalHelpers: true, + // target: 'es2020', + // parser: { + // syntax: 'typescript', + // decorators: true + // } + // } + // }}), !isUMD ? dynamicImportBundlerSuppress() : undefined, !isDebug ? spacesToTabs() : undefined ] From 24067a7153900bd04d29dd883a0defa05b83de5f Mon Sep 17 00:00:00 2001 From: Mark Lundin Date: Fri, 6 Sep 2024 15:11:13 +0100 Subject: [PATCH 2/8] Update SWC options for minification and debugging --- utils/rollup-babel-options.mjs | 16 +++++++++++++--- utils/rollup-build-target.mjs | 8 +++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/utils/rollup-babel-options.mjs b/utils/rollup-babel-options.mjs index d8b57e8543b..382016e2c99 100644 --- a/utils/rollup-babel-options.mjs +++ b/utils/rollup-babel-options.mjs @@ -1,16 +1,26 @@ -/** @typedef {import('@swc/core').Options} SWCOptions */ +/** @typedef {import('@swc/core').Config} SWCOptions */ /** * The options for swc(...) plugin. * + * @param {boolean} isDebug - Whether the build is for debug. * @param {boolean} isUMD - Whether the build is for UMD. + * @param {boolean} minify - Whether to minify. * @returns {SWCOptions} The swc options. */ -function swcOptions(isUMD, minify) { +function swcOptions(isDebug, isUMD, minify) { return { minify, jsc: { - minify: minify ? { mangle: true } : undefined, + minify: { + mangle: true, + format: { + comments: isDebug ? 'all' : false, + }, + compress: { + drop_console: !isDebug, + } + }, externalHelpers: false }, env: { diff --git a/utils/rollup-build-target.mjs b/utils/rollup-build-target.mjs index afb0965ca20..8823d0c1922 100644 --- a/utils/rollup-build-target.mjs +++ b/utils/rollup-build-target.mjs @@ -124,7 +124,6 @@ function getJSCCOptions(buildType, isUMD) { */ function getOutPlugins() { const plugins = [ - // terser() ]; if (process.env.treemap) { @@ -206,6 +205,9 @@ function buildTarget({ moduleFormat, buildType, bundleState, input = 'src/index. */ const target = { input: release.output.file, + plugins: [ + swc({ swc: swcOptions(isDebug, isUMD, isMin)}), + ], output: { plugins: getOutPlugins(), file: `${dir}/${OUT_PREFIX[buildType]}${isUMD ? '.js' : '.mjs'}` @@ -244,8 +246,8 @@ function buildTarget({ moduleFormat, buildType, bundleState, input = 'src/index. isUMD ? dynamicImportLegacyBrowserSupport() : undefined, !isDebug ? shaderChunks() : undefined, isDebug ? engineLayerImportValidation(input) : undefined, - !isDebug ? strip({ functions: STRIP_FUNCTIONS }) : undefined, - swc({ swc: swcOptions(isUMD, isMin)}), + // !isDebug ? strip({ functions: STRIP_FUNCTIONS }) : undefined, + swc({ swc: swcOptions(isDebug, isUMD, isMin)}), // swc({ swc: { // jsc: { // externalHelpers: true, From 613eab97864f808ea3fcd9b4449dec77bf0d7054 Mon Sep 17 00:00:00 2001 From: Mark Lundin Date: Fri, 6 Sep 2024 16:48:22 +0100 Subject: [PATCH 3/8] Update rollup version and add swc options --- package-lock.json | 136 +++++++++--------- package.json | 2 +- utils/rollup-build-target.mjs | 15 +- ...bel-options.mjs => rollup-swc-options.mjs} | 17 ++- 4 files changed, 79 insertions(+), 91 deletions(-) rename utils/{rollup-babel-options.mjs => rollup-swc-options.mjs} (70%) diff --git a/package-lock.json b/package-lock.json index abd07835c24..b3876567217 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38,7 +38,7 @@ "karma-spec-reporter": "^0.0.36", "mocha": "^10.4.0", "publint": "^0.2.7", - "rollup": "^4.16.4", + "rollup": "^4.21.2", "rollup-plugin-dts": "^6.0.2", "rollup-plugin-jscc": "2.0.0", "rollup-plugin-visualizer": "^5.12.0", @@ -2210,9 +2210,9 @@ } }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.16.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.16.4.tgz", - "integrity": "sha512-GkhjAaQ8oUTOKE4g4gsZ0u8K/IHU1+2WQSgS1TwTcYvL+sjbaQjNHFXbOJ6kgqGHIO1DfUhI/Sphi9GkRT9K+Q==", + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.21.2.tgz", + "integrity": "sha512-fSuPrt0ZO8uXeS+xP3b+yYTCBUd05MoSp2N/MFOgjhhUhMmchXlpTQrTpI8T+YAwAQuK7MafsCOxW7VrPMrJcg==", "cpu": [ "arm" ], @@ -2223,9 +2223,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.16.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.16.4.tgz", - "integrity": "sha512-Bvm6D+NPbGMQOcxvS1zUl8H7DWlywSXsphAeOnVeiZLQ+0J6Is8T7SrjGTH29KtYkiY9vld8ZnpV3G2EPbom+w==", + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.21.2.tgz", + "integrity": "sha512-xGU5ZQmPlsjQS6tzTTGwMsnKUtu0WVbl0hYpTPauvbRAnmIvpInhJtgjj3mcuJpEiuUw4v1s4BimkdfDWlh7gA==", "cpu": [ "arm64" ], @@ -2236,9 +2236,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.16.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.16.4.tgz", - "integrity": "sha512-i5d64MlnYBO9EkCOGe5vPR/EeDwjnKOGGdd7zKFhU5y8haKhQZTN2DgVtpODDMxUr4t2K90wTUJg7ilgND6bXw==", + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.21.2.tgz", + "integrity": "sha512-99AhQ3/ZMxU7jw34Sq8brzXqWH/bMnf7ZVhvLk9QU2cOepbQSVTns6qoErJmSiAvU3InRqC2RRZ5ovh1KN0d0Q==", "cpu": [ "arm64" ], @@ -2249,9 +2249,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.16.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.16.4.tgz", - "integrity": "sha512-WZupV1+CdUYehaZqjaFTClJI72fjJEgTXdf4NbW69I9XyvdmztUExBtcI2yIIU6hJtYvtwS6pkTkHJz+k08mAQ==", + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.21.2.tgz", + "integrity": "sha512-ZbRaUvw2iN/y37x6dY50D8m2BnDbBjlnMPotDi/qITMJ4sIxNY33HArjikDyakhSv0+ybdUxhWxE6kTI4oX26w==", "cpu": [ "x64" ], @@ -2262,9 +2262,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.16.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.16.4.tgz", - "integrity": "sha512-ADm/xt86JUnmAfA9mBqFcRp//RVRt1ohGOYF6yL+IFCYqOBNwy5lbEK05xTsEoJq+/tJzg8ICUtS82WinJRuIw==", + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.21.2.tgz", + "integrity": "sha512-ztRJJMiE8nnU1YFcdbd9BcH6bGWG1z+jP+IPW2oDUAPxPjo9dverIOyXz76m6IPA6udEL12reYeLojzW2cYL7w==", "cpu": [ "arm" ], @@ -2275,9 +2275,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.16.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.16.4.tgz", - "integrity": "sha512-tJfJaXPiFAG+Jn3cutp7mCs1ePltuAgRqdDZrzb1aeE3TktWWJ+g7xK9SNlaSUFw6IU4QgOxAY4rA+wZUT5Wfg==", + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.21.2.tgz", + "integrity": "sha512-flOcGHDZajGKYpLV0JNc0VFH361M7rnV1ee+NTeC/BQQ1/0pllYcFmxpagltANYt8FYf9+kL6RSk80Ziwyhr7w==", "cpu": [ "arm" ], @@ -2288,9 +2288,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.16.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.16.4.tgz", - "integrity": "sha512-7dy1BzQkgYlUTapDTvK997cgi0Orh5Iu7JlZVBy1MBURk7/HSbHkzRnXZa19ozy+wwD8/SlpJnOOckuNZtJR9w==", + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.21.2.tgz", + "integrity": "sha512-69CF19Kp3TdMopyteO/LJbWufOzqqXzkrv4L2sP8kfMaAQ6iwky7NoXTp7bD6/irKgknDKM0P9E/1l5XxVQAhw==", "cpu": [ "arm64" ], @@ -2301,9 +2301,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.16.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.16.4.tgz", - "integrity": "sha512-zsFwdUw5XLD1gQe0aoU2HVceI6NEW7q7m05wA46eUAyrkeNYExObfRFQcvA6zw8lfRc5BHtan3tBpo+kqEOxmg==", + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.21.2.tgz", + "integrity": "sha512-48pD/fJkTiHAZTnZwR0VzHrao70/4MlzJrq0ZsILjLW/Ab/1XlVUStYyGt7tdyIiVSlGZbnliqmult/QGA2O2w==", "cpu": [ "arm64" ], @@ -2314,9 +2314,9 @@ ] }, "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { - "version": "4.16.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.16.4.tgz", - "integrity": "sha512-p8C3NnxXooRdNrdv6dBmRTddEapfESEUflpICDNKXpHvTjRRq1J82CbU5G3XfebIZyI3B0s074JHMWD36qOW6w==", + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.21.2.tgz", + "integrity": "sha512-cZdyuInj0ofc7mAQpKcPR2a2iu4YM4FQfuUzCVA2u4HI95lCwzjoPtdWjdpDKyHxI0UO82bLDoOaLfpZ/wviyQ==", "cpu": [ "ppc64" ], @@ -2327,9 +2327,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.16.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.16.4.tgz", - "integrity": "sha512-Lh/8ckoar4s4Id2foY7jNgitTOUQczwMWNYi+Mjt0eQ9LKhr6sK477REqQkmy8YHY3Ca3A2JJVdXnfb3Rrwkng==", + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.21.2.tgz", + "integrity": "sha512-RL56JMT6NwQ0lXIQmMIWr1SW28z4E4pOhRRNqwWZeXpRlykRIlEpSWdsgNWJbYBEWD84eocjSGDu/XxbYeCmwg==", "cpu": [ "riscv64" ], @@ -2340,9 +2340,9 @@ ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.16.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.16.4.tgz", - "integrity": "sha512-1xwwn9ZCQYuqGmulGsTZoKrrn0z2fAur2ujE60QgyDpHmBbXbxLaQiEvzJWDrscRq43c8DnuHx3QorhMTZgisQ==", + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.21.2.tgz", + "integrity": "sha512-PMxkrWS9z38bCr3rWvDFVGD6sFeZJw4iQlhrup7ReGmfn7Oukrr/zweLhYX6v2/8J6Cep9IEA/SmjXjCmSbrMQ==", "cpu": [ "s390x" ], @@ -2353,9 +2353,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.16.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.16.4.tgz", - "integrity": "sha512-LuOGGKAJ7dfRtxVnO1i3qWc6N9sh0Em/8aZ3CezixSTM+E9Oq3OvTsvC4sm6wWjzpsIlOCnZjdluINKESflJLA==", + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.21.2.tgz", + "integrity": "sha512-B90tYAUoLhU22olrafY3JQCFLnT3NglazdwkHyxNDYF/zAxJt5fJUB/yBoWFoIQ7SQj+KLe3iL4BhOMa9fzgpw==", "cpu": [ "x64" ], @@ -2366,9 +2366,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.16.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.16.4.tgz", - "integrity": "sha512-ch86i7KkJKkLybDP2AtySFTRi5fM3KXp0PnHocHuJMdZwu7BuyIKi35BE9guMlmTpwwBTB3ljHj9IQXnTCD0vA==", + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.21.2.tgz", + "integrity": "sha512-7twFizNXudESmC9oneLGIUmoHiiLppz/Xs5uJQ4ShvE6234K0VB1/aJYU3f/4g7PhssLGKBVCC37uRkkOi8wjg==", "cpu": [ "x64" ], @@ -2379,9 +2379,9 @@ ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.16.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.16.4.tgz", - "integrity": "sha512-Ma4PwyLfOWZWayfEsNQzTDBVW8PZ6TUUN1uFTBQbF2Chv/+sjenE86lpiEwj2FiviSmSZ4Ap4MaAfl1ciF4aSA==", + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.21.2.tgz", + "integrity": "sha512-9rRero0E7qTeYf6+rFh3AErTNU1VCQg2mn7CQcI44vNUWM9Ze7MSRS/9RFuSsox+vstRt97+x3sOhEey024FRQ==", "cpu": [ "arm64" ], @@ -2392,9 +2392,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.16.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.16.4.tgz", - "integrity": "sha512-9m/ZDrQsdo/c06uOlP3W9G2ENRVzgzbSXmXHT4hwVaDQhYcRpi9bgBT0FTG9OhESxwK0WjQxYOSfv40cU+T69w==", + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.21.2.tgz", + "integrity": "sha512-5rA4vjlqgrpbFVVHX3qkrCo/fZTj1q0Xxpg+Z7yIo3J2AilW7t2+n6Q8Jrx+4MrYpAnjttTYF8rr7bP46BPzRw==", "cpu": [ "ia32" ], @@ -2405,9 +2405,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.16.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.16.4.tgz", - "integrity": "sha512-YunpoOAyGLDseanENHmbFvQSfVL5BxW3k7hhy0eN4rb3gS/ct75dVD0EXOWIqFT/nE8XYW6LP6vz6ctKRi0k9A==", + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.21.2.tgz", + "integrity": "sha512-6UUxd0+SKomjdzuAcp+HAmxw1FlGBnl1v2yEPSabtx4lBfdXHDVsW7+lQkgz9cNFJGY3AWR7+V8P5BqkD9L9nA==", "cpu": [ "x64" ], @@ -8021,9 +8021,9 @@ } }, "node_modules/rollup": { - "version": "4.16.4", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.16.4.tgz", - "integrity": "sha512-kuaTJSUbz+Wsb2ATGvEknkI12XV40vIiHmLuFlejoo7HtDok/O5eDDD0UpCVY5bBX5U5RYo8wWP83H7ZsqVEnA==", + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.21.2.tgz", + "integrity": "sha512-e3TapAgYf9xjdLvKQCkQTnbTKd4a6jwlpQSJJFokHGaX2IVjoEqkIIhiQfqsi0cdwlOD+tQGuOd5AJkc5RngBw==", "dev": true, "dependencies": { "@types/estree": "1.0.5" @@ -8036,22 +8036,22 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.16.4", - "@rollup/rollup-android-arm64": "4.16.4", - "@rollup/rollup-darwin-arm64": "4.16.4", - "@rollup/rollup-darwin-x64": "4.16.4", - "@rollup/rollup-linux-arm-gnueabihf": "4.16.4", - "@rollup/rollup-linux-arm-musleabihf": "4.16.4", - "@rollup/rollup-linux-arm64-gnu": "4.16.4", - "@rollup/rollup-linux-arm64-musl": "4.16.4", - "@rollup/rollup-linux-powerpc64le-gnu": "4.16.4", - "@rollup/rollup-linux-riscv64-gnu": "4.16.4", - "@rollup/rollup-linux-s390x-gnu": "4.16.4", - "@rollup/rollup-linux-x64-gnu": "4.16.4", - "@rollup/rollup-linux-x64-musl": "4.16.4", - "@rollup/rollup-win32-arm64-msvc": "4.16.4", - "@rollup/rollup-win32-ia32-msvc": "4.16.4", - "@rollup/rollup-win32-x64-msvc": "4.16.4", + "@rollup/rollup-android-arm-eabi": "4.21.2", + "@rollup/rollup-android-arm64": "4.21.2", + "@rollup/rollup-darwin-arm64": "4.21.2", + "@rollup/rollup-darwin-x64": "4.21.2", + "@rollup/rollup-linux-arm-gnueabihf": "4.21.2", + "@rollup/rollup-linux-arm-musleabihf": "4.21.2", + "@rollup/rollup-linux-arm64-gnu": "4.21.2", + "@rollup/rollup-linux-arm64-musl": "4.21.2", + "@rollup/rollup-linux-powerpc64le-gnu": "4.21.2", + "@rollup/rollup-linux-riscv64-gnu": "4.21.2", + "@rollup/rollup-linux-s390x-gnu": "4.21.2", + "@rollup/rollup-linux-x64-gnu": "4.21.2", + "@rollup/rollup-linux-x64-musl": "4.21.2", + "@rollup/rollup-win32-arm64-msvc": "4.21.2", + "@rollup/rollup-win32-ia32-msvc": "4.21.2", + "@rollup/rollup-win32-x64-msvc": "4.21.2", "fsevents": "~2.3.2" } }, diff --git a/package.json b/package.json index 61ed4fd51cd..4fcd4a41fe4 100644 --- a/package.json +++ b/package.json @@ -140,7 +140,7 @@ "karma-spec-reporter": "^0.0.36", "mocha": "^10.4.0", "publint": "^0.2.7", - "rollup": "^4.16.4", + "rollup": "^4.21.2", "rollup-plugin-dts": "^6.0.2", "rollup-plugin-jscc": "2.0.0", "rollup-plugin-visualizer": "^5.12.0", diff --git a/utils/rollup-build-target.mjs b/utils/rollup-build-target.mjs index 8823d0c1922..ce60c5891e0 100644 --- a/utils/rollup-build-target.mjs +++ b/utils/rollup-build-target.mjs @@ -1,6 +1,6 @@ // official package plugins import resolve from '@rollup/plugin-node-resolve'; -import strip from '@rollup/plugin-strip'; +// import strip from '@rollup/plugin-strip'; import swc from '@rollup/plugin-swc'; // unoffical package plugins @@ -16,7 +16,7 @@ import { treeshakeIgnore } from './plugins/rollup-treeshake-ignore.mjs'; import { version, revision } from './rollup-version-revision.mjs'; import { getBanner } from './rollup-get-banner.mjs'; -import { swcOptions } from './rollup-babel-options.mjs'; +import { swcOptions } from './rollup-swc-options.mjs'; import { dirname, resolve as pathResolve } from 'path'; import { fileURLToPath } from 'url'; @@ -246,18 +246,7 @@ function buildTarget({ moduleFormat, buildType, bundleState, input = 'src/index. isUMD ? dynamicImportLegacyBrowserSupport() : undefined, !isDebug ? shaderChunks() : undefined, isDebug ? engineLayerImportValidation(input) : undefined, - // !isDebug ? strip({ functions: STRIP_FUNCTIONS }) : undefined, swc({ swc: swcOptions(isDebug, isUMD, isMin)}), - // swc({ swc: { - // jsc: { - // externalHelpers: true, - // target: 'es2020', - // parser: { - // syntax: 'typescript', - // decorators: true - // } - // } - // }}), !isUMD ? dynamicImportBundlerSuppress() : undefined, !isDebug ? spacesToTabs() : undefined ] diff --git a/utils/rollup-babel-options.mjs b/utils/rollup-swc-options.mjs similarity index 70% rename from utils/rollup-babel-options.mjs rename to utils/rollup-swc-options.mjs index 382016e2c99..9d5cfbb5ba4 100644 --- a/utils/rollup-babel-options.mjs +++ b/utils/rollup-swc-options.mjs @@ -10,23 +10,22 @@ */ function swcOptions(isDebug, isUMD, minify) { return { - minify, + minify: minify, jsc: { - minify: { - mangle: true, + minify: { format: { - comments: isDebug ? 'all' : false, + comments: isDebug ? 'all' : false }, - compress: { - drop_console: !isDebug, - } + compress: minify && isDebug ? { + drop_console: false + } : undefined }, externalHelpers: false }, - env: { + env: isUMD ? { loose: true, targets: isUMD ? 'fully supports webgl, > 0.1%, not dead' : undefined - } + } : undefined }; } From 91d8edbc3c524cf9ea2081aeb22d59d753b5ad28 Mon Sep 17 00:00:00 2001 From: Mark Lundin Date: Mon, 9 Sep 2024 16:36:04 +0100 Subject: [PATCH 4/8] Refactor buildTarget function and swcOptions --- utils/rollup-build-target.mjs | 32 ++------------------------------ utils/rollup-swc-options.mjs | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 36 deletions(-) diff --git a/utils/rollup-build-target.mjs b/utils/rollup-build-target.mjs index ce60c5891e0..dfba962de0a 100644 --- a/utils/rollup-build-target.mjs +++ b/utils/rollup-build-target.mjs @@ -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 ] diff --git a/utils/rollup-swc-options.mjs b/utils/rollup-swc-options.mjs index 9d5cfbb5ba4..0da366f67ec 100644 --- a/utils/rollup-swc-options.mjs +++ b/utils/rollup-swc-options.mjs @@ -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' + } }; } From bb1d6fdcfdfcf4a0275332f0f04d8fa5baa04144 Mon Sep 17 00:00:00 2001 From: Mark Lundin Date: Tue, 10 Sep 2024 15:28:30 +0100 Subject: [PATCH 5/8] Update package-lock.json and rollup-swc-options.mjs --- examples/package-lock.json | 30 +++++++++++++----------------- utils/rollup-swc-options.mjs | 28 +++++++++++++--------------- 2 files changed, 26 insertions(+), 32 deletions(-) diff --git a/examples/package-lock.json b/examples/package-lock.json index a9d8c1be505..d8a866d00ec 100644 --- a/examples/package-lock.json +++ b/examples/package-lock.json @@ -43,30 +43,31 @@ }, "..": { "name": "playcanvas", - "version": "1.71.0-dev", + "version": "2.1.0-dev", "dev": true, "license": "MIT", "dependencies": { - "@types/webxr": "^0.5.15", + "@types/webxr": "^0.5.16", "@webgpu/types": "^0.1.40" }, "devDependencies": { "@babel/core": "^7.24.4", - "@babel/eslint-parser": "^7.24.1", + "@babel/eslint-parser": "^7.25.1", "@babel/preset-env": "^7.24.4", - "@playcanvas/canvas-mock": "^1.0.1", - "@playcanvas/eslint-config": "^1.7.1", + "@playcanvas/eslint-config": "^2.0.2", "@rollup/plugin-babel": "^6.0.4", "@rollup/plugin-node-resolve": "^15.2.3", "@rollup/plugin-strip": "^3.0.4", "@rollup/plugin-terser": "^0.4.4", "@rollup/pluginutils": "^5.1.0", - "c8": "^9.1.0", + "c8": "^10.1.2", + "canvas": "^2.11.2", "chai": "^5.1.0", - "eslint": "^8.57.0", + "eslint": "^9.10.0", "fflate": "^0.8.2", "global-jsdom": "^24.0.0", - "jsdom": "^24.0.0", + "globals": "^15.9.0", + "jsdom": "^24.1.3", "karma": "^6.4.3", "karma-chrome-launcher": "^3.2.0", "karma-mocha": "^2.0.1", @@ -79,10 +80,10 @@ "rollup-plugin-jscc": "2.0.0", "rollup-plugin-visualizer": "^5.12.0", "serve": "^14.2.2", - "sinon": "^17.0.1", - "typedoc": "^0.25.13", - "typedoc-plugin-mdn-links": "^3.1.22", - "typescript": "^5.4.5", + "sinon": "^18.0.0", + "typedoc": "^0.26.3", + "typedoc-plugin-mdn-links": "^3.2.2", + "typescript": "^5.5.3", "xhr2": "^0.2.1" }, "engines": { @@ -1936,11 +1937,6 @@ "node": ">= 8" } }, - "../node_modules/@playcanvas/canvas-mock": { - "version": "1.0.1", - "dev": true, - "license": "MIT" - }, "../node_modules/@playcanvas/eslint-config": { "version": "1.7.1", "dev": true, diff --git a/utils/rollup-swc-options.mjs b/utils/rollup-swc-options.mjs index 0da366f67ec..6ab300e9776 100644 --- a/utils/rollup-swc-options.mjs +++ b/utils/rollup-swc-options.mjs @@ -9,29 +9,27 @@ * @returns {SWCOptions} The swc options. */ function swcOptions(isDebug, isUMD, minify) { + return { minify, - module: { - type: 'es6' // Keep ES module syntax (equivalent to Babel's modules: false) - }, jsc: { - 'parser': { - 'syntax': 'ecmascript' - }, minify: { - format: { - comments: isDebug ? 'some' : false - }, - compress: minify && isDebug ? { - drop_console: false, - pure_funcs: [] + // format: { + // comments: !isDebug || minify ? false : 'some' + // }, + mangle: minify, + compress: (!isDebug && minify) ? { + reduce_funcs: true, + drop_console: true, + pure_funcs: [], + inline: 3, } : undefined }, - externalHelpers: false + externalHelpers: false, + loose: true, }, env: { - loose: true, - targets: isUMD ? 'fully supports webgl, > 0.1%, not dead' : 'chrome 63' + targets: isUMD ? 'fully supports webgl and > 0.1% and not dead' : 'supports es6-module' } }; From 605d165572772d4ec440392f9e880cae7d58d4f5 Mon Sep 17 00:00:00 2001 From: Mark Lundin Date: Fri, 13 Sep 2024 14:00:18 +0100 Subject: [PATCH 6/8] linting --- utils/rollup-swc-options.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/rollup-swc-options.mjs b/utils/rollup-swc-options.mjs index 6ab300e9776..51a52ae8dbb 100644 --- a/utils/rollup-swc-options.mjs +++ b/utils/rollup-swc-options.mjs @@ -22,11 +22,11 @@ function swcOptions(isDebug, isUMD, minify) { reduce_funcs: true, drop_console: true, pure_funcs: [], - inline: 3, + inline: 3 } : undefined }, externalHelpers: false, - loose: true, + loose: true }, env: { targets: isUMD ? 'fully supports webgl and > 0.1% and not dead' : 'supports es6-module' From 73813d8041e0e3876ef84f293efb2b8959f49ce7 Mon Sep 17 00:00:00 2001 From: Mark Lundin Date: Fri, 13 Sep 2024 14:05:54 +0100 Subject: [PATCH 7/8] added strip plugin --- utils/rollup-build-target.mjs | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/utils/rollup-build-target.mjs b/utils/rollup-build-target.mjs index 7998b5d9491..a4f56977e2f 100644 --- a/utils/rollup-build-target.mjs +++ b/utils/rollup-build-target.mjs @@ -1,6 +1,6 @@ // official package plugins import resolve from '@rollup/plugin-node-resolve'; -// import strip from '@rollup/plugin-strip'; +import strip from '@rollup/plugin-strip'; import swc from '@rollup/plugin-swc'; // unofficial package plugins @@ -36,6 +36,34 @@ 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)', @@ -218,6 +246,7 @@ function buildTarget({ moduleFormat, buildType, bundleState, input = 'src/index. isUMD ? dynamicImportLegacyBrowserSupport() : undefined, !isDebug ? shaderChunks() : undefined, isDebug ? engineLayerImportValidation(input) : undefined, + !isDebug ? strip({ functions: STRIP_FUNCTIONS }) : undefined, swc({ swc: swcOptions(isDebug, isUMD, isMin) }), !isUMD ? dynamicImportBundlerSuppress() : undefined, !isDebug ? spacesToTabs() : undefined From 813fb425e99d68ebc7472cf556540f088fc3aff0 Mon Sep 17 00:00:00 2001 From: Mark Lundin Date: Fri, 13 Sep 2024 14:15:24 +0100 Subject: [PATCH 8/8] Skipping lib check for tsconfig --- tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 691968a1088..9d5780adb73 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -18,7 +18,8 @@ "compilerOptions": { "allowSyntheticDefaultImports": true, "checkJs": false, - "typeRoots": [ "./node_modules/@types" ] + "typeRoots": [ "./node_modules/@types" ], + "skipLibCheck": true }, "entryPoints": [ "./src/index.js" ], "excludeNotDocumented": true,