jiek 2.2.7-alpha.1 → 2.2.7-alpha.4
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/.jiek-production-tag +0 -0
- package/bin-helper/index.cjs +1 -1
- package/dist/.internal/{getWD-BRJ3PK1S.js → .chunks/filterSupport.4rM7f6jB.cjs} +38 -29
- package/dist/.internal/{getWD-Cmxzjf-f.js → .chunks/filterSupport.BXWpLBpT.js} +37 -28
- package/dist/.internal/{+/utils/loadConfig.js → .chunks/loadConfig.CFfzkm_p.js} +24 -8
- package/dist/.internal/{+/utils/loadConfig.cjs → .chunks/loadConfig.OOKddvHF.cjs} +29 -12
- package/dist/.internal/bin/common.cjs +743 -0
- package/dist/.internal/bin/common.d.cts +18 -0
- package/dist/.internal/bin/common.d.ts +18 -0
- package/dist/.internal/bin/common.js +736 -0
- package/dist/.internal/{+/utils → utils}/filterSupport.cjs +1 -3
- package/dist/.internal/{+/utils → utils}/filterSupport.js +1 -3
- package/dist/.internal/utils/loadConfig.cjs +14 -0
- package/dist/.internal/{+/utils/getWD.js → utils/loadConfig.js} +5 -6
- package/dist/.internal/{+/utils → utils}/resolveExports.cjs +1 -1
- package/dist/.internal/{+/utils → utils}/resolveExports.js +1 -1
- package/dist/.internal/{+/utils → utils}/ts.cjs +1 -1
- package/dist/.internal/{+/utils → utils}/ts.js +1 -1
- package/dist/bin/build.cjs +3 -498
- package/dist/bin/index.cjs +56 -43
- package/dist/index.d.cts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/rollup/index.cjs +25 -31
- package/dist/rollup/index.js +25 -31
- package/package.json +12 -15
- package/src/bin/build.cts +2 -8
- package/src/bin/common.ts +3 -0
- package/src/bin/index.cts +2 -1
- package/src/commands/build.ts +9 -3
- package/src/commands/publish.ts +62 -39
- package/src/index.ts +6 -1
- package/src/rollup/index.ts +36 -33
- package/dist/.internal/+/commands/build/analyzer.cjs +0 -201
- package/dist/.internal/+/commands/build/analyzer.d.cts +0 -30
- package/dist/.internal/+/commands/build/analyzer.d.ts +0 -30
- package/dist/.internal/+/commands/build/analyzer.js +0 -195
- package/dist/.internal/+/commands/descriptions.cjs +0 -21
- package/dist/.internal/+/commands/descriptions.d.cts +0 -5
- package/dist/.internal/+/commands/descriptions.d.ts +0 -5
- package/dist/.internal/+/commands/descriptions.js +0 -17
- package/dist/.internal/+/commands/meta.cjs +0 -16
- package/dist/.internal/+/commands/meta.d.cts +0 -3
- package/dist/.internal/+/commands/meta.d.ts +0 -3
- package/dist/.internal/+/commands/meta.js +0 -15
- package/dist/.internal/+/commands/utils/optionParser.cjs +0 -8
- package/dist/.internal/+/commands/utils/optionParser.d.cts +0 -3
- package/dist/.internal/+/commands/utils/optionParser.d.ts +0 -3
- package/dist/.internal/+/commands/utils/optionParser.js +0 -6
- package/dist/.internal/+/server.cjs +0 -33
- package/dist/.internal/+/server.d.cts +0 -8
- package/dist/.internal/+/server.d.ts +0 -8
- package/dist/.internal/+/server.js +0 -27
- package/dist/.internal/+/utils/checkDependency.cjs +0 -39
- package/dist/.internal/+/utils/checkDependency.d.cts +0 -3
- package/dist/.internal/+/utils/checkDependency.d.ts +0 -3
- package/dist/.internal/+/utils/checkDependency.js +0 -34
- package/dist/.internal/+/utils/getRoot.cjs +0 -17
- package/dist/.internal/+/utils/getRoot.d.cts +0 -3
- package/dist/.internal/+/utils/getRoot.d.ts +0 -3
- package/dist/.internal/+/utils/getRoot.js +0 -11
- package/dist/.internal/+/utils/getWD.cjs +0 -15
- package/dist/.internal/+/utils/getWD.d.cts +0 -6
- package/dist/.internal/+/utils/getWD.d.ts +0 -6
- package/dist/.internal/+/utils/tsRegister.cjs +0 -25
- package/dist/.internal/+/utils/tsRegister.d.cts +0 -3
- package/dist/.internal/+/utils/tsRegister.d.ts +0 -3
- package/dist/.internal/+/utils/tsRegister.js +0 -26
- package/dist/.internal/jiek_create-require-CWFWNQHj.js +0 -5
- package/dist/.internal/jiek_create-require-CxSGbkTB.js +0 -5
- package/dist/.internal/package.json +0 -10
- /package/dist/.internal/{index-B6RQz1DZ.js → .chunks/index.B6RQz1DZ.js} +0 -0
- /package/dist/.internal/{index-DlHFuTjM.js → .chunks/index.DlHFuTjM.cjs} +0 -0
- /package/dist/.internal/{+/bin → bin}/parseArgv.cjs +0 -0
- /package/dist/.internal/{+/bin → bin}/parseArgv.d.cts +0 -0
- /package/dist/.internal/{+/bin → bin}/parseArgv.d.ts +0 -0
- /package/dist/.internal/{+/bin → bin}/parseArgv.js +0 -0
- /package/dist/.internal/{+/bridge.cjs → bridge.cjs} +0 -0
- /package/dist/.internal/{+/bridge.d.cts → bridge.d.cts} +0 -0
- /package/dist/.internal/{+/bridge.d.ts → bridge.d.ts} +0 -0
- /package/dist/.internal/{+/bridge.js → bridge.js} +0 -0
- /package/dist/.internal/{+/rollup → rollup}/base.cjs +0 -0
- /package/dist/.internal/{+/rollup → rollup}/base.d.cts +0 -0
- /package/dist/.internal/{+/rollup → rollup}/base.d.ts +0 -0
- /package/dist/.internal/{+/rollup → rollup}/base.js +0 -0
- /package/dist/.internal/{+/rollup → rollup}/bundle-analyzer.cjs +0 -0
- /package/dist/.internal/{+/rollup → rollup}/bundle-analyzer.d.cts +0 -0
- /package/dist/.internal/{+/rollup → rollup}/bundle-analyzer.d.ts +0 -0
- /package/dist/.internal/{+/rollup → rollup}/bundle-analyzer.js +0 -0
- /package/dist/.internal/{+/utils → utils}/filterSupport.d.cts +0 -0
- /package/dist/.internal/{+/utils → utils}/filterSupport.d.ts +0 -0
- /package/dist/.internal/{+/utils → utils}/getInternalModuleName.cjs +0 -0
- /package/dist/.internal/{+/utils → utils}/getInternalModuleName.d.cts +0 -0
- /package/dist/.internal/{+/utils → utils}/getInternalModuleName.d.ts +0 -0
- /package/dist/.internal/{+/utils → utils}/getInternalModuleName.js +0 -0
- /package/dist/.internal/{+/utils → utils}/intersection.cjs +0 -0
- /package/dist/.internal/{+/utils → utils}/intersection.d.cts +0 -0
- /package/dist/.internal/{+/utils → utils}/intersection.d.ts +0 -0
- /package/dist/.internal/{+/utils → utils}/intersection.js +0 -0
- /package/dist/.internal/{+/utils → utils}/loadConfig.d.cts +0 -0
- /package/dist/.internal/{+/utils → utils}/loadConfig.d.ts +0 -0
- /package/dist/.internal/{+/utils → utils}/recursiveListFiles.cjs +0 -0
- /package/dist/.internal/{+/utils → utils}/recursiveListFiles.d.cts +0 -0
- /package/dist/.internal/{+/utils → utils}/recursiveListFiles.d.ts +0 -0
- /package/dist/.internal/{+/utils → utils}/recursiveListFiles.js +0 -0
- /package/dist/.internal/{+/utils → utils}/resolveExports.d.cts +0 -0
- /package/dist/.internal/{+/utils → utils}/resolveExports.d.ts +0 -0
- /package/dist/.internal/{+/utils → utils}/ts.d.cts +0 -0
- /package/dist/.internal/{+/utils → utils}/ts.d.ts +0 -0
package/dist/bin/index.cjs
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
+
require('#~/bin/common');
|
3
4
|
var childProcess = require('node:child_process');
|
4
5
|
var fs = require('node:fs');
|
5
6
|
var path = require('node:path');
|
@@ -8,12 +9,11 @@ var bumper = require('@jiek/utils/bumper');
|
|
8
9
|
var commander = require('commander');
|
9
10
|
var detectIndent = require('detect-indent');
|
10
11
|
var jsoncParser = require('jsonc-parser');
|
11
|
-
var filterSupport = require('
|
12
|
-
var loadConfig = require('
|
13
|
-
var resolveExports = require('
|
14
|
-
var getInternalModuleName = require('
|
15
|
-
require('
|
16
|
-
var parseArgv = require('@jiek/__internal__/+/bin/parseArgv');
|
12
|
+
var filterSupport = require('#~/utils/filterSupport');
|
13
|
+
var loadConfig = require('#~/utils/loadConfig');
|
14
|
+
var resolveExports = require('#~/utils/resolveExports');
|
15
|
+
var getInternalModuleName = require('#~/utils/getInternalModuleName');
|
16
|
+
var parseArgv = require('#~/bin/parseArgv');
|
17
17
|
|
18
18
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
19
19
|
|
@@ -100,12 +100,12 @@ async function prepublish({ bumper: bumper$1 } = {}) {
|
|
100
100
|
} = process__default.default.env;
|
101
101
|
const outdir = outdirEnv ? JSON.parse(outdirEnv) : "dist";
|
102
102
|
bumper$1 = bumper$1 ?? (bumperEnv ? JSON.parse(bumperEnv) : false);
|
103
|
-
const generateNewManifest = (dir, manifest) => {
|
103
|
+
const generateNewManifest = (dir, manifest, config) => {
|
104
104
|
const {
|
105
105
|
name,
|
106
106
|
type,
|
107
|
-
exports: entrypoints
|
108
|
-
imports: internalEntrypoints
|
107
|
+
exports: entrypoints,
|
108
|
+
imports: internalEntrypoints
|
109
109
|
} = manifest;
|
110
110
|
if (!name) {
|
111
111
|
throw new Error(`package.json in ${dir} must have a name field`);
|
@@ -115,32 +115,44 @@ async function prepublish({ bumper: bumper$1 } = {}) {
|
|
115
115
|
const commonOptions = {
|
116
116
|
pkgIsModule,
|
117
117
|
pkgName: name,
|
118
|
-
config
|
118
|
+
config,
|
119
119
|
dir,
|
120
120
|
noFilter: true,
|
121
121
|
isPublish: true
|
122
122
|
};
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
123
|
+
let resolvedOutdir = outdir;
|
124
|
+
if (entrypoints) {
|
125
|
+
const [resolvedEntrypoints, exports, _resolvedOutdir] = resolveExports.resolveExports({
|
126
|
+
entrypoints,
|
127
|
+
defaultOutdir: outdir,
|
128
|
+
...commonOptions
|
129
|
+
});
|
130
|
+
newManifest.exports = {
|
131
|
+
...resolvedEntrypoints,
|
132
|
+
...exports
|
133
|
+
};
|
134
|
+
if (resolvedOutdir === outdir) {
|
135
|
+
resolvedOutdir = _resolvedOutdir;
|
136
|
+
}
|
137
|
+
}
|
138
|
+
if (internalEntrypoints) {
|
139
|
+
const [resolvedInternalEntrypoints, imports, _resolvedOutdir] = resolveExports.resolveExports({
|
140
|
+
entrypoints: internalEntrypoints,
|
141
|
+
defaultOutdir: `${outdir}/.internal`,
|
142
|
+
...commonOptions
|
143
|
+
});
|
144
|
+
newManifest.imports = {
|
145
|
+
...resolvedInternalEntrypoints,
|
146
|
+
...imports
|
147
|
+
};
|
148
|
+
if (resolvedOutdir === outdir) {
|
149
|
+
resolvedOutdir = _resolvedOutdir;
|
150
|
+
}
|
151
|
+
}
|
141
152
|
return [newManifest, resolvedOutdir];
|
142
153
|
};
|
143
154
|
const generateNewPackageJSONString = ({
|
155
|
+
config,
|
144
156
|
oldJSONString,
|
145
157
|
oldJSON,
|
146
158
|
manifest,
|
@@ -165,11 +177,13 @@ async function prepublish({ bumper: bumper$1 } = {}) {
|
|
165
177
|
]
|
166
178
|
}
|
167
179
|
});
|
168
|
-
|
169
|
-
|
170
|
-
"
|
171
|
-
|
172
|
-
|
180
|
+
if (config.experimental?.importsDowngrade) {
|
181
|
+
update(["dependencies", internalModuleName], `file:./${outdir}/.internal`);
|
182
|
+
update(["dependenciesMeta", internalModuleName], {
|
183
|
+
"injected": true
|
184
|
+
});
|
185
|
+
update(["imports"], void 0);
|
186
|
+
}
|
173
187
|
for (const [key, value] of Object.entries(manifest)) {
|
174
188
|
if (key === "version") continue;
|
175
189
|
if (JSON.stringify(value) === JSON.stringify(oldJSON[key])) continue;
|
@@ -270,7 +284,8 @@ async function prepublish({ bumper: bumper$1 } = {}) {
|
|
270
284
|
return newJSONString;
|
271
285
|
};
|
272
286
|
await forEachSelectedProjectsGraphEntries((dir, originalManifest) => {
|
273
|
-
const
|
287
|
+
const config = loadConfig.loadConfig(dir);
|
288
|
+
const [manifest, resolvedOutdir] = generateNewManifest(dir, originalManifest, config);
|
274
289
|
const resolveByDir = (...paths) => path__default.default.resolve(dir, ...paths);
|
275
290
|
const oldJSONString = fs__default.default.readFileSync(resolveByDir("package.json"), "utf-8");
|
276
291
|
const oldJSON = JSON.parse(oldJSONString);
|
@@ -288,6 +303,7 @@ async function prepublish({ bumper: bumper$1 } = {}) {
|
|
288
303
|
jsoncParser.modify(oldJSONString, ["version"], newVersion, { formattingOptions })
|
289
304
|
);
|
290
305
|
const newJSONString = generateNewPackageJSONString({
|
306
|
+
config,
|
291
307
|
oldJSONString: modifyVersionPackageJSON,
|
292
308
|
oldJSON: {
|
293
309
|
...oldJSON,
|
@@ -405,21 +421,14 @@ async function prepublish({ bumper: bumper$1 } = {}) {
|
|
405
421
|
}
|
406
422
|
throw new Error(`file type of ${path2} is not supported`);
|
407
423
|
}
|
408
|
-
if ("imports" in manifest && manifest.imports) {
|
409
|
-
Object.entries(manifest.imports).forEach(([key, value]) => {
|
410
|
-
if (typeof value !== "object") return;
|
411
|
-
const [start] = key.split("*");
|
412
|
-
manifest.imports[key] = JSON.parse(
|
413
|
-
JSON.stringify(value).replaceAll(`${resolvedOutdir}/.internal/`, start)
|
414
|
-
);
|
415
|
-
});
|
424
|
+
if (config.experimental?.importsDowngrade && "imports" in manifest && manifest.imports) {
|
416
425
|
fs__default.default.writeFileSync(
|
417
426
|
resolveByDir(resolvedOutdir, resolvedOutdir, ".internal", "package.json"),
|
418
427
|
JSON.stringify(
|
419
428
|
{
|
420
429
|
name: getInternalModuleName.getInternalModuleName(manifest.name),
|
421
430
|
exports: JSON.parse(
|
422
|
-
JSON.stringify(manifest.imports).replaceAll("#", "./").replaceAll("~", "
|
431
|
+
JSON.stringify(manifest.imports).replaceAll("#", "./").replaceAll("~", "")
|
423
432
|
)
|
424
433
|
},
|
425
434
|
null,
|
@@ -427,6 +436,10 @@ async function prepublish({ bumper: bumper$1 } = {}) {
|
|
427
436
|
)
|
428
437
|
);
|
429
438
|
}
|
439
|
+
const jiekProductionTag = path__default.default.resolve(resolvedOutdir, ".jiek-production-tag");
|
440
|
+
if (!fs__default.default.existsSync(jiekProductionTag)) {
|
441
|
+
fs__default.default.writeFileSync(jiekProductionTag, "");
|
442
|
+
}
|
430
443
|
});
|
431
444
|
}
|
432
445
|
async function postpublish() {
|
package/dist/index.d.cts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { TemplateOptions } from '
|
1
|
+
import { TemplateOptions } from '#~/rollup/base';
|
2
2
|
|
3
3
|
declare module 'jiek' {
|
4
4
|
interface Config {
|
@@ -14,6 +14,13 @@ declare module 'jiek' {
|
|
14
14
|
}
|
15
15
|
|
16
16
|
declare module 'jiek' {
|
17
|
+
interface ConfigExperimental {
|
18
|
+
/**
|
19
|
+
* Polyfill `imports` fields in package.json to local dependencies and exports fields.
|
20
|
+
* @default false
|
21
|
+
*/
|
22
|
+
importsDowngrade?: boolean;
|
23
|
+
}
|
17
24
|
interface Config {
|
18
25
|
publish?: {
|
19
26
|
/**
|
@@ -28,8 +35,11 @@ declare module 'jiek' {
|
|
28
35
|
}
|
29
36
|
}
|
30
37
|
|
38
|
+
interface ConfigExperimental {
|
39
|
+
}
|
31
40
|
interface Config {
|
41
|
+
experimental?: ConfigExperimental;
|
32
42
|
}
|
33
43
|
declare const defineConfig: (config: Config) => Config;
|
34
44
|
|
35
|
-
export { type Config, defineConfig };
|
45
|
+
export { type Config, type ConfigExperimental, defineConfig };
|
package/dist/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { TemplateOptions } from '
|
1
|
+
import { TemplateOptions } from '#~/rollup/base';
|
2
2
|
|
3
3
|
declare module 'jiek' {
|
4
4
|
interface Config {
|
@@ -14,6 +14,13 @@ declare module 'jiek' {
|
|
14
14
|
}
|
15
15
|
|
16
16
|
declare module 'jiek' {
|
17
|
+
interface ConfigExperimental {
|
18
|
+
/**
|
19
|
+
* Polyfill `imports` fields in package.json to local dependencies and exports fields.
|
20
|
+
* @default false
|
21
|
+
*/
|
22
|
+
importsDowngrade?: boolean;
|
23
|
+
}
|
17
24
|
interface Config {
|
18
25
|
publish?: {
|
19
26
|
/**
|
@@ -28,8 +35,11 @@ declare module 'jiek' {
|
|
28
35
|
}
|
29
36
|
}
|
30
37
|
|
38
|
+
interface ConfigExperimental {
|
39
|
+
}
|
31
40
|
interface Config {
|
41
|
+
experimental?: ConfigExperimental;
|
32
42
|
}
|
33
43
|
declare const defineConfig: (config: Config) => Config;
|
34
44
|
|
35
|
-
export { type Config, defineConfig };
|
45
|
+
export { type Config, type ConfigExperimental, defineConfig };
|
package/dist/rollup/index.cjs
CHANGED
@@ -11,14 +11,14 @@ var inject = require('@rollup/plugin-inject');
|
|
11
11
|
var json = require('@rollup/plugin-json');
|
12
12
|
var pluginNodeResolve = require('@rollup/plugin-node-resolve');
|
13
13
|
var ts$1 = require('typescript');
|
14
|
-
var bridge = require('
|
15
|
-
var bundleAnalyzer = require('
|
16
|
-
var getInternalModuleName = require('
|
17
|
-
var intersection = require('
|
18
|
-
var loadConfig = require('
|
19
|
-
var recursiveListFiles = require('
|
20
|
-
var resolveExports = require('
|
21
|
-
var ts = require('
|
14
|
+
var bridge = require('#~/bridge');
|
15
|
+
var bundleAnalyzer = require('#~/rollup/bundle-analyzer');
|
16
|
+
var getInternalModuleName = require('#~/utils/getInternalModuleName');
|
17
|
+
var intersection = require('#~/utils/intersection');
|
18
|
+
var loadConfig = require('#~/utils/loadConfig');
|
19
|
+
var recursiveListFiles = require('#~/utils/recursiveListFiles');
|
20
|
+
var resolveExports = require('#~/utils/resolveExports');
|
21
|
+
var ts = require('#~/utils/ts');
|
22
22
|
var node_module = require('node:module');
|
23
23
|
|
24
24
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
@@ -158,7 +158,7 @@ const MINIFY_OPTIONS = {
|
|
158
158
|
const config = loadConfig.loadConfig({
|
159
159
|
root: WORKSPACE_ROOT
|
160
160
|
}) ?? {};
|
161
|
-
const { build = {} } = config;
|
161
|
+
const { experimental, build = {} } = config;
|
162
162
|
const { js: jsOutdir, dts: dtsOutdir } = resolveExports.getOutDirs({
|
163
163
|
config,
|
164
164
|
pkgName: JIEK_NAME
|
@@ -168,7 +168,7 @@ if (CLEAN) {
|
|
168
168
|
fs__default.default.existsSync(dtsOutdir) && fs__default.default.rmdirSync(dtsOutdir, { recursive: true });
|
169
169
|
}
|
170
170
|
const STYLE_REGEXP = /\.(css|s[ac]ss|less|styl)$/;
|
171
|
-
const CWD_FILES = recursiveListFiles.recursiveListFiles(process__default.default.cwd()).filter((p) => /(?<!\.d)\.[cm]?tsx?$/.test(p)).map((p) => node_path.relative(process__default.default.cwd(), p));
|
171
|
+
const CWD_FILES = recursiveListFiles.recursiveListFiles(process__default.default.cwd()).filter((p) => /(?<!\.d)\.[cm]?tsx?$/.test(p)).map((p) => `./${node_path.relative(process__default.default.cwd(), p)}`);
|
172
172
|
const resolveBuildPlugins = (context, plugins) => {
|
173
173
|
if (plugins === false || plugins === void 0 || plugins === null) {
|
174
174
|
return { js: [], dts: [] };
|
@@ -237,6 +237,9 @@ const withMinify = (output, disableMinify, onlyOncePlugins = []) => {
|
|
237
237
|
entryFileNames: (chunkInfo) => typeof output.entryFileNames === "function" ? output.entryFileNames(chunkInfo).replace(/(\.[cm]?js)$/, ".min$1") : (() => {
|
238
238
|
throw new Error("entryFileNames must be a function");
|
239
239
|
})(),
|
240
|
+
chunkFileNames: (chunkInfo) => typeof output.chunkFileNames === "function" ? output.chunkFileNames(chunkInfo).replace(/(\.[cm]?js)$/, ".min$1") : (() => {
|
241
|
+
throw new Error("chunkFileNames must be a function");
|
242
|
+
})(),
|
240
243
|
file: output.file?.replace(/(\.[cm]?js)$/, ".min$1"),
|
241
244
|
plugins: [
|
242
245
|
...notOnlyOncePlugins,
|
@@ -340,11 +343,11 @@ const generateConfigs = (context, {
|
|
340
343
|
'input should not include "**", please read the [documentation](https://nodejs.org/api/packages.html#subpath-patterns).'
|
341
344
|
);
|
342
345
|
}
|
343
|
-
const reg = new RegExp(
|
346
|
+
const reg = new RegExp(`^./${input.slice(2).replace(/\./g, "\\.").replace(/\*/g, ".*")}$`);
|
344
347
|
const inputObj = !input.includes("*") ? input : CWD_FILES.filter((p) => reg.test(p));
|
345
|
-
const globCommonDir = input.includes("*") ? input.split("*")[0]
|
346
|
-
const
|
347
|
-
if (globCommonDir.length > 0 &&
|
348
|
+
const globCommonDir = input.includes("*") ? input.split("*")[0] : "";
|
349
|
+
const outputCommonDir = output.includes("*") ? output.split("*")[0] : "";
|
350
|
+
if (globCommonDir.length > 0 && outputCommonDir.length === 0 || globCommonDir.length === 0 && outputCommonDir.length > 0) {
|
348
351
|
throw new Error('input and path should both include "*" or not include "*"');
|
349
352
|
}
|
350
353
|
const jsOutputSuffix = node_path.extname(output);
|
@@ -370,9 +373,9 @@ const generateConfigs = (context, {
|
|
370
373
|
if (!resolved || !("id" in resolved)) {
|
371
374
|
throw new Error("nodeResolvePluginInstance.resolveId.handler did not return a resolved object");
|
372
375
|
}
|
373
|
-
internalModuleCollect?.(node_path.relative(process__default.default.cwd(), resolved.id));
|
376
|
+
internalModuleCollect?.(`./${node_path.relative(process__default.default.cwd(), resolved.id)}`);
|
374
377
|
return {
|
375
|
-
id: source.replaceAll("#", `${INTERNAL_MODULE_NAME}/`).replaceAll("~", "+"),
|
378
|
+
id: experimental?.importsDowngrade ? source.replaceAll("#", `${INTERNAL_MODULE_NAME}/`).replaceAll("~", "+") : source,
|
376
379
|
external: true
|
377
380
|
};
|
378
381
|
}
|
@@ -446,7 +449,10 @@ const generateConfigs = (context, {
|
|
446
449
|
name,
|
447
450
|
interop: "auto",
|
448
451
|
entryFileNames: (chunkInfo) => {
|
449
|
-
return Array.isArray(inputObj) ? chunkInfo.facadeModuleId.replace(`${process__default.default.cwd()}/`, "").replace(globCommonDir,
|
452
|
+
return Array.isArray(inputObj) ? chunkInfo.facadeModuleId.replace(`${process__default.default.cwd()}/`, "./").replace(globCommonDir, outputCommonDir).replace(/(\.[cm]?)ts$/, jsOutputSuffix).replace(`${jsOutdir}/`, "") : output.replace(`${jsOutdir}/`, "");
|
453
|
+
},
|
454
|
+
chunkFileNames: (chunkInfo) => {
|
455
|
+
return `.internal/.chunks/${chunkInfo.name}.[hash]${jsOutputSuffix}`;
|
450
456
|
},
|
451
457
|
sourcemap,
|
452
458
|
format,
|
@@ -495,7 +501,7 @@ const generateConfigs = (context, {
|
|
495
501
|
{
|
496
502
|
dir: dtsOutdir,
|
497
503
|
sourcemap,
|
498
|
-
entryFileNames: (chunkInfo) => Array.isArray(inputObj) ? chunkInfo.facadeModuleId.replace(`${process__default.default.cwd()}/`, "").replace(globCommonDir,
|
504
|
+
entryFileNames: (chunkInfo) => Array.isArray(inputObj) ? chunkInfo.facadeModuleId.replace(`${process__default.default.cwd()}/`, "./").replace(globCommonDir, outputCommonDir).replace(/(\.[cm]?)ts$/, tsOutputSuffix).replace(`${jsOutdir}/`, "") : output.replace(/(\.[cm]?)js$/, tsOutputSuffix).replace(`${jsOutdir}/`, ""),
|
499
505
|
strict: typeof buildOptions?.output?.strict === "object" ? buildOptions.output.strict.dts : buildOptions?.output?.strict,
|
500
506
|
externalImportAttributes: features.keepImportAttributes !== false,
|
501
507
|
importAttributesKey
|
@@ -655,22 +661,10 @@ function template(packageJSON) {
|
|
655
661
|
async options(inputOptions) {
|
656
662
|
await collected.promise;
|
657
663
|
inputOptions.input = [...intersection.intersection(
|
658
|
-
inputOptions.input,
|
664
|
+
Array.isArray(inputOptions.input) ? inputOptions.input : [inputOptions.input],
|
659
665
|
internalModules
|
660
666
|
)];
|
661
667
|
return inputOptions;
|
662
|
-
},
|
663
|
-
outputOptions(outputOptions) {
|
664
|
-
outputOptions.dir = `${outputOptions.dir}/.internal`;
|
665
|
-
const oldEntryFileNames = outputOptions.entryFileNames;
|
666
|
-
outputOptions.entryFileNames = (chunkInfo) => {
|
667
|
-
if (typeof oldEntryFileNames !== "function") {
|
668
|
-
throw new TypeError("entryFileNames must be a function");
|
669
|
-
}
|
670
|
-
const oldFileName = oldEntryFileNames(chunkInfo);
|
671
|
-
return oldFileName.replaceAll("#", "").replaceAll("~", "+");
|
672
|
-
};
|
673
|
-
return outputOptions;
|
674
668
|
}
|
675
669
|
}
|
676
670
|
],
|
package/dist/rollup/index.js
CHANGED
@@ -9,14 +9,14 @@ import inject from '@rollup/plugin-inject';
|
|
9
9
|
import json from '@rollup/plugin-json';
|
10
10
|
import { nodeResolve } from '@rollup/plugin-node-resolve';
|
11
11
|
import ts from 'typescript';
|
12
|
-
import { publish } from '
|
13
|
-
import { bundleAnalyzer } from '
|
14
|
-
import { getInternalModuleName } from '
|
15
|
-
import { intersection } from '
|
16
|
-
import { loadConfig } from '
|
17
|
-
import { recursiveListFiles } from '
|
18
|
-
import { getOutDirs, resolveExports } from '
|
19
|
-
import { getCompilerOptionsByFilePath } from '
|
12
|
+
import { publish } from '#~/bridge';
|
13
|
+
import { bundleAnalyzer } from '#~/rollup/bundle-analyzer';
|
14
|
+
import { getInternalModuleName } from '#~/utils/getInternalModuleName';
|
15
|
+
import { intersection } from '#~/utils/intersection';
|
16
|
+
import { loadConfig } from '#~/utils/loadConfig';
|
17
|
+
import { recursiveListFiles } from '#~/utils/recursiveListFiles';
|
18
|
+
import { getOutDirs, resolveExports } from '#~/utils/resolveExports';
|
19
|
+
import { getCompilerOptionsByFilePath } from '#~/utils/ts';
|
20
20
|
import { builtinModules } from 'node:module';
|
21
21
|
|
22
22
|
const CREATE_REQUIRE_VIRTUAL_MODULE_NAME = "jiek:create-require";
|
@@ -147,7 +147,7 @@ const MINIFY_OPTIONS = {
|
|
147
147
|
const config = loadConfig({
|
148
148
|
root: WORKSPACE_ROOT
|
149
149
|
}) ?? {};
|
150
|
-
const { build = {} } = config;
|
150
|
+
const { experimental, build = {} } = config;
|
151
151
|
const { js: jsOutdir, dts: dtsOutdir } = getOutDirs({
|
152
152
|
config,
|
153
153
|
pkgName: JIEK_NAME
|
@@ -157,7 +157,7 @@ if (CLEAN) {
|
|
157
157
|
fs.existsSync(dtsOutdir) && fs.rmdirSync(dtsOutdir, { recursive: true });
|
158
158
|
}
|
159
159
|
const STYLE_REGEXP = /\.(css|s[ac]ss|less|styl)$/;
|
160
|
-
const CWD_FILES = recursiveListFiles(process.cwd()).filter((p) => /(?<!\.d)\.[cm]?tsx?$/.test(p)).map((p) => relative(process.cwd(), p));
|
160
|
+
const CWD_FILES = recursiveListFiles(process.cwd()).filter((p) => /(?<!\.d)\.[cm]?tsx?$/.test(p)).map((p) => `./${relative(process.cwd(), p)}`);
|
161
161
|
const resolveBuildPlugins = (context, plugins) => {
|
162
162
|
if (plugins === false || plugins === void 0 || plugins === null) {
|
163
163
|
return { js: [], dts: [] };
|
@@ -226,6 +226,9 @@ const withMinify = (output, disableMinify, onlyOncePlugins = []) => {
|
|
226
226
|
entryFileNames: (chunkInfo) => typeof output.entryFileNames === "function" ? output.entryFileNames(chunkInfo).replace(/(\.[cm]?js)$/, ".min$1") : (() => {
|
227
227
|
throw new Error("entryFileNames must be a function");
|
228
228
|
})(),
|
229
|
+
chunkFileNames: (chunkInfo) => typeof output.chunkFileNames === "function" ? output.chunkFileNames(chunkInfo).replace(/(\.[cm]?js)$/, ".min$1") : (() => {
|
230
|
+
throw new Error("chunkFileNames must be a function");
|
231
|
+
})(),
|
229
232
|
file: output.file?.replace(/(\.[cm]?js)$/, ".min$1"),
|
230
233
|
plugins: [
|
231
234
|
...notOnlyOncePlugins,
|
@@ -329,11 +332,11 @@ const generateConfigs = (context, {
|
|
329
332
|
'input should not include "**", please read the [documentation](https://nodejs.org/api/packages.html#subpath-patterns).'
|
330
333
|
);
|
331
334
|
}
|
332
|
-
const reg = new RegExp(
|
335
|
+
const reg = new RegExp(`^./${input.slice(2).replace(/\./g, "\\.").replace(/\*/g, ".*")}$`);
|
333
336
|
const inputObj = !input.includes("*") ? input : CWD_FILES.filter((p) => reg.test(p));
|
334
|
-
const globCommonDir = input.includes("*") ? input.split("*")[0]
|
335
|
-
const
|
336
|
-
if (globCommonDir.length > 0 &&
|
337
|
+
const globCommonDir = input.includes("*") ? input.split("*")[0] : "";
|
338
|
+
const outputCommonDir = output.includes("*") ? output.split("*")[0] : "";
|
339
|
+
if (globCommonDir.length > 0 && outputCommonDir.length === 0 || globCommonDir.length === 0 && outputCommonDir.length > 0) {
|
337
340
|
throw new Error('input and path should both include "*" or not include "*"');
|
338
341
|
}
|
339
342
|
const jsOutputSuffix = extname(output);
|
@@ -359,9 +362,9 @@ const generateConfigs = (context, {
|
|
359
362
|
if (!resolved || !("id" in resolved)) {
|
360
363
|
throw new Error("nodeResolvePluginInstance.resolveId.handler did not return a resolved object");
|
361
364
|
}
|
362
|
-
internalModuleCollect?.(relative(process.cwd(), resolved.id));
|
365
|
+
internalModuleCollect?.(`./${relative(process.cwd(), resolved.id)}`);
|
363
366
|
return {
|
364
|
-
id: source.replaceAll("#", `${INTERNAL_MODULE_NAME}/`).replaceAll("~", "+"),
|
367
|
+
id: experimental?.importsDowngrade ? source.replaceAll("#", `${INTERNAL_MODULE_NAME}/`).replaceAll("~", "+") : source,
|
365
368
|
external: true
|
366
369
|
};
|
367
370
|
}
|
@@ -435,7 +438,10 @@ const generateConfigs = (context, {
|
|
435
438
|
name,
|
436
439
|
interop: "auto",
|
437
440
|
entryFileNames: (chunkInfo) => {
|
438
|
-
return Array.isArray(inputObj) ? chunkInfo.facadeModuleId.replace(`${process.cwd()}/`, "").replace(globCommonDir,
|
441
|
+
return Array.isArray(inputObj) ? chunkInfo.facadeModuleId.replace(`${process.cwd()}/`, "./").replace(globCommonDir, outputCommonDir).replace(/(\.[cm]?)ts$/, jsOutputSuffix).replace(`${jsOutdir}/`, "") : output.replace(`${jsOutdir}/`, "");
|
442
|
+
},
|
443
|
+
chunkFileNames: (chunkInfo) => {
|
444
|
+
return `.internal/.chunks/${chunkInfo.name}.[hash]${jsOutputSuffix}`;
|
439
445
|
},
|
440
446
|
sourcemap,
|
441
447
|
format,
|
@@ -484,7 +490,7 @@ const generateConfigs = (context, {
|
|
484
490
|
{
|
485
491
|
dir: dtsOutdir,
|
486
492
|
sourcemap,
|
487
|
-
entryFileNames: (chunkInfo) => Array.isArray(inputObj) ? chunkInfo.facadeModuleId.replace(`${process.cwd()}/`, "").replace(globCommonDir,
|
493
|
+
entryFileNames: (chunkInfo) => Array.isArray(inputObj) ? chunkInfo.facadeModuleId.replace(`${process.cwd()}/`, "./").replace(globCommonDir, outputCommonDir).replace(/(\.[cm]?)ts$/, tsOutputSuffix).replace(`${jsOutdir}/`, "") : output.replace(/(\.[cm]?)js$/, tsOutputSuffix).replace(`${jsOutdir}/`, ""),
|
488
494
|
strict: typeof buildOptions?.output?.strict === "object" ? buildOptions.output.strict.dts : buildOptions?.output?.strict,
|
489
495
|
externalImportAttributes: features.keepImportAttributes !== false,
|
490
496
|
importAttributesKey
|
@@ -644,22 +650,10 @@ function template(packageJSON) {
|
|
644
650
|
async options(inputOptions) {
|
645
651
|
await collected.promise;
|
646
652
|
inputOptions.input = [...intersection(
|
647
|
-
inputOptions.input,
|
653
|
+
Array.isArray(inputOptions.input) ? inputOptions.input : [inputOptions.input],
|
648
654
|
internalModules
|
649
655
|
)];
|
650
656
|
return inputOptions;
|
651
|
-
},
|
652
|
-
outputOptions(outputOptions) {
|
653
|
-
outputOptions.dir = `${outputOptions.dir}/.internal`;
|
654
|
-
const oldEntryFileNames = outputOptions.entryFileNames;
|
655
|
-
outputOptions.entryFileNames = (chunkInfo) => {
|
656
|
-
if (typeof oldEntryFileNames !== "function") {
|
657
|
-
throw new TypeError("entryFileNames must be a function");
|
658
|
-
}
|
659
|
-
const oldFileName = oldEntryFileNames(chunkInfo);
|
660
|
-
return oldFileName.replaceAll("#", "").replaceAll("~", "+");
|
661
|
-
};
|
662
|
-
return outputOptions;
|
663
657
|
}
|
664
658
|
}
|
665
659
|
],
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "jiek",
|
3
3
|
"type": "module",
|
4
|
-
"version": "2.2.7-alpha.
|
4
|
+
"version": "2.2.7-alpha.4",
|
5
5
|
"description": "A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.",
|
6
6
|
"author": "YiJie <yijie4188@gmail.com>",
|
7
7
|
"homepage": "https://github.com/NWYLZW/jiek/tree/master/packages/jiek#readme",
|
@@ -37,6 +37,13 @@
|
|
37
37
|
"default": "./dist/rollup/index.js"
|
38
38
|
}
|
39
39
|
},
|
40
|
+
"imports": {
|
41
|
+
"#~/*": {
|
42
|
+
"jiek/__source__": "./src/*.ts",
|
43
|
+
"require": "./dist/.internal/*.cjs",
|
44
|
+
"default": "./dist/.internal/*.js"
|
45
|
+
}
|
46
|
+
},
|
40
47
|
"bin": {
|
41
48
|
"jiek": "bin/index.cjs",
|
42
49
|
"jk": "bin/index.cjs",
|
@@ -69,14 +76,11 @@
|
|
69
76
|
"jsonc-parser": "^3.2.1",
|
70
77
|
"koa": "^2.15.3",
|
71
78
|
"rollup": "^4.0.0",
|
72
|
-
"@jiek/__internal__": "file:./dist/.internal",
|
73
79
|
"@jiek/pkger": "^0.2.1",
|
74
80
|
"@jiek/utils": "^0.2.3"
|
75
81
|
},
|
76
|
-
"
|
77
|
-
"
|
78
|
-
"injected": true
|
79
|
-
}
|
82
|
+
"publishConfig": {
|
83
|
+
"directory": "./dist/.internal"
|
80
84
|
},
|
81
85
|
"peerDependenciesMeta": {
|
82
86
|
"@pnpm/filter-workspace-packages": {
|
@@ -108,7 +112,7 @@
|
|
108
112
|
}
|
109
113
|
},
|
110
114
|
"scripts": {
|
111
|
-
"prepublish": "
|
115
|
+
"prepublish": "jb -nm && jk",
|
112
116
|
"test": "vitest run"
|
113
117
|
},
|
114
118
|
"typesVersions": {
|
@@ -124,12 +128,5 @@
|
|
124
128
|
},
|
125
129
|
"main": "./dist/index.cjs",
|
126
130
|
"module": "./dist/index.js",
|
127
|
-
"types": "./dist/index.d.ts"
|
128
|
-
"imports": {
|
129
|
-
"#~/*": {
|
130
|
-
"jiek/__source__": "./src/*.ts",
|
131
|
-
"require": "./dist/.internal/*.cjs",
|
132
|
-
"default": "./dist/.internal/*.js"
|
133
|
-
}
|
134
|
-
}
|
131
|
+
"types": "./dist/index.d.ts"
|
135
132
|
}
|
package/src/bin/build.cts
CHANGED
@@ -1,11 +1,5 @@
|
|
1
|
-
import '
|
2
|
-
import '../commands/base'
|
3
|
-
import '../commands/build'
|
4
|
-
|
5
|
-
import process from 'node:process'
|
1
|
+
import '#~/bin/common'
|
6
2
|
|
7
3
|
import parseArgv from '#~/bin/parseArgv'
|
8
4
|
|
9
|
-
|
10
|
-
parseArgv()
|
11
|
-
}
|
5
|
+
parseArgv()
|
package/src/bin/index.cts
CHANGED
package/src/commands/build.ts
CHANGED
@@ -23,7 +23,7 @@ import { loadConfig } from '#~/utils/loadConfig'
|
|
23
23
|
import { tsRegisterName } from '#~/utils/tsRegister'
|
24
24
|
|
25
25
|
declare module 'jiek' {
|
26
|
-
|
26
|
+
interface Config {
|
27
27
|
build?: TemplateOptions & {
|
28
28
|
/**
|
29
29
|
* Whether to run in silent mode, only active when configured in the workspace root or cwd.
|
@@ -150,7 +150,7 @@ let command = isDefault
|
|
150
150
|
command = command
|
151
151
|
.description(description)
|
152
152
|
.option('-t, --type <TYPE>', `The type of build, support ${BUILDER_TYPES.map(s => `"${s}"`).join(', ')}.`, v => {
|
153
|
-
if (!BUILDER_TYPES.includes(v as
|
153
|
+
if (!BUILDER_TYPES.includes(v as typeof BUILDER_TYPES[number])) {
|
154
154
|
throw new Error(`The value of 'type' must be ${BUILDER_TYPES.map(s => `"${s}"`).join(', ')}`)
|
155
155
|
}
|
156
156
|
return String(v)
|
@@ -306,7 +306,13 @@ command
|
|
306
306
|
const resolveByJiekTemp = (...paths: string[]) => path.resolve(wdNodeModules, '.jiek', ...paths)
|
307
307
|
const jiekTemp = resolveByJiekTemp()
|
308
308
|
if (!existsSync(jiekTemp)) {
|
309
|
-
|
309
|
+
try {
|
310
|
+
mkdirSync(jiekTemp)
|
311
|
+
} catch (e) {
|
312
|
+
if ((e as { code: string }).code !== 'EEXIST') {
|
313
|
+
throw e
|
314
|
+
}
|
315
|
+
}
|
310
316
|
}
|
311
317
|
|
312
318
|
let i = 0
|