From ffd2a62c3f7df94365980302fef3bc3376b48182 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 3 Aug 2020 13:00:48 +0530 Subject: modularize repo, use pnpm, improve typechecking --- .../taler-wallet-webextension/rollup.config.js | 212 +++++++++++++++++++++ 1 file changed, 212 insertions(+) create mode 100644 packages/taler-wallet-webextension/rollup.config.js (limited to 'packages/taler-wallet-webextension/rollup.config.js') diff --git a/packages/taler-wallet-webextension/rollup.config.js b/packages/taler-wallet-webextension/rollup.config.js new file mode 100644 index 000000000..25ce768b4 --- /dev/null +++ b/packages/taler-wallet-webextension/rollup.config.js @@ -0,0 +1,212 @@ +// rollup.config.js +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: "src/headless/taler-wallet-cli.ts", + output: { + file: "dist/standalone/taler-wallet-cli.js", + format: "cjs", + }, + external: builtins, + plugins: [ + nodeResolve({ + preferBuiltins: true, + }), + + commonjs({ + include: ["node_modules/**", "dist/node/**"], + extensions: [".js", ".ts"], + ignoreGlobal: false, // Default: false + sourceMap: false, + ignore: ["taler-wallet"], + }), + + json(), + + typescript({ + tsconfig: false, + ...baseTypescriptCompilerSettings, + sourceMap: false, + }), + ], +}; + +const walletAndroid = { + input: "src/android/index.ts", + output: { + //dir: "dist/standalone", + file: "dist/standalone/taler-wallet-android.js", + format: "cjs", + exports: "named", + }, + external: builtins, + plugins: [ + json(), + + nodeResolve({ + preferBuiltins: true, + }), + + commonjs({ + include: ["node_modules/**"], + extensions: [".js"], + sourceMap: false, + ignore: ["taler-wallet"], + }), + + typescript({ + tsconfig: false, + ...baseTypescriptCompilerSettings, + sourceMap: false, + }), + ], +}; + +const webExtensionPageEntryPoint = { + input: "src/webex/pageEntryPoint.ts", + output: { + file: "dist/webextension/pageEntryPoint.js", + format: "iife", + exports: "none", + name: "webExtensionPageEntry", + }, + external: builtins, + plugins: [ + json(), + + nodeResolve({ + preferBuiltins: true, + }), + + terser(), + + replace({ + "process.env.NODE_ENV": JSON.stringify("production"), + }), + + commonjs({ + include: ["node_modules/**", "dist/node/**"], + extensions: [".js"], + sourceMap: false, + ignore: ["taler-wallet"], + }), + + typescript({ + tsconfig: false, + ...baseTypescriptCompilerSettings, + sourceMap: false, + }), + ], +}; + +const webExtensionBackgroundPageScript = { + input: "src/webex/background.ts", + output: { + file: "dist/webextension/background.js", + format: "iife", + exports: "none", + name: "webExtensionBackgroundScript", + }, + external: builtins, + plugins: [ + json(), + + nodeResolve({ + preferBuiltins: true, + }), + + terser(), + + replace({ + "process.env.NODE_ENV": JSON.stringify("production"), + }), + + commonjs({ + include: ["node_modules/**", "dist/node/**"], + extensions: [".js"], + sourceMap: false, + ignore: ["taler-wallet", "crypto"], + }), + + typescript({ + tsconfig: false, + ...baseTypescriptCompilerSettings, + sourceMap: false, + }), + ], +}; + +const webExtensionCryptoWorker = { + input: "src/crypto/workers/browserWorkerEntry.ts", + output: { + file: "dist/webextension/browserWorkerEntry.js", + format: "iife", + exports: "none", + name: "webExtensionCryptoWorker", + }, + external: builtins, + plugins: [ + json(), + + nodeResolve({ + preferBuiltins: true, + }), + + terser(), + + replace({ + "process.env.NODE_ENV": JSON.stringify("production"), + }), + + commonjs({ + include: ["node_modules/**", "dist/node/**"], + extensions: [".js"], + sourceMap: false, + ignore: ["taler-wallet", "crypto"], + }), + + typescript({ + tsconfig: false, + ...baseTypescriptCompilerSettings, + sourceMap: false, + }), + ], +}; + +export default [ + walletCli, + walletAndroid, + webExtensionPageEntryPoint, + webExtensionBackgroundPageScript, + webExtensionCryptoWorker, +]; -- cgit v1.2.3