Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
baseConfig.plugins.unshift(multiEntry({ exports: false }));
// different output file
baseConfig.output.file = "dist-test/index.node.js";
// mark assert as external
baseConfig.external.push("assert", "fs", "path");
baseConfig.context = "null";
// Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, rollup started respecting
// the "sideEffects" field in package.json. Since our package.json sets "sideEffects=false", this also
// applies to test code, which causes all tests to be removed by tree-shaking.
baseConfig.treeshake = false;
} else if (production) {
baseConfig.plugins.push(terser());
}
return baseConfig;
}
baseConfig.input = "dist-esm/test/**/*.spec.js";
baseConfig.input = ["dist-esm/test/*.spec.js", "dist-esm/test/node/*.spec.js"];
baseConfig.plugins.unshift(multiEntry({ exports: false }));
// different output file
baseConfig.output.file = "test-dist/index.js";
// mark assert as external
baseConfig.external.push("assert");
// Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, rollup started respecting
// the "sideEffects" field in package.json. Since our package.json sets "sideEffects=false", this also
// applies to test code, which causes all tests to be removed by tree-shaking.
baseConfig.treeshake = false;
} else if (production) {
baseConfig.plugins.push(terser());
}
return baseConfig;
}
},
)
}
if (pkg.browser) {
config.push(
// umd bundle min
{
external: nodeModule,
input: pkg.module,
plugins: [
resolve({
mainFields: ['browser', 'module', 'main']
}),
commonjs(),
production && terser(uglifyOpts),
],
output: {
amd: { id: name },
banner,
file: `${targetDir}/${name}.umd.min.js`,
format: 'umd',
globals,
name,
sourcemap: production ? true : false,
},
},
)
}
if (pkg.bin) {
const shebang = `#!/usr/bin/env node\n\n${banner}`
]
},
// Only the global variable API. No UI
{
input: "src/import-map-overrides-api.js",
output: {
file: "dist/import-map-overrides-api.js",
format: "iife",
sourcemap: true
},
plugins: [
babel({
exclude: "node_modules/**"
}),
isProduction &&
terser({
compress: {
passes: 2
},
sourcemap: true
})
]
}
];
babel({
// Disable the logic that checks for local Babel config files:
// https://github.com/GoogleChrome/workbox/issues/2111
babelrc: false,
configFile: false,
presets: [[presetEnv, {
targets: {
browsers: babelPresetEnvTargets,
},
loose: true,
}]],
}),
];
if (mode === 'production') {
plugins.push(terser({
mangle: {
toplevel: true,
properties: {
regex: /(^_|_$)/,
},
},
}));
}
const rollupConfig = {
plugins,
input: temporaryFile,
};
// Rollup will inline the runtime by default. If we don't want that, we need
// to add in some additional config.
resolveCss({
code: css.code,
map: css.map,
});
css.write(pkgStyle);
},
preprocess,
}),
resolve(),
commonjs(),
buble({
transforms: {
dangerousForOf: true,
},
}),
terser(terserOpts),
],
});
const bundleElement = await rollup.rollup({
input: pkgSvelte,
plugins: [
svelte({
customElement: true,
preprocess,
// FIXME: Make this customisable or use a new technique to name tags
tag: pkgName!.replace('@minna-ui/', 'minna-'),
}),
resolve(),
commonjs(),
buble({
transforms: {
import { terser } from "rollup-plugin-terser";
import tslint from "rollup-plugin-tslint";
import typescript2 from "rollup-plugin-typescript2";
import * as typescript from "typescript";
import extendedPkg from "./extended/package.json";
import pkg from "./package.json";
const plugins = [
tslint({}),
typescript2({
typescript: typescript,
}),
];
if (!process.env.ROLLUP_WATCH) {
plugins.push(terser());
}
const configs = [ {
input: "src/index.ts",
output: [
{
file: pkg.main,
format: "umd",
name: "webauthnJSON",
sourcemap: true,
},
{
file: pkg.module,
format: "esm",
sourcemap: true,
},
];
if (isDev) {
plugins.push(
serve({
open: false,
openPage: "/index.html",
historyApiFallback: "/index.html",
contentBase: ["./build"]
}),
livereload({
watch: "build"
})
);
} else if (isProd) {
plugins.push(terser({ sourcemap: true }));
}
module.exports = {
input: "src/index.ts",
output: {
sourcemap: true,
name: "main",
file: "build/js/main.js",
format: "iife"
},
plugins
};
}],
}
}
return [
fromSource('esm'),
fromESM('cjs'),
fromESM('umd'),
{
input: outputFile('cjs'),
output: {
file: outputFile('cjs.min'),
format: 'esm',
},
plugins: [
minify({
mangle: {
toplevel: true,
},
compress: {
global_defs: {
'@process.env.NODE_ENV': JSON.stringify('production'),
},
},
}),
],
},
];
}
const uglifyESMPlugin = () => {
return terser();
};