jiek 2.2.7-alpha.1 → 2.2.7-alpha.3
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/bin-helper/index.cjs +1 -1
- package/dist/.internal/{getWD-Cmxzjf-f.js → .chunks/getWD.D6wq8Qc2.js} +2 -2
- package/dist/.internal/{getWD-BRJ3PK1S.js → .chunks/getWD.ZF0avqDB.cjs} +2 -2
- package/dist/.internal/{+/commands → commands}/build/analyzer.cjs +2 -2
- package/dist/.internal/{+/commands → commands}/build/analyzer.js +2 -2
- package/dist/.internal/{+/commands → commands}/meta.cjs +2 -2
- package/dist/.internal/{+/commands → commands}/meta.js +2 -2
- package/dist/.internal/{+/utils → utils}/checkDependency.cjs +2 -2
- package/dist/.internal/{+/utils → utils}/checkDependency.js +2 -2
- package/dist/.internal/{+/utils → utils}/filterSupport.cjs +2 -2
- package/dist/.internal/{+/utils → utils}/filterSupport.js +2 -2
- package/dist/.internal/{+/utils → utils}/getWD.cjs +2 -2
- package/dist/.internal/{+/utils → utils}/getWD.js +2 -2
- package/dist/.internal/{+/utils → utils}/loadConfig.cjs +2 -2
- package/dist/.internal/{+/utils → utils}/loadConfig.js +2 -2
- 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/.internal/{+/utils → utils}/tsRegister.cjs +1 -1
- package/dist/.internal/{+/utils → utils}/tsRegister.js +1 -1
- package/dist/bin/build.cjs +27 -17
- package/dist/bin/index.cjs +51 -42
- 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/commands/build.ts +9 -3
- package/src/commands/publish.ts +57 -39
- package/src/index.ts +6 -1
- package/src/rollup/index.ts +36 -33
- 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/{jiek_create-require-CWFWNQHj.js → .chunks/jiek_create-require.CWFWNQHj.cjs} +0 -0
- /package/dist/.internal/{jiek_create-require-CxSGbkTB.js → .chunks/jiek_create-require.CxSGbkTB.js} +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/{+/commands → commands}/build/analyzer.d.cts +0 -0
- /package/dist/.internal/{+/commands → commands}/build/analyzer.d.ts +0 -0
- /package/dist/.internal/{+/commands → commands}/descriptions.cjs +0 -0
- /package/dist/.internal/{+/commands → commands}/descriptions.d.cts +0 -0
- /package/dist/.internal/{+/commands → commands}/descriptions.d.ts +0 -0
- /package/dist/.internal/{+/commands → commands}/descriptions.js +0 -0
- /package/dist/.internal/{+/commands → commands}/meta.d.cts +0 -0
- /package/dist/.internal/{+/commands → commands}/meta.d.ts +0 -0
- /package/dist/.internal/{+/commands → commands}/utils/optionParser.cjs +0 -0
- /package/dist/.internal/{+/commands → commands}/utils/optionParser.d.cts +0 -0
- /package/dist/.internal/{+/commands → commands}/utils/optionParser.d.ts +0 -0
- /package/dist/.internal/{+/commands → commands}/utils/optionParser.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/{+/server.cjs → server.cjs} +0 -0
- /package/dist/.internal/{+/server.d.cts → server.d.cts} +0 -0
- /package/dist/.internal/{+/server.d.ts → server.d.ts} +0 -0
- /package/dist/.internal/{+/server.js → server.js} +0 -0
- /package/dist/.internal/{+/utils → utils}/checkDependency.d.cts +0 -0
- /package/dist/.internal/{+/utils → utils}/checkDependency.d.ts +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}/getRoot.cjs +0 -0
- /package/dist/.internal/{+/utils → utils}/getRoot.d.cts +0 -0
- /package/dist/.internal/{+/utils → utils}/getRoot.d.ts +0 -0
- /package/dist/.internal/{+/utils → utils}/getRoot.js +0 -0
- /package/dist/.internal/{+/utils → utils}/getWD.d.cts +0 -0
- /package/dist/.internal/{+/utils → utils}/getWD.d.ts +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/.internal/{+/utils → utils}/tsRegister.d.cts +0 -0
- /package/dist/.internal/{+/utils → utils}/tsRegister.d.ts +0 -0
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.3",
|
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/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
|
package/src/commands/publish.ts
CHANGED
@@ -7,6 +7,7 @@ import process from 'node:process'
|
|
7
7
|
import { type BumperType, TAGS, bump } from '@jiek/utils/bumper'
|
8
8
|
import { program } from 'commander'
|
9
9
|
import detectIndent from 'detect-indent'
|
10
|
+
import type { Config } from 'jiek'
|
10
11
|
import type { JSONPath } from 'jsonc-parser'
|
11
12
|
import { applyEdits, modify } from 'jsonc-parser'
|
12
13
|
|
@@ -20,6 +21,13 @@ import { getInternalModuleName } from '#~/utils/getInternalModuleName'
|
|
20
21
|
import { outdirDescription } from './descriptions'
|
21
22
|
|
22
23
|
declare module 'jiek' {
|
24
|
+
interface ConfigExperimental {
|
25
|
+
/**
|
26
|
+
* Polyfill `imports` fields in package.json to local dependencies and exports fields.
|
27
|
+
* @default false
|
28
|
+
*/
|
29
|
+
importsDowngrade?: boolean
|
30
|
+
}
|
23
31
|
export interface Config {
|
24
32
|
publish?: {
|
25
33
|
/**
|
@@ -111,12 +119,16 @@ async function prepublish({ bumper }: {
|
|
111
119
|
bumperEnv ? JSON.parse(bumperEnv) as string | boolean : false
|
112
120
|
)
|
113
121
|
|
114
|
-
const generateNewManifest = (
|
122
|
+
const generateNewManifest = (
|
123
|
+
dir: string,
|
124
|
+
manifest: NonNullable<ProjectsGraph['value']>[string],
|
125
|
+
config: Config
|
126
|
+
) => {
|
115
127
|
const {
|
116
128
|
name,
|
117
129
|
type,
|
118
|
-
exports: entrypoints
|
119
|
-
imports: internalEntrypoints
|
130
|
+
exports: entrypoints,
|
131
|
+
imports: internalEntrypoints
|
120
132
|
} = manifest
|
121
133
|
if (!name) {
|
122
134
|
throw new Error(`package.json in ${dir} must have a name field`)
|
@@ -127,38 +139,51 @@ async function prepublish({ bumper }: {
|
|
127
139
|
const commonOptions = {
|
128
140
|
pkgIsModule,
|
129
141
|
pkgName: name,
|
130
|
-
config
|
142
|
+
config,
|
131
143
|
dir,
|
132
144
|
noFilter: true,
|
133
145
|
isPublish: true
|
134
146
|
} satisfies Partial<ResolveExportsOptions>
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
147
|
+
let resolvedOutdir = outdir
|
148
|
+
if (entrypoints) {
|
149
|
+
const [resolvedEntrypoints, exports, _resolvedOutdir] = resolveExports({
|
150
|
+
entrypoints,
|
151
|
+
defaultOutdir: outdir,
|
152
|
+
...commonOptions
|
153
|
+
})
|
154
|
+
newManifest.exports = {
|
155
|
+
...resolvedEntrypoints,
|
156
|
+
...exports
|
157
|
+
}
|
158
|
+
if (resolvedOutdir === outdir) {
|
159
|
+
resolvedOutdir = _resolvedOutdir
|
160
|
+
}
|
143
161
|
}
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
162
|
+
if (internalEntrypoints) {
|
163
|
+
const [resolvedInternalEntrypoints, imports, _resolvedOutdir] = resolveExports({
|
164
|
+
entrypoints: internalEntrypoints,
|
165
|
+
defaultOutdir: `${outdir}/.internal`,
|
166
|
+
...commonOptions
|
167
|
+
})
|
168
|
+
newManifest.imports = {
|
169
|
+
...resolvedInternalEntrypoints,
|
170
|
+
...imports
|
171
|
+
}
|
172
|
+
if (resolvedOutdir === outdir) {
|
173
|
+
resolvedOutdir = _resolvedOutdir
|
174
|
+
}
|
152
175
|
}
|
153
176
|
return [newManifest, resolvedOutdir] as const
|
154
177
|
}
|
155
178
|
|
156
179
|
const generateNewPackageJSONString = ({
|
180
|
+
config,
|
157
181
|
oldJSONString,
|
158
182
|
oldJSON,
|
159
183
|
manifest,
|
160
184
|
formattingOptions
|
161
185
|
}: {
|
186
|
+
config: Config
|
162
187
|
oldJSONString: string
|
163
188
|
oldJSON: Record<string, unknown>
|
164
189
|
manifest: NonNullable<ProjectsGraph['value']>[string]
|
@@ -188,11 +213,13 @@ async function prepublish({ bumper }: {
|
|
188
213
|
]
|
189
214
|
}
|
190
215
|
})
|
191
|
-
|
192
|
-
|
193
|
-
'
|
194
|
-
|
195
|
-
|
216
|
+
if (config.experimental?.importsDowngrade) {
|
217
|
+
update(['dependencies', internalModuleName], `file:./${outdir}/.internal`)
|
218
|
+
update(['dependenciesMeta', internalModuleName], {
|
219
|
+
'injected': true
|
220
|
+
})
|
221
|
+
update(['imports'], undefined)
|
222
|
+
}
|
196
223
|
|
197
224
|
for (const [key, value] of Object.entries(manifest)) {
|
198
225
|
if (key === 'version') continue
|
@@ -301,7 +328,8 @@ async function prepublish({ bumper }: {
|
|
301
328
|
}
|
302
329
|
|
303
330
|
await forEachSelectedProjectsGraphEntries((dir, originalManifest) => {
|
304
|
-
const
|
331
|
+
const config = loadConfig(dir)
|
332
|
+
const [manifest, resolvedOutdir] = generateNewManifest(dir, originalManifest, config)
|
305
333
|
const resolveByDir = (...paths: string[]) => path.resolve(dir, ...paths)
|
306
334
|
|
307
335
|
const oldJSONString = fs.readFileSync(resolveByDir('package.json'), 'utf-8')
|
@@ -326,6 +354,7 @@ async function prepublish({ bumper }: {
|
|
326
354
|
)
|
327
355
|
|
328
356
|
const newJSONString = generateNewPackageJSONString({
|
357
|
+
config,
|
329
358
|
oldJSONString: modifyVersionPackageJSON,
|
330
359
|
oldJSON: {
|
331
360
|
...oldJSON,
|
@@ -467,18 +496,7 @@ async function prepublish({ bumper }: {
|
|
467
496
|
throw new Error(`file type of ${path} is not supported`)
|
468
497
|
}
|
469
498
|
|
470
|
-
if ('imports' in manifest && manifest.imports) {
|
471
|
-
Object
|
472
|
-
.entries(manifest.imports)
|
473
|
-
.forEach(([key, value]) => {
|
474
|
-
if (typeof value !== 'object') return
|
475
|
-
const [start] = key.split('*')
|
476
|
-
manifest.imports![key] = JSON.parse(
|
477
|
-
JSON
|
478
|
-
.stringify(value)
|
479
|
-
.replaceAll(`${resolvedOutdir}/.internal/`, start)
|
480
|
-
)
|
481
|
-
})
|
499
|
+
if (config.experimental?.importsDowngrade && 'imports' in manifest && manifest.imports) {
|
482
500
|
fs.writeFileSync(
|
483
501
|
resolveByDir(resolvedOutdir, resolvedOutdir, '.internal', 'package.json'),
|
484
502
|
JSON.stringify(
|
@@ -488,7 +506,7 @@ async function prepublish({ bumper }: {
|
|
488
506
|
JSON
|
489
507
|
.stringify(manifest.imports)
|
490
508
|
.replaceAll('#', './')
|
491
|
-
.replaceAll('~', '
|
509
|
+
.replaceAll('~', '')
|
492
510
|
) as Record<string, unknown>
|
493
511
|
},
|
494
512
|
null,
|
package/src/index.ts
CHANGED
@@ -2,6 +2,11 @@ import type {} from './commands/base'
|
|
2
2
|
import type {} from './commands/build'
|
3
3
|
import type {} from './commands/publish'
|
4
4
|
|
5
|
-
export interface
|
5
|
+
export interface ConfigExperimental {
|
6
|
+
}
|
7
|
+
|
8
|
+
export interface Config {
|
9
|
+
experimental?: ConfigExperimental
|
10
|
+
}
|
6
11
|
|
7
12
|
export const defineConfig = (config: Config) => config
|