From 9f5e61057e1cf07e8aeb8d10fa8f5d1002d841ab Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Fri, 17 Jul 2020 18:00:34 +0530 Subject: upgrade rollup; bundle TS directly This also resolves a problem where symbols weren't exported correctly for the Android wallet-core bundle --- rollup.config.js | 83 ++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 68 insertions(+), 15 deletions(-) (limited to 'rollup.config.js') diff --git a/rollup.config.js b/rollup.config.js index 71748a864..25ce768b4 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,13 +1,38 @@ // rollup.config.js -import commonjs from "rollup-plugin-commonjs"; -import nodeResolve from "rollup-plugin-node-resolve"; +import commonjs from "@rollup/plugin-commonjs"; +import nodeResolve from "@rollup/plugin-node-resolve"; import json from "@rollup/plugin-json"; import replace from "@rollup/plugin-replace"; import builtins from "builtin-modules"; import { terser } from "rollup-plugin-terser"; +import typescript from "@rollup/plugin-typescript"; + +// Base settings to use +const baseTypescriptCompilerSettings = { + target: "ES6", + jsx: "react", + reactNamespace: "React", + moduleResolution: "node", + sourceMap: true, + lib: ["es6", "dom"], + noImplicitReturns: true, + noFallthroughCasesInSwitch: true, + strict: true, + strictPropertyInitialization: false, + noImplicitAny: true, + noImplicitThis: true, + allowJs: true, + checkJs: true, + incremental: false, + esModuleInterop: true, + importHelpers: true, + module: "ESNext", + include: ["src/**/*.+(ts|tsx)"], + rootDir: "./src", +}; const walletCli = { - input: "dist/node/headless/taler-wallet-cli.js", + input: "src/headless/taler-wallet-cli.ts", output: { file: "dist/standalone/taler-wallet-cli.js", format: "cjs", @@ -25,13 +50,21 @@ const walletCli = { sourceMap: false, ignore: ["taler-wallet"], }), + json(), + + typescript({ + tsconfig: false, + ...baseTypescriptCompilerSettings, + sourceMap: false, + }), ], }; const walletAndroid = { - input: "dist/node/android/index.js", + input: "src/android/index.ts", output: { + //dir: "dist/standalone", file: "dist/standalone/taler-wallet-android.js", format: "cjs", exports: "named", @@ -45,21 +78,26 @@ const walletAndroid = { }), commonjs({ - include: ["node_modules/**", "dist/node/**"], + include: ["node_modules/**"], extensions: [".js"], - ignoreGlobal: false, // Default: false sourceMap: false, ignore: ["taler-wallet"], }), + + typescript({ + tsconfig: false, + ...baseTypescriptCompilerSettings, + sourceMap: false, + }), ], }; const webExtensionPageEntryPoint = { - input: "dist/node/webex/pageEntryPoint.js", + input: "src/webex/pageEntryPoint.ts", output: { file: "dist/webextension/pageEntryPoint.js", format: "iife", - exports: "default", + exports: "none", name: "webExtensionPageEntry", }, external: builtins, @@ -79,19 +117,24 @@ const webExtensionPageEntryPoint = { commonjs({ include: ["node_modules/**", "dist/node/**"], extensions: [".js"], - ignoreGlobal: false, // Default: false sourceMap: false, ignore: ["taler-wallet"], }), + + typescript({ + tsconfig: false, + ...baseTypescriptCompilerSettings, + sourceMap: false, + }), ], }; const webExtensionBackgroundPageScript = { - input: "dist/node/webex/background.js", + input: "src/webex/background.ts", output: { file: "dist/webextension/background.js", format: "iife", - exports: "default", + exports: "none", name: "webExtensionBackgroundScript", }, external: builtins, @@ -111,19 +154,24 @@ const webExtensionBackgroundPageScript = { commonjs({ include: ["node_modules/**", "dist/node/**"], extensions: [".js"], - ignoreGlobal: false, // Default: false sourceMap: false, ignore: ["taler-wallet", "crypto"], }), + + typescript({ + tsconfig: false, + ...baseTypescriptCompilerSettings, + sourceMap: false, + }), ], }; const webExtensionCryptoWorker = { - input: "dist/node/crypto/workers/browserWorkerEntry.js", + input: "src/crypto/workers/browserWorkerEntry.ts", output: { file: "dist/webextension/browserWorkerEntry.js", format: "iife", - exports: "default", + exports: "none", name: "webExtensionCryptoWorker", }, external: builtins, @@ -143,10 +191,15 @@ const webExtensionCryptoWorker = { commonjs({ include: ["node_modules/**", "dist/node/**"], extensions: [".js"], - ignoreGlobal: false, // Default: false sourceMap: false, ignore: ["taler-wallet", "crypto"], }), + + typescript({ + tsconfig: false, + ...baseTypescriptCompilerSettings, + sourceMap: false, + }), ], }; -- cgit v1.2.3