@knighted/duel 2.0.0 → 2.0.1
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 +0 -2
- package/dist/cjs/init.cjs +3 -16
- package/dist/cjs/init.d.cts +10 -1
- package/dist/esm/init.d.ts +10 -1
- package/dist/esm/init.js +4 -14
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -114,8 +114,6 @@ These are definitely edge cases, and would only really come up if your project m
|
|
|
114
114
|
|
|
115
115
|
- Unfortunately, TypeScript doesn't really build [dual packages](https://nodejs.org/api/packages.html#dual-commonjses-module-packages) very well. One instance of unexpected behavior is when the compiler throws errors for ES module globals when running a dual CJS build, but not for the inverse case, despite both causing runtime errors in Node.js. See the [open issue](https://github.com/microsoft/TypeScript/issues/58658). You can circumvent this with `duel` by using the `--modules` option if your project uses module globals such as `import.meta` properties or `__dirname`, `__filename`, etc. in a CommonJS project.
|
|
116
116
|
|
|
117
|
-
- If doing an `import type` across module systems, i.e. from `.mts` into `.cts`, or vice versa, you might encounter the compilation error ``error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.``. This is a [known issue](https://github.com/microsoft/TypeScript/issues/49055) and TypeScript currently suggests installing the nightly build, i.e. `npm i typescript@next`.
|
|
118
|
-
|
|
119
117
|
- If running `duel` with your project's package.json file open in your editor, you may temporarily see the content replaced. This is because `duel` dynamically creates a new package.json using the `type` necessary for the dual build. Your original package.json will be restored after the build completes.
|
|
120
118
|
|
|
121
119
|
## Notes
|
package/dist/cjs/init.cjs
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.init = void 0;
|
|
7
4
|
const node_process_1 = require("node:process");
|
|
8
5
|
const node_util_1 = require("node:util");
|
|
9
6
|
const node_path_1 = require("node:path");
|
|
10
7
|
const promises_1 = require("node:fs/promises");
|
|
8
|
+
const get_tsconfig_1 = require("get-tsconfig");
|
|
11
9
|
const read_package_up_1 = require("read-package-up");
|
|
12
|
-
const jsonc_parser_1 = __importDefault(require("jsonc-parser"));
|
|
13
10
|
const util_js_1 = require("./util.cjs");
|
|
14
11
|
const init = async (args) => {
|
|
15
12
|
let parsed = null;
|
|
@@ -96,21 +93,11 @@ const init = async (args) => {
|
|
|
96
93
|
}
|
|
97
94
|
}
|
|
98
95
|
if (stats.isFile()) {
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
const jsonText = (await (0, promises_1.readFile)(configPath)).toString();
|
|
102
|
-
tsconfig = jsonc_parser_1.default.parse(jsonText, errors, {
|
|
103
|
-
disallowComments: false,
|
|
104
|
-
allowTrailingComma: true,
|
|
105
|
-
});
|
|
106
|
-
if (errors.length) {
|
|
107
|
-
(0, util_js_1.logError)(`The config file found at ${configPath} is not parsable as JSONC.`);
|
|
108
|
-
return false;
|
|
109
|
-
}
|
|
96
|
+
const tsconfig = (0, get_tsconfig_1.parseTsconfig)(configPath);
|
|
97
|
+
const projectDir = (0, node_path_1.dirname)(configPath);
|
|
110
98
|
if (!tsconfig.compilerOptions?.outDir) {
|
|
111
99
|
(0, util_js_1.log)('No outDir defined in tsconfig.json. Build output will be in "dist".');
|
|
112
100
|
}
|
|
113
|
-
const projectDir = (0, node_path_1.dirname)(configPath);
|
|
114
101
|
return {
|
|
115
102
|
pkg,
|
|
116
103
|
dirs,
|
package/dist/cjs/init.d.cts
CHANGED
|
@@ -2,7 +2,16 @@ export function init(args: any): Promise<false | {
|
|
|
2
2
|
pkg: import("read-package-up", { with: { "resolution-mode": "import" } }).NormalizedReadResult;
|
|
3
3
|
dirs: boolean;
|
|
4
4
|
modules: boolean;
|
|
5
|
-
tsconfig:
|
|
5
|
+
tsconfig: {
|
|
6
|
+
compilerOptions?: import("get-tsconfig").TsConfigJson.CompilerOptions | undefined;
|
|
7
|
+
watchOptions?: import("get-tsconfig").TsConfigJson.WatchOptions | undefined;
|
|
8
|
+
typeAcquisition?: import("get-tsconfig").TsConfigJson.TypeAcquisition | undefined;
|
|
9
|
+
compileOnSave?: boolean | undefined;
|
|
10
|
+
files?: string[] | undefined;
|
|
11
|
+
exclude?: string[] | undefined;
|
|
12
|
+
include?: string[] | undefined;
|
|
13
|
+
references?: import("get-tsconfig").TsConfigJson.References[] | undefined;
|
|
14
|
+
};
|
|
6
15
|
projectDir: string;
|
|
7
16
|
configPath: string;
|
|
8
17
|
}>;
|
package/dist/esm/init.d.ts
CHANGED
|
@@ -2,7 +2,16 @@ export function init(args: any): Promise<false | {
|
|
|
2
2
|
pkg: import("read-package-up").NormalizedReadResult;
|
|
3
3
|
dirs: boolean;
|
|
4
4
|
modules: boolean;
|
|
5
|
-
tsconfig:
|
|
5
|
+
tsconfig: {
|
|
6
|
+
compilerOptions?: import("get-tsconfig").TsConfigJson.CompilerOptions | undefined;
|
|
7
|
+
watchOptions?: import("get-tsconfig").TsConfigJson.WatchOptions | undefined;
|
|
8
|
+
typeAcquisition?: import("get-tsconfig").TsConfigJson.TypeAcquisition | undefined;
|
|
9
|
+
compileOnSave?: boolean | undefined;
|
|
10
|
+
files?: string[] | undefined;
|
|
11
|
+
exclude?: string[] | undefined;
|
|
12
|
+
include?: string[] | undefined;
|
|
13
|
+
references?: import("get-tsconfig").TsConfigJson.References[] | undefined;
|
|
14
|
+
};
|
|
6
15
|
projectDir: string;
|
|
7
16
|
configPath: string;
|
|
8
17
|
}>;
|
package/dist/esm/init.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { cwd } from 'node:process';
|
|
2
2
|
import { parseArgs } from 'node:util';
|
|
3
3
|
import { resolve, join, dirname } from 'node:path';
|
|
4
|
-
import { stat
|
|
4
|
+
import { stat } from 'node:fs/promises';
|
|
5
|
+
import { parseTsconfig } from 'get-tsconfig';
|
|
5
6
|
import { readPackageUp } from 'read-package-up';
|
|
6
|
-
import JSONC from 'jsonc-parser';
|
|
7
7
|
import { logError, log } from './util.js';
|
|
8
8
|
const init = async (args) => {
|
|
9
9
|
let parsed = null;
|
|
@@ -90,21 +90,11 @@ const init = async (args) => {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
if (stats.isFile()) {
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
const jsonText = (await readFile(configPath)).toString();
|
|
96
|
-
tsconfig = JSONC.parse(jsonText, errors, {
|
|
97
|
-
disallowComments: false,
|
|
98
|
-
allowTrailingComma: true,
|
|
99
|
-
});
|
|
100
|
-
if (errors.length) {
|
|
101
|
-
logError(`The config file found at ${configPath} is not parsable as JSONC.`);
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
93
|
+
const tsconfig = parseTsconfig(configPath);
|
|
94
|
+
const projectDir = dirname(configPath);
|
|
104
95
|
if (!tsconfig.compilerOptions?.outDir) {
|
|
105
96
|
log('No outDir defined in tsconfig.json. Build output will be in "dist".');
|
|
106
97
|
}
|
|
107
|
-
const projectDir = dirname(configPath);
|
|
108
98
|
return {
|
|
109
99
|
pkg,
|
|
110
100
|
dirs,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knighted/duel",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "TypeScript dual packages.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/esm/duel.js",
|
|
@@ -57,22 +57,23 @@
|
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@eslint/js": "^9.6.0",
|
|
60
|
+
"@tsconfig/recommended": "^1.0.8",
|
|
60
61
|
"@types/node": "^22.7.4",
|
|
61
62
|
"c8": "^10.1.3",
|
|
62
63
|
"eslint": "^9.16.0",
|
|
63
64
|
"eslint-plugin-n": "^17.15.0",
|
|
64
65
|
"globals": "^15.6.0",
|
|
65
66
|
"prettier": "^3.4.2",
|
|
66
|
-
"tsx": "^4.19.
|
|
67
|
-
"typescript": "^5.
|
|
68
|
-
"vite": "^6.
|
|
67
|
+
"tsx": "^4.19.3",
|
|
68
|
+
"typescript": "^5.8.2",
|
|
69
|
+
"vite": "^6.2.3"
|
|
69
70
|
},
|
|
70
71
|
"dependencies": {
|
|
71
72
|
"@knighted/module": "^1.0.0-alpha.4",
|
|
72
73
|
"@knighted/specifier": "^2.0.0-rc.1",
|
|
73
74
|
"find-up": "^6.3.0",
|
|
74
|
-
"
|
|
75
|
-
"
|
|
75
|
+
"get-tsconfig": "^4.10.0",
|
|
76
|
+
"glob": "^11.0.1",
|
|
76
77
|
"read-package-up": "^11.0.0"
|
|
77
78
|
},
|
|
78
79
|
"prettier": {
|