From 8012542cc44eaab903abcb74cb8669266ab5983c Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 24 Jun 2017 18:58:21 -0400 Subject: [PATCH] combine rollup configs --- package.json | 10 ++--- rollup.config.js | 74 ++++++++++++++++++++++++++++++++++ rollup/rollup.config.main.js | 39 ------------------ rollup/rollup.config.shared.js | 5 --- rollup/rollup.config.ssr.js | 26 ------------ yarn.lock | 6 +-- 6 files changed, 80 insertions(+), 80 deletions(-) create mode 100644 rollup.config.js delete mode 100644 rollup/rollup.config.main.js delete mode 100644 rollup/rollup.config.shared.js delete mode 100644 rollup/rollup.config.ssr.js diff --git a/package.json b/package.json index eca368922c..0db01e2b4d 100644 --- a/package.json +++ b/package.json @@ -16,12 +16,8 @@ "codecov": "codecov", "precodecov": "npm run coverage", "lint": "eslint src test/*.js", - "build": "npm run build:main && npm run build:shared && npm run build:ssr", - "build:main": "node src/shared/_build.js && rollup -c rollup/rollup.config.main.js", - "build:shared": "rollup -c rollup/rollup.config.shared.js", - "build:ssr": "rollup -c rollup/rollup.config.ssr.js", - "dev": "node src/shared/_build.js && rollup -c rollup/rollup.config.main.js -w", - "dev:shared": "rollup -c rollup/rollup.config.shared.js -w", + "build": "node src/shared/_build.js && rollup -c", + "dev": "node src/shared/_build.js && rollup -c -w", "pretest": "npm run build", "prepublish": "npm run build && npm run lint", "prettier": "prettier --use-tabs --single-quote --trailing-comma es5 --write \"src/**/*.ts\"" @@ -75,7 +71,7 @@ "nyc": "^10.0.0", "prettier": "^1.4.1", "reify": "^0.4.4", - "rollup": "^0.39.0", + "rollup": "^0.43.0", "rollup-plugin-buble": "^0.15.0", "rollup-plugin-commonjs": "^7.0.0", "rollup-plugin-json": "^2.1.0", diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000000..fe2a98494d --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,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' + } +]; diff --git a/rollup/rollup.config.main.js b/rollup/rollup.config.main.js deleted file mode 100644 index c9ab0f7394..0000000000 --- a/rollup/rollup.config.main.js +++ /dev/null @@ -1,39 +0,0 @@ -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'; - -const src = path.resolve('src'); - -export default { - entry: 'src/index.ts', - moduleName: 'svelte', - targets: [{ dest: 'compiler/svelte.js', format: 'umd' }], - 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 -}; diff --git a/rollup/rollup.config.shared.js b/rollup/rollup.config.shared.js deleted file mode 100644 index 1dda31ee6b..0000000000 --- a/rollup/rollup.config.shared.js +++ /dev/null @@ -1,5 +0,0 @@ -export default { - entry: 'src/shared/index.js', - dest: 'shared.js', - format: 'es' -}; diff --git a/rollup/rollup.config.ssr.js b/rollup/rollup.config.ssr.js deleted file mode 100644 index 6f9e9f6fe6..0000000000 --- a/rollup/rollup.config.ssr.js +++ /dev/null @@ -1,26 +0,0 @@ -import * as path from 'path'; -import nodeResolve from 'rollup-plugin-node-resolve'; -import commonjs from 'rollup-plugin-commonjs'; -import buble from 'rollup-plugin-buble'; - -export default { - entry: 'src/server-side-rendering/register.js', - moduleName: 'svelte', - targets: [{ 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 -}; diff --git a/yarn.lock b/yarn.lock index 682deff103..a3b9fbe5a4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2578,9 +2578,9 @@ rollup-watch@^3.2.2: dependencies: require-relative "0.8.7" -rollup@^0.39.0: - version "0.39.2" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-0.39.2.tgz#858cf3020027cf74e0c5d7faa1c18275faf00df4" +rollup@^0.43.0: + version "0.43.0" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-0.43.0.tgz#b36bdb75fa5e0823b6de8aee18ff7b5655520543" dependencies: source-map-support "^0.4.0"