2019-01-26 18:50:35 +01:00
import fs from 'fs' ;
2017-11-23 14:45:22 +01:00
import replace from 'rollup-plugin-replace' ;
2017-08-20 17:56:21 +02:00
import resolve from 'rollup-plugin-node-resolve' ;
2017-06-25 00:58:21 +02:00
import commonjs from 'rollup-plugin-commonjs' ;
import json from 'rollup-plugin-json' ;
2019-01-26 18:50:35 +01:00
import sucrase from 'rollup-plugin-sucrase' ;
2017-06-25 00:58:21 +02:00
import typescript from 'rollup-plugin-typescript' ;
2017-11-23 14:45:22 +01:00
import pkg from './package.json' ;
2017-06-25 00:58:21 +02:00
2019-01-26 18:50:35 +01:00
const is _publish = ! ! process . env . PUBLISH ;
2017-06-25 00:58:21 +02:00
export default [
2019-01-26 18:50:35 +01:00
/* internal.[m]js */
{
input : ` src/internal/index.js ` ,
output : [
{
file : ` internal.mjs ` ,
format : 'esm' ,
paths : id => id . startsWith ( 'svelte/' ) && id . replace ( 'svelte' , '.' )
} ,
{
file : ` internal.js ` ,
format : 'cjs' ,
paths : id => id . startsWith ( 'svelte/' ) && id . replace ( 'svelte' , '.' )
}
] ,
external : id => id . startsWith ( 'svelte/' ) ,
plugins : [ {
generateBundle ( options , bundle ) {
const mod = bundle [ 'internal.mjs' ] ;
if ( mod ) {
fs . writeFileSync ( 'src/compile/internal-exports.ts' , ` // This file is automatically generated \n export default new Set( ${ JSON . stringify ( mod . exports ) } ); ` ) ;
}
}
} ]
} ,
2018-12-22 06:42:44 +01:00
/* compiler.js */
2017-06-25 00:58:21 +02:00
{
2017-08-20 17:09:05 +02:00
input : 'src/index.ts' ,
2017-06-25 00:58:21 +02:00
plugins : [
2017-11-23 14:45:22 +01:00
replace ( {
_ _VERSION _ _ : pkg . version
} ) ,
2019-01-27 02:52:56 +01:00
resolve ( ) ,
2019-01-26 18:50:35 +01:00
commonjs ( {
include : [ 'node_modules/**' ]
} ) ,
2017-06-25 00:58:21 +02:00
json ( ) ,
2019-01-26 18:50:35 +01:00
is _publish
? typescript ( {
include : 'src/**' ,
exclude : 'src/internal/**' ,
typescript : require ( 'typescript' )
} )
: sucrase ( {
transforms : [ 'typescript' ]
} )
2017-06-25 00:58:21 +02:00
] ,
2017-08-20 17:09:05 +02:00
output : {
2018-12-16 01:18:03 +01:00
file : 'compiler.js' ,
2019-01-26 18:50:35 +01:00
format : is _publish ? 'umd' : 'cjs' ,
2017-08-20 17:09:05 +02:00
name : 'svelte' ,
2019-01-26 18:50:35 +01:00
sourcemap : true ,
} ,
external : is _publish
? [ ]
: id => id === 'acorn' || id === 'magic-string' || id . startsWith ( 'css-tree' )
2017-06-25 00:58:21 +02:00
} ,
2019-01-26 18:50:35 +01:00
/* motion.mjs */
{
input : ` src/motion/index.js ` ,
2018-12-22 06:42:44 +01:00
output : [
{
2019-01-26 18:50:35 +01:00
file : ` motion.mjs ` ,
2019-01-01 22:54:50 +01:00
format : 'esm' ,
paths : id => id . startsWith ( 'svelte/' ) && id . replace ( 'svelte' , '.' )
2018-12-22 06:42:44 +01:00
} ,
{
2019-01-26 18:50:35 +01:00
file : ` motion.js ` ,
2019-01-01 22:54:50 +01:00
format : 'cjs' ,
paths : id => id . startsWith ( 'svelte/' ) && id . replace ( 'svelte' , '.' )
2018-12-22 06:42:44 +01:00
}
2019-01-01 22:54:50 +01:00
] ,
external : id => id . startsWith ( 'svelte/' )
2019-01-26 18:50:35 +01:00
} ,
2018-12-22 06:42:44 +01:00
2019-01-01 22:54:50 +01:00
// everything else
2019-03-17 20:53:40 +01:00
... [ 'index' , 'store' , 'easing' , 'transition' , 'animate' ] . map ( name => ( {
2018-12-23 22:51:50 +01:00
input : ` ${ name } .mjs ` ,
2017-08-20 17:09:05 +02:00
output : {
2018-12-23 22:51:50 +01:00
file : ` ${ name } .js ` ,
2019-01-01 22:54:50 +01:00
format : 'cjs' ,
paths : id => id . startsWith ( 'svelte/' ) && id . replace ( 'svelte' , '.' )
2018-12-22 06:42:44 +01:00
} ,
2018-12-23 22:51:50 +01:00
external : id => id !== ` ${ name } .mjs `
} ) )
2017-06-25 00:58:21 +02:00
] ;