Bundler updates

- Use .m.js instead of .mjs for es bundle since react tools does not like that extension
 - Switch to standard rollup typescript plugin
 - Include tslib for lighter bundles upstream
This commit is contained in:
Johan Nordberg
2020-12-06 09:37:53 +09:00
parent 9d1668e984
commit c45de93008
5 changed files with 183 additions and 1133 deletions
+1
View File
@@ -2,6 +2,7 @@
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"ignorePatterns": ["lib/*", "node_modules/**"],
"extends": [
"eslint:recommended",
"plugin:prettier/recommended",
+12 -11
View File
@@ -5,7 +5,7 @@
"homepage": "https://github.com/greymass/eosio-signing-request",
"license": "MIT",
"main": "lib/esr.js",
"module": "lib/esr.mjs",
"module": "lib/esr.m.js",
"types": "lib/esr.d.ts",
"sideEffects": false,
"files": [
@@ -16,24 +16,25 @@
"prepare": "make"
},
"dependencies": {
"@greymass/eosio": "^0.1.2"
"@greymass/eosio": "^0.1.4",
"tslib": "^2.0.3"
},
"devDependencies": {
"@rollup/plugin-typescript": "^8.0.0",
"@types/mocha": "^8.0.4",
"@types/node": "^14.14.9",
"@typescript-eslint/eslint-plugin": "^4.8.2",
"@typescript-eslint/parser": "^4.8.2",
"@wessberg/rollup-plugin-ts": "^1.3.8",
"eslint": "^7.5.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.3",
"@typescript-eslint/eslint-plugin": "^4.9.0",
"@typescript-eslint/parser": "^4.9.0",
"eslint": "^7.15.0",
"eslint-config-prettier": "^7.0.0",
"eslint-plugin-prettier": "^3.2.0",
"mocha": "^8.0.1",
"node-fetch": "^2.6.0",
"nyc": "^15.1.0",
"prettier": "^2.0.5",
"rollup": "^2.33.3",
"prettier": "^2.2.1",
"rollup": "^2.34.1",
"rollup-plugin-dts": "^2.0.0",
"ts-node": "^9.0.0",
"ts-node": "^9.1.0",
"typescript": "^4.1.2"
}
}
+28 -25
View File
@@ -1,6 +1,6 @@
import fs from 'fs'
import dts from 'rollup-plugin-dts'
import ts from '@wessberg/rollup-plugin-ts'
import typescript from '@rollup/plugin-typescript'
import pkg from './package.json'
@@ -20,33 +20,25 @@ const external = Object.keys(pkg.dependencies)
export default [
{
input: 'src/index.ts',
output: {banner, file: pkg.main, format: 'cjs', sourcemap: true},
plugins: [
ts({
tsconfig: (conf) => ({
...conf,
declaration: false,
target: 'es6',
module: 'commonjs',
}),
}),
],
output: {
banner,
file: pkg.main,
format: 'cjs',
sourcemap: true,
},
plugins: [typescript({target: 'es5'})],
external,
onwarn,
},
{
input: 'src/index.ts',
output: {banner, file: pkg.module, format: 'esm', sourcemap: true},
plugins: [
ts({
tsconfig: (conf) => ({
...conf,
declaration: false,
target: 'esnext',
module: 'esnext',
}),
}),
],
output: {
banner,
file: pkg.module,
format: 'esm',
sourcemap: true,
},
plugins: [typescript({target: 'esnext'})],
external,
onwarn,
},
@@ -59,7 +51,18 @@ export default [
]
function onwarn(warning, rollupWarn) {
if (warning.code !== 'CIRCULAR_DEPENDENCY') {
if (warning.code === 'CIRCULAR_DEPENDENCY') {
// unnecessary warning
return
}
if (
warning.code === 'UNUSED_EXTERNAL_IMPORT' &&
warning.source === 'tslib' &&
warning.names[0] === '__read'
) {
// when using ts with importHelpers: true rollup complains about this
// seems safe to ignore since __read is not actually imported or used anywhere in the resulting bundles
return
}
rollupWarn(warning)
}
}
+1 -2
View File
@@ -1,15 +1,14 @@
{
"compilerOptions": {
"declaration": true,
"downlevelIteration": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"importHelpers": true,
"isolatedModules": true,
"lib": ["dom", "esnext"],
"module": "esnext",
"moduleResolution": "node",
"noImplicitAny": false,
"outDir": "lib",
"sourceMap": true,
"strict": true,
"target": "esnext"
+141 -1095
View File
File diff suppressed because it is too large Load Diff