forked from sveltejs/svelte
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
74 lines (70 loc) · 1.65 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import path from 'path';
import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import json from 'rollup-plugin-json';
import typescript from 'rollup-plugin-typescript';
import buble from 'rollup-plugin-buble';
const src = path.resolve('src');
export default [
/* compiler/svelte.js */
{
entry: 'src/index.ts',
dest: 'compiler/svelte.js',
format: 'umd',
moduleName: 'svelte',
plugins: [
{
resolveId(importee, importer) {
// bit of a hack — TypeScript only really works if it can resolve imports,
// but they misguidedly chose to reject imports with file extensions. This
// means we need to resolve them here
if (
importer &&
importer.startsWith(src) &&
importee[0] === '.' &&
path.extname(importee) === ''
) {
return path.resolve(path.dirname(importer), `${importee}.ts`);
}
}
},
nodeResolve({ jsnext: true, module: true }),
commonjs(),
json(),
typescript({
include: 'src/**',
exclude: 'src/shared/**',
typescript: require('typescript')
})
],
sourceMap: true
},
/* ssr/register.js */
{
entry: 'src/server-side-rendering/register.js',
dest: 'ssr/register.js',
format: 'cjs',
plugins: [
nodeResolve({ jsnext: true, module: true }),
commonjs(),
buble({
include: 'src/**',
exclude: 'src/shared/**',
target: {
node: 4
}
})
],
external: [path.resolve('src/index.ts'), 'fs', 'path'],
paths: {
[path.resolve('src/index.ts')]: '../compiler/svelte.js'
},
sourceMap: true
},
/* shared.js */
{
entry: 'src/shared/index.js',
dest: 'shared.js',
format: 'es'
}
];