forked from sveltejs/svelte
-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.js
50 lines (46 loc) · 1.36 KB
/
rollup.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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: []
}
];