11import svelte from "rollup-plugin-svelte"
22import resolve from "rollup-plugin-node-resolve"
3- import babel from "rollup-plugin-babel"
4- import commonjs from "rollup-plugin-commonjs"
5- import globals from "rollup-plugin-node-globals"
63import json from "rollup-plugin-json"
74import image from "rollup-plugin-img"
5+ import commonjs from "rollup-plugin-commonjs"
6+ import globals from "rollup-plugin-node-globals"
87import builtins from "@joseph184/rollup-plugin-node-builtins"
98import { terser } from "rollup-plugin-terser"
9+ import typescript from "rollup-plugin-typescript2"
10+
11+ import {
12+ preprocess ,
13+ createEnv ,
14+ readConfigFile
15+ } from "@pyoner/svelte-ts-preprocess"
16+
17+ const env = createEnv ( )
18+ const compilerOptions = readConfigFile ( env )
19+ const opts = {
20+ env,
21+ compilerOptions : {
22+ ...compilerOptions ,
23+ allowNonTsExtensions : true
24+ }
25+ }
1026
1127export default [
1228 {
13- input : "src/index.js " ,
29+ input : "src/onboard.ts " ,
1430 output : {
15- format : "iife" ,
31+ sourcemap : true ,
32+ format : "umd" ,
1633 name : "onboard" ,
17- file : "dist/iife/onboard.js" ,
18- esModule : false
34+ file : "dist/bnc-onboard.js"
35+ } ,
36+ moduleContext : id => {
37+ const thisAsWindowForModules = [
38+ "node_modules/intl-messageformat/lib/core.js" ,
39+ "node_modules/intl-messageformat/lib/compiler.js"
40+ ]
41+
42+ if ( thisAsWindowForModules . some ( id_ => id . trimRight ( ) . endsWith ( id_ ) ) ) {
43+ return "window"
44+ }
1945 } ,
2046 plugins : [
2147 image ( ) ,
2248 json ( ) ,
23- svelte ( ) ,
49+ svelte ( {
50+ preprocess : preprocess ( opts )
51+ } ) ,
2452 resolve ( {
25- preferBuiltins : true ,
2653 browser : true ,
54+ preferBuiltins : true ,
2755 dedupe : importee =>
2856 importee === "svelte" || importee . startsWith ( "svelte/" )
2957 } ) ,
3058 commonjs ( ) ,
3159 globals ( ) ,
32- babel ( { exclude : "node_modules/**" } ) ,
3360 builtins ( ) ,
61+ typescript ( ) ,
3462 terser ( )
35- ] ,
63+ ]
64+ } ,
65+ {
66+ input : "src/onboard.ts" ,
67+ output : {
68+ sourcemap : true ,
69+ format : "es" ,
70+ file : "dist/bnc-onboard.es5.js"
71+ } ,
3672 moduleContext : id => {
3773 const thisAsWindowForModules = [
3874 "node_modules/intl-messageformat/lib/core.js" ,
@@ -42,49 +78,31 @@ export default [
4278 if ( thisAsWindowForModules . some ( id_ => id . trimRight ( ) . endsWith ( id_ ) ) ) {
4379 return "window"
4480 }
45- }
46- } ,
47- {
48- input : "src/index.js" ,
81+ } ,
82+ plugins : [
83+ json ( ) ,
84+ image ( ) ,
85+ svelte ( {
86+ preprocess : preprocess ( opts )
87+ } ) ,
88+ resolve ( {
89+ browser : true ,
90+ dedupe : importee =>
91+ importee === "svelte" || importee . startsWith ( "svelte/" )
92+ } ) ,
93+ commonjs ( ) ,
94+ typescript ( )
95+ ] ,
4996 external : [
5097 "bowser" ,
5198 "bnc-sdk" ,
5299 "bignumber.js" ,
53100 "promise-cancelable" ,
54- "regenerator-runtime/runtime" ,
55101 "@portis/web3" ,
56102 "@walletconnect/web3-provider" ,
57103 "fortmatic" ,
58104 "squarelink" ,
59105 "authereum"
60- ] ,
61- plugins : [
62- svelte ( ) ,
63- json ( ) ,
64- image ( ) ,
65- resolve ( ) ,
66- commonjs ( ) ,
67- babel ( { exclude : "node_modules/**" } )
68- ] ,
69- moduleContext : id => {
70- const thisAsWindowForModules = [
71- "node_modules/intl-messageformat/lib/core.js" ,
72- "node_modules/intl-messageformat/lib/compiler.js"
73- ]
74-
75- if ( thisAsWindowForModules . some ( id_ => id . trimRight ( ) . endsWith ( id_ ) ) ) {
76- return "window"
77- }
78- } ,
79- output : [
80- {
81- dir : "dist/esm" ,
82- format : "esm"
83- } ,
84- {
85- dir : "dist/cjs" ,
86- format : "cjs"
87- }
88106 ]
89107 }
90108]
0 commit comments