fix: Update repackage.sh scaffolding script
MODIFY
scripts/repackage.sh
scripts/repackage.sh
@@ -30,23 +30,30 @@ NEWPKGJSONHASH=$(
author: "Agoric",
license: "Apache-2.0",
type: null,
+ parsers: null,
main: null,
module: null,
browser: null,
unpkg: null,
+ types: null,
exports: {},
scripts: {},
dependencies: {},
devDependencies: {},
- files: []
+ files: [],
+ publishConfig: null,
+ eslintConfig: null,
+ prettier: null,
+ ava: null,
} + . + {
name: (.name // "@agoric/\($name)"),
- version: "0.0.0+1-dev",
+ version: (.version // "0.1.0"),
type: "module",
main: "./dist/\($name).cjs",
module: "./src/main.js",
browser: "./dist/\($name).umd.js",
unpkg: "./dist/\($name).umd.js",
+ types: "./types/main.d.ts",
exports: ((.exports // {}) + {
import: "./src/main.js",
require: "./dist/\($name).cjs",
@@ -55,28 +62,63 @@ NEWPKGJSONHASH=$(
scripts: ((.scripts // {}) + {
prepublish: "yarn clean && yarn build",
clean: "rm -rf dist",
- build: "rollup --config rollup.config.js",
- test: "yarn build && tap --no-esm --no-coverage --reporter spec 'test/**/*.test.js'",
+ build: "yarn build:types && yarn build:dist",
+ "build:dist": "rollup --config rollup.config.js",
+ "build:types": "tsc src/*.js --declaration --allowJs --emitDeclarationOnly --outDir types",
+ test: "ava",
+ cover: "nyc ava",
lint: "eslint '"'**/*.js'"'",
"lint-fix": "eslint --fix '"'**/*.js'"'",
}) | to_entries | sort_by(.key) | from_entries,
devDependencies: ((.devDependencies // {}) + {
"@rollup/plugin-node-resolve": "^6.1.0",
+ "@rollup/plugin-commonjs": "^13.0.0",
"rollup-plugin-terser": "^5.1.3",
- "tap": "14.10.5",
- "tape": "5.0.1",
+ "ava": "^3.12.1",
+ "babel-eslint": "^10.0.3",
+ "eslint": "^6.8.0",
+ "eslint-config-airbnb-base": "^14.0.0",
+ "eslint-config-prettier": "^6.9.0",
+ "eslint-plugin-eslint-comments": "^3.1.2",
+ "eslint-plugin-import": "^2.19.1",
+ "eslint-plugin-prettier": "^3.1.2",
+ "nyc": "^15.1.0",
+ "prettier": "^1.19.1",
+ "rollup": "1.31.0",
+ "rollup-plugin-terser": "^5.1.3",
+ "typescript": "^4.0.5",
+ "ava": "^3.12.1",
+ "nyc": "^15.1.0",
}) | to_entries | sort_by(.key) | from_entries,
files: ((.files // []) + [
"src",
"dist",
"LICENSE*"
- ]) | sort | unique
+ ]) | sort | unique,
+ "publishConfig": {
+ "access": "public",
+ },
+ "eslintConfig": {
+ "extends": [
+ "@agoric"
+ ],
+ },
+ "prettier": {
+ "trailingComma": "all",
+ "singleQuote": true,
+ },
+ "ava": {
+ "files": [
+ "test/**/test-*.js"
+ ],
+ "timeout": "2m"
+ }
}' | git hash-object -w --stdin
)
git cat-file blob "$NEWPKGJSONHASH" > "$PKGJSON"
-cp packages/transform-module/rollup.config.js packages/"$NAME"/rollup.config.js
-cp packages/transform-module/LICENSE packages/"$NAME"/LICENSE
+cp template-rollup.config.js packages/"$NAME"/rollup.config.js
+cp LICENSE packages/"$NAME"/LICENSE
touch packages/"$NAME"/README.md
touch packages/"$NAME"/NEWS.md

ADD
template-rollup.config.js
+import resolve from '@rollup/plugin-node-resolve';
+import commonjs from '@rollup/plugin-commonjs';
+import { terser } from 'rollup-plugin-terser';
+import fs from 'fs';
+
+const metaPath = new URL('package.json', import.meta.url).pathname;
+const meta = JSON.parse(fs.readFileSync(metaPath, 'utf-8'));
+const name = meta.name.split('/').pop();
+const umd = meta.umd || name;
+
+export default [
+ {
+ input: 'src/main.js',
+ output: [
+ {
+ file: `dist/${name}.mjs`,
+ format: 'esm',
+ },
+ {
+ file: `dist/${name}.cjs`,
+ format: 'cjs',
+ },
+ ],
+ plugins: [resolve(), commonjs()],
+ },
+ {
+ input: 'src/main.js',
+ output: {
+ file: `dist/${name}.umd.js`,
+ format: 'umd',
+ name: umd,
+ },
+ plugins: [resolve(), commonjs()],
+ },
+ {
+ input: 'src/main.js',
+ output: {
+ file: `dist/${name}.umd.min.js`,
+ format: 'umd',
+ name: umd,
+ },
+ plugins: [resolve(), commonjs(), terser()],
+ },
+];

fix: Update repackage.sh scaffolding script