Commit 8743910d authored by Robert Knight's avatar Robert Knight

Use @rollup/plugin-virtual to exclude modules in production

Make conditional exclusion of modules work the same way in the app
bundle as in the tests bundle.
parent e40f8438
...@@ -5,18 +5,19 @@ import { nodeResolve } from '@rollup/plugin-node-resolve'; ...@@ -5,18 +5,19 @@ import { nodeResolve } from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace'; import replace from '@rollup/plugin-replace';
import { string } from 'rollup-plugin-string'; import { string } from 'rollup-plugin-string';
import { terser } from 'rollup-plugin-terser'; import { terser } from 'rollup-plugin-terser';
import virtual from '@rollup/plugin-virtual';
const isProd = process.env.NODE_ENV === 'production'; const isProd = process.env.NODE_ENV === 'production';
const prodPlugins = []; const prodPlugins = [];
const prodAliases = [];
if (isProd) { if (isProd) {
prodPlugins.push(terser()); prodPlugins.push(terser());
// Exclude 'preact/debug' from production builds. // Eliminate debug-only imports.
prodAliases.push({ prodPlugins.push(
find: 'preact/debug', virtual({
replacement: 'preact', 'preact/debug': '',
}); })
);
} }
function bundleConfig(name, entryFile) { function bundleConfig(name, entryFile) {
...@@ -44,7 +45,6 @@ function bundleConfig(name, entryFile) { ...@@ -44,7 +45,6 @@ function bundleConfig(name, entryFile) {
find: 'preact/compat/jsx-dev-runtime', find: 'preact/compat/jsx-dev-runtime',
replacement: 'preact/jsx-dev-runtime', replacement: 'preact/jsx-dev-runtime',
}, },
...prodAliases,
], ],
}), }),
replace({ replace({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment