fix(transform-module): Generalize rollup config
MODIFY
packages/transform-module/rollup.config.js
packages/transform-module/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';
@@ -20,7 +21,7 @@ export default [
format: 'cjs',
},
],
- plugins: [resolve()],
+ plugins: [resolve(), commonjs()],
},
{
input: 'src/main.js',
@@ -29,7 +30,7 @@ export default [
format: 'umd',
name: umd,
},
- plugins: [resolve()],
+ plugins: [resolve(), commonjs()],
},
{
input: 'src/main.js',
@@ -38,6 +39,6 @@ export default [
format: 'umd',
name: umd,
},
- plugins: [resolve(), terser()],
+ plugins: [resolve(), commonjs(), terser()],
},
];

MODIFY
scripts/repackage.sh
scripts/repackage.sh
@@ -49,16 +49,34 @@ NEWPKGJSONHASH=$(
name: (.name // "@agoric/\($name)"),
version: (.version // "0.1.0"),
type: "module",
+ parsers: {"js": "mjs"},
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 // {}) + {
+ exports: (
+ if
+ .exports["./package.json"]
+ then
+ (.exports // {}) + {
+ ".": ((.exports["."] // {}) + {
import: "./src/main.js",
require: "./dist/\($name).cjs",
browser: "./dist/\($name).umd.js",
- }),
+ })
+ }
+ else
+ ({
+ "./package.json": "./package.json",
+ ".": ((.exports // {}) + {
+ import: "./src/main.js",
+ require: "./dist/\($name).cjs",
+ browser: "./dist/\($name).umd.js",
+ })
+ })
+ end
+ ),
scripts: ((.scripts // {}) + {
prepublish: "yarn clean && yarn build",
clean: "rm -rf dist",

fix(transform-module): Generalize rollup config