@ -9,7 +9,7 @@ import pkg from './package.json';
const is _publish = ! ! process . env . PUBLISH ;
const ts P lugin = is _publish
const ts _p lugin = is _publish
? typescript ( {
include : 'src/**' ,
typescript : require ( 'typescript' )
@ -18,39 +18,61 @@ const tsPlugin = is_publish
transforms : [ 'typescript' ]
} ) ;
const external = id => id . startsWith ( 'svelte/' ) ;
export default [
/* internal.[m]js */
/* runtime */
{
input : ` src/ internal /index.ts` ,
input : ` src/ runtime /index.ts` ,
output : [
{
file : ` in ternal .mjs` ,
file : ` in dex .mjs` ,
format : 'esm' ,
paths : id => id . startsWith ( 'svelte/' ) && id . replace ( 'svelte' , '.' )
paths : id => id . startsWith ( 'svelte/' ) && ` ${ id . replace ( 'svelte' , '.' ) } `
} ,
{
file : ` in ternal .js` ,
file : ` in dex .js` ,
format : 'cjs' ,
paths : id => id . startsWith ( 'svelte/' ) && id . replace ( 'svelte' , '.' )
paths : id => id . startsWith ( 'svelte/' ) && ` ${ id . replace ( 'svelte' , '.' ) } `
}
] ,
external : id => id . startsWith ( 'svelte/' ) ,
external ,
plugins : [ ts _plugin ]
} ,
plugins : [
tsPlugin ,
{
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 ) } ); ` ) ;
... fs . readdirSync ( 'src/runtime' )
. filter ( dir => fs . statSync ( ` src/runtime/ ${ dir } ` ) . isDirectory ( ) )
. map ( dir => ( {
input : ` src/runtime/ ${ dir } /index.ts ` ,
output : [
{
file : ` ${ dir } /index.mjs ` ,
format : 'esm' ,
paths : id => id . startsWith ( 'svelte/' ) && ` ${ id . replace ( 'svelte' , '..' ) } `
} ,
{
file : ` ${ dir } /index.js ` ,
format : 'cjs' ,
paths : id => id . startsWith ( 'svelte/' ) && ` ${ id . replace ( 'svelte' , '..' ) } `
}
] ,
external ,
plugins : [
ts _plugin ,
dir === 'internal' && {
generateBundle ( options , bundle ) {
const mod = bundle [ 'index.mjs' ] ;
if ( mod ) {
fs . writeFileSync ( 'src/compiler/compile/internal-exports.ts' , ` // This file is automatically generated \n export default new Set( ${ JSON . stringify ( mod . exports ) } ); ` ) ;
}
}
}
} ]
} ,
]
} ) ) ,
/* compiler.js */
{
input : 'src/compiler.ts' ,
input : 'src/compiler /index .ts',
plugins : [
replace ( {
_ _VERSION _ _ : pkg . version
@ -60,7 +82,7 @@ export default [
include : [ 'node_modules/**' ]
} ) ,
json ( ) ,
ts P lugin
ts _p lugin
] ,
output : {
file : 'compiler.js' ,
@ -71,47 +93,5 @@ export default [
external : is _publish
? [ ]
: id => id === 'acorn' || id === 'magic-string' || id . startsWith ( 'css-tree' )
} ,
/* motion.mjs */
{
input : ` src/motion/index.ts ` ,
output : [
{
file : ` motion.mjs ` ,
format : 'esm' ,
paths : id => id . startsWith ( 'svelte/' ) && id . replace ( 'svelte' , '.' )
} ,
{
file : ` motion.js ` ,
format : 'cjs' ,
paths : id => id . startsWith ( 'svelte/' ) && id . replace ( 'svelte' , '.' )
}
] ,
plugins : [
tsPlugin
] ,
external : id => id . startsWith ( 'svelte/' )
} ,
// everything else
... [ 'index' , 'easing' , 'transition' , 'animate' , 'store' ] . map ( name => ( {
input : ` src/ ${ name } .ts ` ,
output : [
{
file : ` ${ name } .mjs ` ,
format : 'esm' ,
paths : id => id . startsWith ( 'svelte/' ) && id . replace ( 'svelte' , '.' )
} ,
{
file : ` ${ name } .js ` ,
format : 'cjs' ,
paths : id => id . startsWith ( 'svelte/' ) && id . replace ( 'svelte' , '.' )
}
] ,
plugins : [
tsPlugin
] ,
external : id => id . startsWith ( 'svelte/' )
} ) )
}
] ;