@knighted/module 1.5.0 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/cjs/cli.cjs +7 -8
- package/dist/cli.js +8 -9
- package/package.json +5 -13
package/README.md
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
[](https://codecov.io/gh/knightedcodemonkey/module)
|
|
5
5
|
[](https://www.npmjs.com/package/@knighted/module)
|
|
6
6
|
|
|
7
|
-
Node.js utility for transforming a JavaScript or TypeScript file from an ES module
|
|
7
|
+
Node.js utility for transforming a JavaScript or TypeScript file from CommonJS to an ES module, or vice versa.
|
|
8
8
|
|
|
9
|
-
- ES module ➡️ CommonJS
|
|
10
9
|
- CommonJS ➡️ ES module
|
|
10
|
+
- ES module ➡️ CommonJS
|
|
11
11
|
|
|
12
12
|
Highlights
|
|
13
13
|
|
|
14
|
-
-
|
|
14
|
+
- CJS ➡️ ESM and ESM ➡️ CJS with one function call.
|
|
15
15
|
- Defaults to safe CommonJS output: strict live bindings, import.meta shims, and specifier preservation.
|
|
16
16
|
- Configurable lowering modes: full syntax transforms or globals-only.
|
|
17
17
|
- Specifier tools: add extensions, add directory indexes, or map with a custom callback.
|
|
@@ -25,7 +25,7 @@ By default `@knighted/module` transforms the one-to-one [differences between ES
|
|
|
25
25
|
|
|
26
26
|
## Requirements
|
|
27
27
|
|
|
28
|
-
- Node 22
|
|
28
|
+
- Node 22.21.1+ or 24+
|
|
29
29
|
|
|
30
30
|
## Install
|
|
31
31
|
|
package/dist/cjs/cli.cjs
CHANGED
|
@@ -9,7 +9,6 @@ var _nodeProcess = require("node:process");
|
|
|
9
9
|
var _nodeUtil = require("node:util");
|
|
10
10
|
var _promises = require("node:fs/promises");
|
|
11
11
|
var _nodePath = require("node:path");
|
|
12
|
-
var _glob = require("glob");
|
|
13
12
|
var _module = require("./module.cjs");
|
|
14
13
|
var _parse = require("./parse.cjs");
|
|
15
14
|
var _format = require("./format.cjs");
|
|
@@ -387,14 +386,14 @@ const normalizeSourceMapArgv = argv => {
|
|
|
387
386
|
const expandFiles = async (patterns, cwd, ignore) => {
|
|
388
387
|
const files = new Set();
|
|
389
388
|
for (const pattern of patterns) {
|
|
390
|
-
const
|
|
389
|
+
for await (const match of (0, _promises.glob)(pattern, {
|
|
391
390
|
cwd,
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
391
|
+
exclude: ignore,
|
|
392
|
+
withFileTypes: true
|
|
393
|
+
})) {
|
|
394
|
+
if (match.isDirectory()) continue;
|
|
395
|
+
files.add((0, _nodePath.resolve)(match.parentPath, match.name));
|
|
396
|
+
}
|
|
398
397
|
}
|
|
399
398
|
return [...files];
|
|
400
399
|
};
|
package/dist/cli.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { stdin as defaultStdin, stdout as defaultStdout, stderr as defaultStderr } from 'node:process';
|
|
3
3
|
import { parseArgs } from 'node:util';
|
|
4
|
-
import { readFile, mkdir, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { readFile, mkdir, writeFile, glob } from 'node:fs/promises';
|
|
5
5
|
import { dirname, resolve, relative, join, basename } from 'node:path';
|
|
6
|
-
import { glob } from 'glob';
|
|
7
6
|
import { transform, collectProjectDualPackageHazards } from './module.js';
|
|
8
7
|
import { parse } from './parse.js';
|
|
9
8
|
import { format } from './format.js';
|
|
@@ -381,14 +380,14 @@ const normalizeSourceMapArgv = argv => {
|
|
|
381
380
|
const expandFiles = async (patterns, cwd, ignore) => {
|
|
382
381
|
const files = new Set();
|
|
383
382
|
for (const pattern of patterns) {
|
|
384
|
-
const
|
|
383
|
+
for await (const match of glob(pattern, {
|
|
385
384
|
cwd,
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
385
|
+
exclude: ignore,
|
|
386
|
+
withFileTypes: true
|
|
387
|
+
})) {
|
|
388
|
+
if (match.isDirectory()) continue;
|
|
389
|
+
files.add(resolve(match.parentPath, match.name));
|
|
390
|
+
}
|
|
392
391
|
}
|
|
393
392
|
return [...files];
|
|
394
393
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knighted/module",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "Bidirectional transform for ES modules and CommonJS.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/module.js",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"build:types": "tsc --emitDeclarationOnly",
|
|
39
39
|
"build:dual": "babel-dual-package src --extensions .ts",
|
|
40
40
|
"build": "npm run build:types && npm run build:dual",
|
|
41
|
-
"cycles": "
|
|
41
|
+
"cycles": "oxlint --import-plugin --tsconfig tsconfig.json -A all -D import/no-cycle src test",
|
|
42
42
|
"prepack": "npm run build"
|
|
43
43
|
},
|
|
44
44
|
"keywords": [
|
|
@@ -64,29 +64,21 @@
|
|
|
64
64
|
"url": "https://github.com/knightedcodemonkey/module/issues"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@knighted/dump": "^1.0.3",
|
|
68
67
|
"@types/node": "^22.19.3",
|
|
69
68
|
"babel-dual-package": "^1.2.3",
|
|
70
|
-
"c8": "^
|
|
69
|
+
"c8": "^11.0.0",
|
|
71
70
|
"husky": "^9.1.7",
|
|
72
71
|
"lint-staged": "^16.2.7",
|
|
73
|
-
"
|
|
74
|
-
"oxlint": "^1.35.0",
|
|
72
|
+
"oxlint": "^1.51.0",
|
|
75
73
|
"prettier": "^3.7.4",
|
|
76
74
|
"tsx": "^4.21.0",
|
|
77
75
|
"typescript": "^5.9.3"
|
|
78
76
|
},
|
|
79
77
|
"dependencies": {
|
|
80
|
-
"glob": "^13.0.0",
|
|
81
78
|
"magic-string": "^0.30.21",
|
|
82
|
-
"oxc-parser": "^0.
|
|
79
|
+
"oxc-parser": "^0.116.0",
|
|
83
80
|
"periscopic": "^4.0.2"
|
|
84
81
|
},
|
|
85
|
-
"overrides": {
|
|
86
|
-
"module-lookup-amd": {
|
|
87
|
-
"glob": "^9.0.0"
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
82
|
"prettier": {
|
|
91
83
|
"arrowParens": "avoid",
|
|
92
84
|
"printWidth": 90,
|