You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/packages/svelte/rollup.config.js

51 lines
1.4 KiB

import fs from 'node:fs';
import { createRequire } from 'node:module';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
// runs the version generation as a side-effect of importing
import './scripts/generate-version.js';
const require = createRequire(import.meta.url);
const internal = await import('./src/runtime/internal/index.js');
fs.writeFileSync(
'src/compiler/compile/internal_exports.js',
`// This file is automatically generated\n` +
`export default new Set(${JSON.stringify(Object.keys(internal))});`
);
/**
* @type {import("rollup").RollupOptions[]}
*/
export default [
// Generate UMD build of the compiler so that Eslint/Prettier (which need CJS) and REPL (which needs UMD because browser) can use it
{
input: 'src/compiler/index.js',
plugins: [
{
resolveId(id) {
// Must import from the `css-tree` browser bundled distribution due to `createRequire` usage if importing from css-tree directly
if (id === 'css-tree') {
return require.resolve('./node_modules/css-tree/dist/csstree.esm.js');
}
}
},
resolve(),
commonjs({
include: ['../../node_modules/**', 'node_modules/**']
}),
json()
],
output: {
file: 'compiler.cjs',
format: 'umd',
name: 'svelte',
sourcemap: false,
indent: false
},
external: []
}
];