chore(cjs-module-analyzer): Clarify package name
MODIFY
package.json
package.json
"useWorkspaces": true,
"workspaces": [
"packages/base64",
+ "packages/cjs-module-analyzer",
"packages/compartment-mapper",
"packages/endo",
"packages/eslint-config",
"packages/harden",
- "packages/lexer",
"packages/make-hardener",
"packages/make-importer",
"packages/make-simple-evaluate",

RENAME
packages/lexer/LICENSE
packages/cjs-module-analyzer/LICENSE
RENAME
packages/lexer/NEWS.md
packages/cjs-module-analyzer/NEWS.md
RENAME
packages/lexer/README.md
packages/cjs-module-analyzer/README.md
ADD
packages/cjs-module-analyzer/index.d.ts
+export * from './src/main.js';

ADD
packages/cjs-module-analyzer/index.js
+export { analyzeCommonJS } from './src/cjs-module-analyzer.js';

RENAME
packages/lexer/jsconfig.json
packages/cjs-module-analyzer/jsconfig.json
RENAME
packages/lexer/package.json
packages/cjs-module-analyzer/package.json
"parsers": {
"js": "mjs"
},
- "main": "./dist/lexer.cjs",
- "module": "./src/main.js",
- "browser": "./dist/lexer.umd.js",
- "unpkg": "./dist/lexer.umd.js",
+ "main": "./dist/cjs-module-analyzer.cjs",
+ "module": "./index.js",
+ "browser": "./dist/cjs-module-analyzer.umd.js",
+ "unpkg": "./dist/cjs-module-analyzer.umd.js",
"types": "./index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
- "import": "./src/main.js",
- "require": "./dist/lexer.cjs",
- "browser": "./dist/lexer.umd.js"
+ "import": "./index.js",
+ "require": "./dist/cjs-module-analyzer.cjs",
+ "browser": "./dist/cjs-module-analyzer.umd.js"
}
},
"scripts": {

RENAME
packages/lexer/rollup.config.js
packages/cjs-module-analyzer/rollup.config.js
@@ -10,7 +10,7 @@ const umd = meta.umd || name;
export default [
{
- input: 'src/main.js',
+ input: 'index.js',
output: [
{
file: `dist/${name}.mjs`,
@@ -24,7 +24,7 @@ export default [
plugins: [resolve(), commonjs()],
},
{
- input: 'src/main.js',
+ input: 'index.js',
output: {
file: `dist/${name}.umd.js`,
format: 'umd',
@@ -33,7 +33,7 @@ export default [
plugins: [resolve(), commonjs()],
},
{
- input: 'src/main.js',
+ input: 'index.js',
output: {
file: `dist/${name}.umd.min.js`,
format: 'umd',

RENAME
packages/lexer/src/lexer.js
packages/cjs-module-analyzer/src/cjs-module-analyzer.js
RENAME
packages/lexer/test/test-unit.js
packages/cjs-module-analyzer/test/test-cjs-module-analyzer.js
import test from 'ava';
-import { analyzeCommonJS } from '../src/lexer.js';
+import { analyzeCommonJS } from '../src/cjs-module-analyzer.js';
+
+test('analyze exports', t => {
+ const { exports, reexports } = analyzeCommonJS(`
+ exports.meaning = 42;
+ `);
+ t.deepEqual(exports, ['meaning']);
+ t.deepEqual(reexports, []);
+});
+
+test('analyze default export figure', t => {
+ const { exports, reexports } = analyzeCommonJS(`
+ module.exports = function () {};
+ `);
+ t.deepEqual(exports, ['default']);
+ t.deepEqual(reexports, []);
+});
+
+test('analyze exported restructured name', t => {
+ const { exports, reexports } = analyzeCommonJS(`
+ function a() {}
+ module.exports = {a};
+ `);
+ t.deepEqual(exports, ['a']);
+ t.deepEqual(reexports, []);
+});
+
+test('analyze exported quoted identifier to identifier', t => {
+ const { exports, reexports } = analyzeCommonJS(`
+ function a() {}
+ module.exports = {"a": a};
+ `);
+ t.deepEqual(exports, ['a']);
+ t.deepEqual(reexports, []);
+});
+
+test('analyze mix of quoted and unquoted destructed identifiers', t => {
+ const { exports, reexports } = analyzeCommonJS(`
+ function a() {}
+ function b() {}
+ function c() {}
+ function d() {}
+ module.exports = {"a": a, 'b': b, c: c, d};
+ `);
+ t.deepEqual(exports, ['a', 'b', 'c', 'd']);
+ t.deepEqual(reexports, []);
+});
+
+test('analyze reexports', t => {
+ const { exports, reexports } = analyzeCommonJS(`
+ module.exports = require('./x.js');
+ `);
+ t.deepEqual(exports, []);
+ t.deepEqual(reexports, ['./x.js']);
+});
test('esbuild hint style', t => {
const { exports, reexports } = analyzeCommonJS(`

DELETE
packages/lexer/index.d.ts
-export type * from './src/main.js';

DELETE
packages/lexer/src/main.js
-export { analyzeCommonJS } from './lexer.js';

DELETE
packages/lexer/test/test-lexer.js
-import test from 'ava';
-import { analyzeCommonJS } from '../src/lexer.js';
-
-test('analyze exports', t => {
- const { exports, reexports } = analyzeCommonJS(`
- exports.meaning = 42;
- `);
- t.deepEqual(exports, ['meaning']);
- t.deepEqual(reexports, []);
-});
-
-test('analyze default export figure', t => {
- const { exports, reexports } = analyzeCommonJS(`
- module.exports = function () {};
- `);
- t.deepEqual(exports, ['default']);
- t.deepEqual(reexports, []);
-});
-
-test('analyze exported restructured name', t => {
- const { exports, reexports } = analyzeCommonJS(`
- function a() {}
- module.exports = {a};
- `);
- t.deepEqual(exports, ['a']);
- t.deepEqual(reexports, []);
-});
-
-test('analyze exported quoted identifier to identifier', t => {
- const { exports, reexports } = analyzeCommonJS(`
- function a() {}
- module.exports = {"a": a};
- `);
- t.deepEqual(exports, ['a']);
- t.deepEqual(reexports, []);
-});
-
-test('analyze mix of quoted and unquoted destructed identifiers', t => {
- const { exports, reexports } = analyzeCommonJS(`
- function a() {}
- function b() {}
- function c() {}
- function d() {}
- module.exports = {"a": a, 'b': b, c: c, d};
- `);
- t.deepEqual(exports, ['a', 'b', 'c', 'd']);
- t.deepEqual(reexports, []);
-});
-
-test('analyze reexports', t => {
- const { exports, reexports } = analyzeCommonJS(`
- module.exports = require('./x.js');
- `);
- t.deepEqual(exports, []);
- t.deepEqual(reexports, ['./x.js']);
-});

chore(cjs-module-analyzer): Clarify package name