make-hardener: Fix direct Node.js ESM support
This change rearranges make-hardener so that it supports the full hybrid of ESM, RESM, CJS, browser, and unpkg module systems.
MODIFY
packages/harden/src/main.js
packages/harden/src/main.js
// See the License for the specific language governing permissions and
// limitations under the License.
+// eslint-disable-next-line import/no-unresolved
import makeHardener from '@agoric/make-hardener';
import buildTable from './buildTable.js';

MODIFY
packages/make-hardener-integration-test/pre-release-browser-tests/rollup/make-hardener.js
packages/make-hardener-integration-test/pre-release-browser-tests/rollup/make-hardener.js
+// eslint-disable-next-line import/no-unresolved
import makeHardener from "@agoric/make-hardener";
export default makeHardener;

MODIFY
packages/make-hardener/package.json
packages/make-hardener/package.json
"test": "test"
},
"type": "module",
- "main": "./src/main.js",
- "browser": "dist/make-hardener.umd.js",
+ "main": "./dist/make-hardener.cjs",
+ "module": "./src/main.js",
+ "browser": "./dist/make-hardener.umd.js",
+ "unpkg": "./dist/make-hardener.umd.js",
+ "exports": {
+ "import": "./src/main.js",
+ "require": "./dist/make-hardener.cjs",
+ "browser": "./dist/make-hardener.umd.js"
+ },
"scripts": {
"depcheck": "depcheck",
"lint": "eslint '**/*.js'",
"build": "rollup -c rollup.config.js"
},
"devDependencies": {
+ "@rollup/plugin-node-resolve": "^6.1.0",
"babel-eslint": "^10.0.3",
"eslint": "^6.8.0",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-plugin-prettier": "^3.1.2",
"prettier": "^1.19.1",
"rollup": "1.31.0",
- "rollup-plugin-node-resolve": "5.2.0",
+ "rollup-plugin-terser": "^5.1.3",
"tap": "14.10.5"
}
}

MODIFY
packages/make-hardener/rollup.config.js
packages/make-hardener/rollup.config.js
+import resolve from '@rollup/plugin-node-resolve';
+import { terser } from 'rollup-plugin-terser';
+
export default [
{
input: 'src/main.js',
output: [
{
+ file: 'dist/make-hardener.mjs',
+ format: 'esm',
+ },
+ {
+ file: 'dist/make-hardener.cjs',
+ format: 'cjs',
+ },
+ ],
+ plugins: [resolve()],
+ },
+ {
+ input: 'src/main.js',
+ output: {
file: 'dist/make-hardener.umd.js',
format: 'umd',
name: 'makeHardener',
},
+ plugins: [resolve()],
+ },
{
- file: 'dist/make-hardener.cjs.js',
- format: 'cjs',
+ input: 'src/main.js',
+ output: {
+ file: 'dist/make-hardener.umd.min.js',
+ format: 'umd',
+ name: 'makeHardener',
},
- ],
+ plugins: [resolve(), terser()],
},
];

MODIFY
packages/ses/src/lockdown-shim.js
packages/ses/src/lockdown-shim.js
// See the License for the specific language governing permissions and
// limitations under the License.
+// eslint-disable-next-line import/no-unresolved
import makeHardener from '@agoric/make-hardener';
import { getIntrinsics } from './intrinsics.js';

MODIFY
packages/ses/test/enable-property-overrides.test.js
packages/ses/test/enable-property-overrides.test.js
import tap from 'tap';
import { captureGlobals } from '@agoric/test262-runner';
+// eslint-disable-next-line import/no-unresolved
import makeHardener from '@agoric/make-hardener';
import enablePropertyOverrides from '../src/enable-property-overrides.js';

make-hardener: Fix direct Node.js ESM support (#220)

This change rearranges make-hardener so that it supports the full hybrid of ESM, RESM, CJS, browser, and unpkg module systems.