upgrade rollup; bundle TS directly

This also resolves a problem where symbols weren't exported correctly for the Android wallet-core bundle
This commit is contained in:
Florian Dold 2020-07-17 18:00:34 +05:30
parent 50550da3c2
commit 9f5e61057e
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
5 changed files with 877 additions and 1083 deletions

View File

@ -22,6 +22,7 @@ module.exports = {
"@typescript-eslint/camelcase": "off", "@typescript-eslint/camelcase": "off",
"@typescript-eslint/ban-ts-ignore": "off", "@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-unused-vars": ["warn", { args: "none" }], "@typescript-eslint/no-unused-vars": ["warn", { args: "none" }],
"@typescript-eslint/explicit-function-return-type": [ "@typescript-eslint/explicit-function-return-type": [
"warn", "warn",

View File

@ -82,7 +82,7 @@ install: tsc
endif endif
.PHONY: rollup .PHONY: rollup
rollup: tsc rollup: yarn-install
./node_modules/.bin/rollup -c ./node_modules/.bin/rollup -c
.PHONY: lint .PHONY: lint

View File

@ -5,7 +5,6 @@
"engines": { "engines": {
"node": ">=0.12.0" "node": ">=0.12.0"
}, },
"main": "dist/node/index.js",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git://git.taler.net/wallet-core.git" "url": "git://git.taler.net/wallet-core.git"
@ -31,41 +30,43 @@
], ],
"devDependencies": { "devDependencies": {
"@ava/typescript": "^1.1.1", "@ava/typescript": "^1.1.1",
"@rollup/plugin-json": "^4.0.2", "@rollup/plugin-commonjs": "^14.0.0",
"@rollup/plugin-replace": "^2.3.1", "@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^8.4.0",
"@rollup/plugin-replace": "^2.3.3",
"@rollup/plugin-typescript": "^5.0.2",
"@types/chrome": "^0.0.103", "@types/chrome": "^0.0.103",
"@types/enzyme": "^3.10.5", "@types/enzyme": "^3.10.5",
"@types/enzyme-adapter-react-16": "^1.0.6", "@types/enzyme-adapter-react-16": "^1.0.6",
"@types/node": "^14.0.23",
"@types/react": "^16.9.6", "@types/react": "^16.9.6",
"@types/react-dom": "^16.9.6", "@types/react-dom": "^16.9.6",
"@typescript-eslint/eslint-plugin": "^2.27.0", "@typescript-eslint/eslint-plugin": "^3.6.1",
"@typescript-eslint/parser": "^2.27.0", "@typescript-eslint/parser": "^3.6.1",
"ava": "^3.8.2", "ava": "^3.10.1",
"enzyme": "^3.11.0", "enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2", "enzyme-adapter-react-16": "^1.15.2",
"eslint": "^6.8.0", "eslint": "^7.4.0",
"eslint-config-airbnb-typescript": "^8.0.0", "eslint-config-airbnb-typescript": "^8.0.2",
"eslint-plugin-import": "^2.20.2", "eslint-plugin-import": "^2.22.0",
"eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-react": "^7.20.0", "eslint-plugin-react": "^7.20.3",
"eslint-plugin-react-hooks": "^4.0.4", "eslint-plugin-react-hooks": "^4.0.8",
"jed": "^1.1.1", "jed": "^1.1.1",
"moment": "^2.26.0", "moment": "^2.27.0",
"nyc": "^15.1.0", "nyc": "^15.1.0",
"po2json": "^0.4.5", "po2json": "^0.4.5",
"pogen": "^0.0.5", "pogen": "^0.0.5",
"prettier": "^2.0.5", "prettier": "^2.0.5",
"react": "^16.13.1", "react": "^16.13.1",
"react-dom": "^16.13.1", "react-dom": "^16.13.1",
"rollup": "^2.12.1", "rollup": "^2.21.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-sourcemaps": "^0.6.2", "rollup-plugin-sourcemaps": "^0.6.2",
"rollup-plugin-terser": "^6.1.0", "rollup-plugin-terser": "^6.1.0",
"source-map-resolve": "^0.6.0", "source-map-resolve": "^0.6.0",
"structured-clone": "^0.2.2", "structured-clone": "^0.2.2",
"typedoc": "^0.17.7", "typedoc": "^0.17.8",
"typescript": "^3.9.3" "typescript": "^3.9.7"
}, },
"dependencies": { "dependencies": {
"axios": "^0.19.2", "axios": "^0.19.2",

View File

@ -1,13 +1,38 @@
// rollup.config.js // rollup.config.js
import commonjs from "rollup-plugin-commonjs"; import commonjs from "@rollup/plugin-commonjs";
import nodeResolve from "rollup-plugin-node-resolve"; import nodeResolve from "@rollup/plugin-node-resolve";
import json from "@rollup/plugin-json"; import json from "@rollup/plugin-json";
import replace from "@rollup/plugin-replace"; import replace from "@rollup/plugin-replace";
import builtins from "builtin-modules"; import builtins from "builtin-modules";
import { terser } from "rollup-plugin-terser"; 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 = { const walletCli = {
input: "dist/node/headless/taler-wallet-cli.js", input: "src/headless/taler-wallet-cli.ts",
output: { output: {
file: "dist/standalone/taler-wallet-cli.js", file: "dist/standalone/taler-wallet-cli.js",
format: "cjs", format: "cjs",
@ -25,13 +50,21 @@ const walletCli = {
sourceMap: false, sourceMap: false,
ignore: ["taler-wallet"], ignore: ["taler-wallet"],
}), }),
json(), json(),
typescript({
tsconfig: false,
...baseTypescriptCompilerSettings,
sourceMap: false,
}),
], ],
}; };
const walletAndroid = { const walletAndroid = {
input: "dist/node/android/index.js", input: "src/android/index.ts",
output: { output: {
//dir: "dist/standalone",
file: "dist/standalone/taler-wallet-android.js", file: "dist/standalone/taler-wallet-android.js",
format: "cjs", format: "cjs",
exports: "named", exports: "named",
@ -45,21 +78,26 @@ const walletAndroid = {
}), }),
commonjs({ commonjs({
include: ["node_modules/**", "dist/node/**"], include: ["node_modules/**"],
extensions: [".js"], extensions: [".js"],
ignoreGlobal: false, // Default: false
sourceMap: false, sourceMap: false,
ignore: ["taler-wallet"], ignore: ["taler-wallet"],
}), }),
typescript({
tsconfig: false,
...baseTypescriptCompilerSettings,
sourceMap: false,
}),
], ],
}; };
const webExtensionPageEntryPoint = { const webExtensionPageEntryPoint = {
input: "dist/node/webex/pageEntryPoint.js", input: "src/webex/pageEntryPoint.ts",
output: { output: {
file: "dist/webextension/pageEntryPoint.js", file: "dist/webextension/pageEntryPoint.js",
format: "iife", format: "iife",
exports: "default", exports: "none",
name: "webExtensionPageEntry", name: "webExtensionPageEntry",
}, },
external: builtins, external: builtins,
@ -79,19 +117,24 @@ const webExtensionPageEntryPoint = {
commonjs({ commonjs({
include: ["node_modules/**", "dist/node/**"], include: ["node_modules/**", "dist/node/**"],
extensions: [".js"], extensions: [".js"],
ignoreGlobal: false, // Default: false
sourceMap: false, sourceMap: false,
ignore: ["taler-wallet"], ignore: ["taler-wallet"],
}), }),
typescript({
tsconfig: false,
...baseTypescriptCompilerSettings,
sourceMap: false,
}),
], ],
}; };
const webExtensionBackgroundPageScript = { const webExtensionBackgroundPageScript = {
input: "dist/node/webex/background.js", input: "src/webex/background.ts",
output: { output: {
file: "dist/webextension/background.js", file: "dist/webextension/background.js",
format: "iife", format: "iife",
exports: "default", exports: "none",
name: "webExtensionBackgroundScript", name: "webExtensionBackgroundScript",
}, },
external: builtins, external: builtins,
@ -111,19 +154,24 @@ const webExtensionBackgroundPageScript = {
commonjs({ commonjs({
include: ["node_modules/**", "dist/node/**"], include: ["node_modules/**", "dist/node/**"],
extensions: [".js"], extensions: [".js"],
ignoreGlobal: false, // Default: false
sourceMap: false, sourceMap: false,
ignore: ["taler-wallet", "crypto"], ignore: ["taler-wallet", "crypto"],
}), }),
typescript({
tsconfig: false,
...baseTypescriptCompilerSettings,
sourceMap: false,
}),
], ],
}; };
const webExtensionCryptoWorker = { const webExtensionCryptoWorker = {
input: "dist/node/crypto/workers/browserWorkerEntry.js", input: "src/crypto/workers/browserWorkerEntry.ts",
output: { output: {
file: "dist/webextension/browserWorkerEntry.js", file: "dist/webextension/browserWorkerEntry.js",
format: "iife", format: "iife",
exports: "default", exports: "none",
name: "webExtensionCryptoWorker", name: "webExtensionCryptoWorker",
}, },
external: builtins, external: builtins,
@ -143,10 +191,15 @@ const webExtensionCryptoWorker = {
commonjs({ commonjs({
include: ["node_modules/**", "dist/node/**"], include: ["node_modules/**", "dist/node/**"],
extensions: [".js"], extensions: [".js"],
ignoreGlobal: false, // Default: false
sourceMap: false, sourceMap: false,
ignore: ["taler-wallet", "crypto"], ignore: ["taler-wallet", "crypto"],
}), }),
typescript({
tsconfig: false,
...baseTypescriptCompilerSettings,
sourceMap: false,
}),
], ],
}; };

1837
yarn.lock

File diff suppressed because it is too large Load Diff