MCPcopy Create free account
hub / github.com/react-hook-form/react-hook-form / createRollupConfig

Function createRollupConfig

scripts/rollup/createRollupConfig.js:11–53  ·  view source on GitHub ↗
(options, callback)

Source from the content-addressed store, hash-verified

9 * @returns {import("rollup").RollupOptions}
10 */
11export function createRollupConfig(options, callback) {
12 const name = options.name;
13 // A file with the extension ".mjs" will always be treated as ESM, even when pkg.type is "commonjs" (the default)
14 // https://nodejs.org/docs/latest/api/packages.html#packages_determining_module_system
15 const extName = options.format === 'esm' ? 'mjs' : 'js';
16 const outputName = 'dist/' + [name, options.format, extName].join('.');
17
18 const config = {
19 input: options.input,
20 output: {
21 file: outputName,
22 format: options.format,
23 name: 'ReactHookForm',
24 sourcemap: true,
25 globals: { react: 'React' },
26 exports: 'named',
27 },
28 external: Object.keys(pkg.peerDependencies),
29 plugins: [
30 typescript({
31 clean: true,
32 }),
33 options.format === 'umd' &&
34 commonjs({
35 include: /\/node_modules\//,
36 }),
37 options.format !== 'esm' &&
38 terser({
39 output: { comments: false },
40 compress: {
41 drop_console: true,
42 passes: 2,
43 unsafe: false,
44 unsafe_comps: false,
45 unsafe_math: false,
46 pure_funcs: ['console.log', 'console.info', 'console.debug'],
47 },
48 }),
49 ].filter(Boolean),
50 };
51
52 return callback ? callback(config) : config;
53}

Callers 2

rollup.config.jsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected