Merge "rollup: speed up dev build by bypassing babel and terser plugins"

This commit is contained in:
jenkins-bot 2024-05-14 02:12:23 +00:00 committed by Gerrit Code Review
commit 549539c3b5
2 changed files with 11 additions and 3 deletions

View file

@ -3,7 +3,7 @@
"private": true,
"scripts": {
"start": "rollup -c --watch",
"build": "rollup -c",
"build": "rollup -c --environment BUILD:production",
"test": "npm run test:lint && npm run test:unit && npm run check-built-assets",
"test:lint": "npm run test:lint:styles && npm run test:lint:js && npm run test:lint:i18n",
"test:lint:js": "eslint --cache .",

View file

@ -5,6 +5,8 @@ const copy = require( 'rollup-plugin-copy' );
const babel = require( '@rollup/plugin-babel' );
const terser = require( '@rollup/plugin-terser' );
const isProduction = process.env.BUILD === 'production';
/**
* Mapping of import paths to ResourceLoader module names.
* See usage in 'plugins' below for explanation.
@ -68,6 +70,12 @@ module.exports = [
`require("${ alias }")`,
`require("${ importAliases[ alias ] }")`
);
// Yuck, need to do the same with single apostrophes
// in the event terser is disabled such as during dev builds.
contents = contents.toString().replace(
`require('${ alias }')`,
`require('${ importAliases[ alias ] }')`
);
} );
return contents;
}
@ -75,9 +83,9 @@ module.exports = [
hook: 'writeBundle'
} ),
babel( { babelHelpers: 'bundled' } ),
isProduction ? babel( { babelHelpers: 'bundled' } ) : null,
terser()
isProduction ? terser() : null
],
onwarn: ( warning, warn ) => {