combine rollup configs

pull/672/head
Rich Harris 7 years ago
parent 9b4550d2e8
commit 8012542cc4

@ -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",

@ -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'
}
];

@ -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
};

@ -1,5 +0,0 @@
export default {
entry: 'src/shared/index.js',
dest: 'shared.js',
format: 'es'
};

@ -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
};

@ -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"

Loading…
Cancel
Save