Skip to content

Commit 82c247e

Browse files
committed
expose ESM and CJS versions of runtime code (#1886)
1 parent b40c153 commit 82c247e

File tree

5 files changed

+42
-18
lines changed

5 files changed

+42
-18
lines changed

Diff for: .gitignore

+4-5
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
node_modules
44
*.map
55
/cli/
6-
/compiler/
7-
/ssr/
8-
/internal.js
96
/compiler.js
7+
/index.js
8+
/internal.*
9+
/store.js
1010
/scratch/
1111
/coverage/
1212
/coverage.lcov/
@@ -15,7 +15,6 @@ node_modules
1515
/test/sourcemaps/samples/*/output.js.map
1616
/test/sourcemaps/samples/*/output.css
1717
/test/sourcemaps/samples/*/output.css.map
18-
/store.umd.js
1918
/yarn-error.log
2019
_actual*.*
21-
_*/
20+
_*/

Diff for: index.js renamed to index.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ export {
44
beforeUpdate,
55
afterUpdate,
66
createEventDispatcher
7-
} from './internal.js';
7+
} from './internal';

Diff for: package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "svelte",
33
"version": "3.0.0-alpha6",
44
"description": "The magical disappearing UI framework",
5+
"module": "index.mjs",
56
"main": "index.js",
67
"bin": {
78
"svelte": "svelte"
@@ -10,9 +11,9 @@
1011
"cli",
1112
"compiler.js",
1213
"register.js",
13-
"index.js",
14-
"internal.js",
15-
"store.js",
14+
"index.*",
15+
"internal.*",
16+
"store.*",
1617
"svelte",
1718
"README.md"
1819
],

Diff for: rollup.config.js

+32-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
import path from 'path';
21
import replace from 'rollup-plugin-replace';
32
import resolve from 'rollup-plugin-node-resolve';
43
import commonjs from 'rollup-plugin-commonjs';
54
import json from 'rollup-plugin-json';
65
import typescript from 'rollup-plugin-typescript';
7-
import buble from 'rollup-plugin-buble';
86
import pkg from './package.json';
97

108
export default [
11-
/* compiler/svelte.js */
9+
/* compiler.js */
1210
{
1311
input: 'src/index.ts',
1412
plugins: [
@@ -54,12 +52,38 @@ export default [
5452
experimentalCodeSplitting: true
5553
},
5654

57-
/* internal.js */
55+
/* index.js */
56+
{
57+
input: 'index.mjs',
58+
output: {
59+
file: 'index.js',
60+
format: 'cjs'
61+
},
62+
external: name => name !== 'index.mjs'
63+
},
64+
65+
/* internal.[m]js */
5866
{
5967
input: 'src/internal/index.js',
68+
output: [
69+
{
70+
file: 'internal.mjs',
71+
format: 'esm'
72+
},
73+
{
74+
file: 'internal.js',
75+
format: 'cjs'
76+
}
77+
]
78+
},
79+
80+
/* store.js */
81+
{
82+
input: 'store.mjs',
6083
output: {
61-
file: 'internal.js',
62-
format: 'es'
63-
}
64-
}
84+
file: 'store.js',
85+
format: 'cjs'
86+
},
87+
external: name => name !== 'store.mjs'
88+
},
6589
];

Diff for: store.js renamed to store.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { run_all, noop } from './internal.js';
1+
import { run_all, noop } from './internal';
22

33
export function readable(start, value) {
44
const subscribers = [];

0 commit comments

Comments
 (0)