mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeMirror
synced 2024-11-23 13:56:44 +00:00
rollup: speed up dev build by bypassing babel and terser plugins
Brings it down from ~3 secs on my machine to ~600 ms. This also allows for debuggers, and essentially eliminates the need for source maps on your local (though we should probably still look into them for prod). Change-Id: I4c164b409b2c327e439e1524d4a898693bd8d907
This commit is contained in:
parent
2aa6d5c564
commit
198a1f7d72
|
@ -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 .",
|
||||
|
|
|
@ -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.
|
||||
|
@ -67,6 +69,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;
|
||||
}
|
||||
|
@ -74,9 +82,9 @@ module.exports = [
|
|||
hook: 'writeBundle'
|
||||
} ),
|
||||
|
||||
babel( { babelHelpers: 'bundled' } ),
|
||||
isProduction ? babel( { babelHelpers: 'bundled' } ) : null,
|
||||
|
||||
terser()
|
||||
isProduction ? terser() : null
|
||||
],
|
||||
|
||||
onwarn: ( warning, warn ) => {
|
||||
|
|
Loading…
Reference in a new issue