From 82c247ea3e3ef06fad5c62eebf469d5d1e65433a Mon Sep 17 00:00:00 2001 From: Conduitry Date: Sat, 22 Dec 2018 00:42:44 -0500 Subject: [PATCH] expose ESM and CJS versions of runtime code (#1886) --- .gitignore | 9 ++++----- index.js => index.mjs | 2 +- package.json | 7 ++++--- rollup.config.js | 40 ++++++++++++++++++++++++++++++++-------- store.js => store.mjs | 2 +- 5 files changed, 42 insertions(+), 18 deletions(-) rename index.js => index.mjs (77%) rename store.js => store.mjs (97%) diff --git a/.gitignore b/.gitignore index 930c8dc863..dbed468f15 100644 --- a/.gitignore +++ b/.gitignore @@ -3,10 +3,10 @@ node_modules *.map /cli/ -/compiler/ -/ssr/ -/internal.js /compiler.js +/index.js +/internal.* +/store.js /scratch/ /coverage/ /coverage.lcov/ @@ -15,7 +15,6 @@ node_modules /test/sourcemaps/samples/*/output.js.map /test/sourcemaps/samples/*/output.css /test/sourcemaps/samples/*/output.css.map -/store.umd.js /yarn-error.log _actual*.* -_*/ \ No newline at end of file +_*/ diff --git a/index.js b/index.mjs similarity index 77% rename from index.js rename to index.mjs index 9fdeadb8fa..44031c35c8 100644 --- a/index.js +++ b/index.mjs @@ -4,4 +4,4 @@ export { beforeUpdate, afterUpdate, createEventDispatcher -} from './internal.js'; +} from './internal'; diff --git a/package.json b/package.json index 4844644834..f12c429aa9 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "svelte", "version": "3.0.0-alpha6", "description": "The magical disappearing UI framework", + "module": "index.mjs", "main": "index.js", "bin": { "svelte": "svelte" @@ -10,9 +11,9 @@ "cli", "compiler.js", "register.js", - "index.js", - "internal.js", - "store.js", + "index.*", + "internal.*", + "store.*", "svelte", "README.md" ], diff --git a/rollup.config.js b/rollup.config.js index 3229a2800f..1bb01c9282 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,14 +1,12 @@ -import path from 'path'; import replace from 'rollup-plugin-replace'; import resolve 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'; import pkg from './package.json'; export default [ - /* compiler/svelte.js */ + /* compiler.js */ { input: 'src/index.ts', plugins: [ @@ -54,12 +52,38 @@ export default [ experimentalCodeSplitting: true }, - /* internal.js */ + /* index.js */ + { + input: 'index.mjs', + output: { + file: 'index.js', + format: 'cjs' + }, + external: name => name !== 'index.mjs' + }, + + /* internal.[m]js */ { input: 'src/internal/index.js', + output: [ + { + file: 'internal.mjs', + format: 'esm' + }, + { + file: 'internal.js', + format: 'cjs' + } + ] + }, + + /* store.js */ + { + input: 'store.mjs', output: { - file: 'internal.js', - format: 'es' - } - } + file: 'store.js', + format: 'cjs' + }, + external: name => name !== 'store.mjs' + }, ]; diff --git a/store.js b/store.mjs similarity index 97% rename from store.js rename to store.mjs index d22afdedee..ffdd90bf0e 100644 --- a/store.js +++ b/store.mjs @@ -1,4 +1,4 @@ -import { run_all, noop } from './internal.js'; +import { run_all, noop } from './internal'; export function readable(start, value) { const subscribers = [];