jiek 2.2.3 → 2.2.5-alpha.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/bin-helper/package.json +1 -0
- package/cli/package.json +1 -0
- package/cli-only-build/package.json +1 -0
- package/dist/cli-only-build.cjs +31 -31
- package/dist/cli-only-build.d.cts +24 -0
- package/dist/cli-only-build.d.ts +24 -0
- package/dist/cli-only-build.js +33 -31
- package/dist/cli.cjs +79 -49
- package/dist/cli.js +79 -47
- package/dist/index.d.cts +24 -0
- package/dist/index.d.ts +24 -0
- package/dist/rollup/index.cjs +67 -64
- package/dist/rollup/index.js +65 -60
- package/package.json +3 -4
- package/rollup/package.json +1 -1
- package/src/commands/build.ts +10 -12
- package/src/commands/publish.ts +69 -33
- package/src/rollup/base.ts +24 -0
- package/src/rollup/index.ts +34 -9
- package/src/rollup/plugins/create-require.ts +14 -65
- package/src/utils/checkDependency.ts +8 -4
- package/src/utils/filterSupport.ts +1 -3
- package/src/utils/getExports.ts +33 -18
- package/src/utils/loadConfig.ts +0 -3
- package/src/utils/tsRegister.ts +0 -4
package/dist/rollup/index.cjs
CHANGED
@@ -7,32 +7,29 @@ var entrypoints = require('@jiek/pkger/entrypoints');
|
|
7
7
|
var rollupPluginDts = require('@jiek/rollup-plugin-dts');
|
8
8
|
var getWorkspaceDir = require('@jiek/utils/getWorkspaceDir');
|
9
9
|
var commonjs = require('@rollup/plugin-commonjs');
|
10
|
+
var inject = require('@rollup/plugin-inject');
|
10
11
|
var json = require('@rollup/plugin-json');
|
11
12
|
var pluginNodeResolve = require('@rollup/plugin-node-resolve');
|
12
13
|
var require$$0 = require('util');
|
13
14
|
var require$$0$1 = require('path');
|
14
15
|
var ts = require('typescript');
|
15
16
|
var execa = require('execa');
|
16
|
-
var node_module = require('node:module');
|
17
17
|
var commander = require('commander');
|
18
18
|
var jsYaml = require('js-yaml');
|
19
19
|
var jsoncParser = require('jsonc-parser');
|
20
|
-
var
|
21
|
-
var replace = require('@rollup/plugin-replace');
|
20
|
+
var node_module = require('node:module');
|
22
21
|
|
23
|
-
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
24
22
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
25
23
|
|
26
24
|
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
27
25
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
28
26
|
var process__default = /*#__PURE__*/_interopDefault(process$1);
|
29
27
|
var commonjs__default = /*#__PURE__*/_interopDefault(commonjs);
|
28
|
+
var inject__default = /*#__PURE__*/_interopDefault(inject);
|
30
29
|
var json__default = /*#__PURE__*/_interopDefault(json);
|
31
30
|
var require$$0__default = /*#__PURE__*/_interopDefault(require$$0);
|
32
31
|
var require$$0__default$1 = /*#__PURE__*/_interopDefault(require$$0$1);
|
33
32
|
var ts__default = /*#__PURE__*/_interopDefault(ts);
|
34
|
-
var inject__default = /*#__PURE__*/_interopDefault(inject);
|
35
|
-
var replace__default = /*#__PURE__*/_interopDefault(replace);
|
36
33
|
|
37
34
|
var utils$1 = {};
|
38
35
|
|
@@ -4188,11 +4185,13 @@ function bundleAnalyzer(modulesResolved) {
|
|
4188
4185
|
|
4189
4186
|
const intersection = (a, b) => new Set([...a].filter((i) => b.has(i)));
|
4190
4187
|
const {
|
4191
|
-
JIEK_OUT_DIR
|
4192
|
-
|
4188
|
+
JIEK_OUT_DIR,
|
4189
|
+
JIEK_CROSS_MODULE_CONVERTOR
|
4190
|
+
} = process__default.default.env;
|
4193
4191
|
const OUTDIR = JIEK_OUT_DIR ?? "dist";
|
4192
|
+
const crossModuleConvertorDefault = JIEK_CROSS_MODULE_CONVERTOR === void 0 ? true : JIEK_CROSS_MODULE_CONVERTOR === "true";
|
4194
4193
|
function getOutDirs({
|
4195
|
-
cwd =
|
4194
|
+
cwd = process__default.default.cwd(),
|
4196
4195
|
defaultOutdir = OUTDIR,
|
4197
4196
|
config,
|
4198
4197
|
pkgName
|
@@ -4232,7 +4231,7 @@ function getExports({
|
|
4232
4231
|
} = {}
|
4233
4232
|
} = config ?? {};
|
4234
4233
|
const {
|
4235
|
-
crossModuleConvertor =
|
4234
|
+
crossModuleConvertor = crossModuleConvertorDefault
|
4236
4235
|
} = build;
|
4237
4236
|
const [, resolvedEntrypoints] = entrypoints.resolveEntrypoints(entrypoints$1);
|
4238
4237
|
if (entries) {
|
@@ -4253,14 +4252,24 @@ function getExports({
|
|
4253
4252
|
}
|
4254
4253
|
);
|
4255
4254
|
const crossModuleWithConditional = crossModuleConvertor ? {
|
4256
|
-
import: (opts) =>
|
4257
|
-
|
4258
|
-
|
4259
|
-
|
4260
|
-
|
4261
|
-
|
4262
|
-
|
4263
|
-
|
4255
|
+
import: (opts) => {
|
4256
|
+
if (pkgIsModule) return false;
|
4257
|
+
if (opts.src.endsWith(".cts")) return false;
|
4258
|
+
if (intersection(
|
4259
|
+
new Set(opts.conditionals),
|
4260
|
+
/* @__PURE__ */ new Set(["import", "module"])
|
4261
|
+
).size !== 0) return false;
|
4262
|
+
return opts.dist.replace(/\.js$/, ".mjs");
|
4263
|
+
},
|
4264
|
+
require: (opts) => {
|
4265
|
+
if (!pkgIsModule) return false;
|
4266
|
+
if (opts.src.endsWith(".mts")) return false;
|
4267
|
+
if (intersection(
|
4268
|
+
new Set(opts.conditionals),
|
4269
|
+
/* @__PURE__ */ new Set(["require", "node"])
|
4270
|
+
).size !== 0) return false;
|
4271
|
+
return opts.dist.replace(/\.js$/, ".cjs");
|
4272
|
+
}
|
4264
4273
|
} : {};
|
4265
4274
|
return [
|
4266
4275
|
filteredResolvedEntrypoints,
|
@@ -4277,6 +4286,8 @@ function getExports({
|
|
4277
4286
|
];
|
4278
4287
|
}
|
4279
4288
|
|
4289
|
+
var require$1 = require;
|
4290
|
+
|
4280
4291
|
let root;
|
4281
4292
|
function getRoot() {
|
4282
4293
|
if (root) return root;
|
@@ -4287,7 +4298,6 @@ function getRoot() {
|
|
4287
4298
|
|
4288
4299
|
let type = "";
|
4289
4300
|
try {
|
4290
|
-
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('rollup/index.cjs', document.baseURI).href)));
|
4291
4301
|
require$1.resolve("@pnpm/filter-workspace-packages");
|
4292
4302
|
type = "pnpm";
|
4293
4303
|
} catch {
|
@@ -4317,10 +4327,9 @@ function getWD() {
|
|
4317
4327
|
return { wd, notWorkspace };
|
4318
4328
|
}
|
4319
4329
|
|
4320
|
-
const require$2 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('rollup/index.cjs', document.baseURI).href)));
|
4321
4330
|
function packageIsExist(name) {
|
4322
4331
|
try {
|
4323
|
-
require$
|
4332
|
+
require$1.resolve(name);
|
4324
4333
|
return true;
|
4325
4334
|
} catch (e) {
|
4326
4335
|
return false;
|
@@ -4340,7 +4349,6 @@ for (const register of registers) {
|
|
4340
4349
|
}
|
4341
4350
|
}
|
4342
4351
|
|
4343
|
-
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('rollup/index.cjs', document.baseURI).href)));
|
4344
4352
|
let configName = "jiek.config";
|
4345
4353
|
function getConfigPath(root, dir) {
|
4346
4354
|
const isSupportTsLoader = !!tsRegisterName;
|
@@ -4470,8 +4478,8 @@ const getCompilerOptionsByFilePath = (tsconfigPath, filePath) => {
|
|
4470
4478
|
if (exclude.length > 0 && exclude.some((i) => micromatchExports.isMatch(filePath, i))) return;
|
4471
4479
|
if (tsconfig.files?.length === 0 && tsconfig.include?.length === 0) return;
|
4472
4480
|
let isInclude = false;
|
4473
|
-
isInclude
|
4474
|
-
isInclude
|
4481
|
+
isInclude || (isInclude = files.length > 0 && files.includes(filePath));
|
4482
|
+
isInclude || (isInclude = include.length > 0 && include.some((i) => micromatchExports.isMatch(filePath, i)));
|
4475
4483
|
if (isInclude) {
|
4476
4484
|
return tsconfig.compilerOptions ?? {};
|
4477
4485
|
} else {
|
@@ -4485,43 +4493,16 @@ const getCompilerOptionsByFilePath = (tsconfigPath, filePath) => {
|
|
4485
4493
|
return tsconfig.compilerOptions;
|
4486
4494
|
};
|
4487
4495
|
|
4488
|
-
const
|
4489
|
-
const
|
4490
|
-
|
4491
|
-
|
4492
|
-
|
4493
|
-
export default (
|
4494
|
-
${isEsmVariableName}
|
4495
|
-
? /* @__PURE__ */ createRequire(import.meta.url)
|
4496
|
-
: require
|
4497
|
-
)
|
4496
|
+
const CREATE_REQUIRE_VIRTUAL_MODULE_NAME = "jiek:create-require";
|
4497
|
+
const INSERT_STR = (isESM) => `
|
4498
|
+
${isESM ? `import { createRequire } from 'node:module'` : ""}
|
4499
|
+
export default ${isESM ? "/* @__PURE__ */ createRequire(import.meta.url)" : "require"}
|
4498
4500
|
`.trim();
|
4499
|
-
var createRequire = () => ({
|
4500
|
-
...inject__default.default({
|
4501
|
-
require: virtualModuleName
|
4502
|
-
}),
|
4501
|
+
var createRequire = (isEsm) => ({
|
4503
4502
|
name: "create-require",
|
4504
|
-
resolveId: (
|
4505
|
-
load: (id) =>
|
4506
|
-
if (id !== virtualModuleName) {
|
4507
|
-
return null;
|
4508
|
-
}
|
4509
|
-
return INSERT_STR;
|
4510
|
-
}
|
4503
|
+
resolveId: (id) => id === CREATE_REQUIRE_VIRTUAL_MODULE_NAME ? id : null,
|
4504
|
+
load: (id) => id === CREATE_REQUIRE_VIRTUAL_MODULE_NAME ? INSERT_STR(isEsm) : null
|
4511
4505
|
});
|
4512
|
-
const isFormatEsm = (isEsm) => {
|
4513
|
-
const handler = replace__default.default({
|
4514
|
-
[isEsmVariableName]: isEsm
|
4515
|
-
}).renderChunk;
|
4516
|
-
return {
|
4517
|
-
name: "create-require-insert-format",
|
4518
|
-
// Pick out renderChunk because it's used as an output plugin
|
4519
|
-
renderChunk: {
|
4520
|
-
order: "pre",
|
4521
|
-
handler: typeof handler === "function" ? handler : handler.handler
|
4522
|
-
}
|
4523
|
-
};
|
4524
|
-
};
|
4525
4506
|
|
4526
4507
|
var progress = (options = {}) => {
|
4527
4508
|
const { onEvent } = options;
|
@@ -4814,7 +4795,16 @@ const generateConfigs = (context, options = {}) => {
|
|
4814
4795
|
({ default: esbuild }) => esbuild({
|
4815
4796
|
sourceMap: sourcemap === "hidden" ? false : !!sourcemap,
|
4816
4797
|
tsconfig: buildTSConfigPath,
|
4817
|
-
|
4798
|
+
loaders: {
|
4799
|
+
cts: "ts",
|
4800
|
+
ctsx: "tsx",
|
4801
|
+
mts: "ts",
|
4802
|
+
mtsx: "tsx",
|
4803
|
+
cjs: "js",
|
4804
|
+
cjsx: "jsx",
|
4805
|
+
mjs: "js",
|
4806
|
+
mjsx: "jsx"
|
4807
|
+
},
|
4818
4808
|
...noTypeResolvedBuilderOptions,
|
4819
4809
|
supported: {
|
4820
4810
|
"import-attributes": features.keepImportAttributes !== false,
|
@@ -4831,6 +4821,12 @@ const generateConfigs = (context, options = {}) => {
|
|
4831
4821
|
...noTypeResolvedBuilderOptions,
|
4832
4822
|
jsc: {
|
4833
4823
|
...resolvedBuilderOptions.jsc,
|
4824
|
+
parser: resolvedBuilderOptions.jsc?.parser ? resolvedBuilderOptions.jsc?.parser : {
|
4825
|
+
syntax: "typescript",
|
4826
|
+
tsx: true,
|
4827
|
+
decorators: true,
|
4828
|
+
dynamicImport: true
|
4829
|
+
},
|
4834
4830
|
experimental: {
|
4835
4831
|
...resolvedBuilderOptions.jsc?.experimental,
|
4836
4832
|
keepImportAttributes: features.keepImportAttributes !== false
|
@@ -4856,9 +4852,7 @@ const generateConfigs = (context, options = {}) => {
|
|
4856
4852
|
strict: typeof options?.output?.strict === "object" ? options.output.strict.js : options?.output?.strict,
|
4857
4853
|
externalImportAttributes: features.keepImportAttributes !== false,
|
4858
4854
|
importAttributesKey: features.keepImportAttributes === false || features.keepImportAttributes === void 0 ? void 0 : features.keepImportAttributes === true ? "with" : features.keepImportAttributes,
|
4859
|
-
plugins: [
|
4860
|
-
isFormatEsm(format === "esm")
|
4861
|
-
]
|
4855
|
+
plugins: []
|
4862
4856
|
}, onlyOncePlugins)
|
4863
4857
|
],
|
4864
4858
|
plugins: [
|
@@ -4870,8 +4864,16 @@ const generateConfigs = (context, options = {}) => {
|
|
4870
4864
|
})
|
4871
4865
|
).catch(() => void 0),
|
4872
4866
|
commonjs__default.default(),
|
4873
|
-
createRequire(),
|
4874
4867
|
builder,
|
4868
|
+
// inject plugin can't resolve `import type`, so we should register it after the builder plugin
|
4869
|
+
inject__default.default({
|
4870
|
+
sourceMap: sourcemap === "hidden" ? false : !!sourcemap,
|
4871
|
+
modules: {
|
4872
|
+
...build.injects ?? {},
|
4873
|
+
require: CREATE_REQUIRE_VIRTUAL_MODULE_NAME
|
4874
|
+
}
|
4875
|
+
}),
|
4876
|
+
createRequire(format === "esm"),
|
4875
4877
|
ana,
|
4876
4878
|
progress({
|
4877
4879
|
onEvent: (event, message) => void publishInEntry("progress", { event, message, tags: ["js"] })
|
@@ -4881,13 +4883,14 @@ const generateConfigs = (context, options = {}) => {
|
|
4881
4883
|
});
|
4882
4884
|
}
|
4883
4885
|
if (dtsOutput && !WITHOUT_DTS) {
|
4886
|
+
const sourcemap = typeof options?.output?.sourcemap === "object" ? options.output.sourcemap.dts : options?.output?.sourcemap;
|
4884
4887
|
rollupOptions.push({
|
4885
4888
|
input: inputObj,
|
4886
4889
|
external,
|
4887
4890
|
output: [
|
4888
4891
|
{
|
4889
4892
|
dir: dtsOutdir,
|
4890
|
-
sourcemap
|
4893
|
+
sourcemap,
|
4891
4894
|
entryFileNames: (chunkInfo) => Array.isArray(inputObj) ? chunkInfo.facadeModuleId.replace(`${process__default.default.cwd()}/`, "").replace(globCommonDir, pathCommonDir).replace(/(\.[cm]?)ts$/, tsOutputSuffix) : output.replace(`${jsOutdir}/`, "").replace(/(\.[cm]?)js$/, tsOutputSuffix),
|
4892
4895
|
strict: typeof options?.output?.strict === "object" ? options.output.strict.dts : options?.output?.strict
|
4893
4896
|
}
|
package/dist/rollup/index.js
CHANGED
@@ -5,6 +5,7 @@ import { resolveEntrypoints, filterLeafs, DEFAULT_SKIP_VALUES, entrypoints2Expor
|
|
5
5
|
import { dts } from '@jiek/rollup-plugin-dts';
|
6
6
|
import { isWorkspaceDir, getWorkspaceDir } from '@jiek/utils/getWorkspaceDir';
|
7
7
|
import commonjs from '@rollup/plugin-commonjs';
|
8
|
+
import inject from '@rollup/plugin-inject';
|
8
9
|
import json from '@rollup/plugin-json';
|
9
10
|
import { nodeResolve } from '@rollup/plugin-node-resolve';
|
10
11
|
import require$$0 from 'util';
|
@@ -15,8 +16,6 @@ import { createRequire as createRequire$1, builtinModules } from 'node:module';
|
|
15
16
|
import { program } from 'commander';
|
16
17
|
import { load } from 'js-yaml';
|
17
18
|
import { parse } from 'jsonc-parser';
|
18
|
-
import inject from '@rollup/plugin-inject';
|
19
|
-
import replace from '@rollup/plugin-replace';
|
20
19
|
|
21
20
|
var utils$1 = {};
|
22
21
|
|
@@ -4172,11 +4171,13 @@ function bundleAnalyzer(modulesResolved) {
|
|
4172
4171
|
|
4173
4172
|
const intersection = (a, b) => new Set([...a].filter((i) => b.has(i)));
|
4174
4173
|
const {
|
4175
|
-
JIEK_OUT_DIR
|
4176
|
-
|
4174
|
+
JIEK_OUT_DIR,
|
4175
|
+
JIEK_CROSS_MODULE_CONVERTOR
|
4176
|
+
} = process$1.env;
|
4177
4177
|
const OUTDIR = JIEK_OUT_DIR ?? "dist";
|
4178
|
+
const crossModuleConvertorDefault = JIEK_CROSS_MODULE_CONVERTOR === void 0 ? true : JIEK_CROSS_MODULE_CONVERTOR === "true";
|
4178
4179
|
function getOutDirs({
|
4179
|
-
cwd = process.cwd(),
|
4180
|
+
cwd = process$1.cwd(),
|
4180
4181
|
defaultOutdir = OUTDIR,
|
4181
4182
|
config,
|
4182
4183
|
pkgName
|
@@ -4216,7 +4217,7 @@ function getExports({
|
|
4216
4217
|
} = {}
|
4217
4218
|
} = config ?? {};
|
4218
4219
|
const {
|
4219
|
-
crossModuleConvertor =
|
4220
|
+
crossModuleConvertor = crossModuleConvertorDefault
|
4220
4221
|
} = build;
|
4221
4222
|
const [, resolvedEntrypoints] = resolveEntrypoints(entrypoints);
|
4222
4223
|
if (entries) {
|
@@ -4237,14 +4238,24 @@ function getExports({
|
|
4237
4238
|
}
|
4238
4239
|
);
|
4239
4240
|
const crossModuleWithConditional = crossModuleConvertor ? {
|
4240
|
-
import: (opts) =>
|
4241
|
-
|
4242
|
-
|
4243
|
-
|
4244
|
-
|
4245
|
-
|
4246
|
-
|
4247
|
-
|
4241
|
+
import: (opts) => {
|
4242
|
+
if (pkgIsModule) return false;
|
4243
|
+
if (opts.src.endsWith(".cts")) return false;
|
4244
|
+
if (intersection(
|
4245
|
+
new Set(opts.conditionals),
|
4246
|
+
/* @__PURE__ */ new Set(["import", "module"])
|
4247
|
+
).size !== 0) return false;
|
4248
|
+
return opts.dist.replace(/\.js$/, ".mjs");
|
4249
|
+
},
|
4250
|
+
require: (opts) => {
|
4251
|
+
if (!pkgIsModule) return false;
|
4252
|
+
if (opts.src.endsWith(".mts")) return false;
|
4253
|
+
if (intersection(
|
4254
|
+
new Set(opts.conditionals),
|
4255
|
+
/* @__PURE__ */ new Set(["require", "node"])
|
4256
|
+
).size !== 0) return false;
|
4257
|
+
return opts.dist.replace(/\.js$/, ".cjs");
|
4258
|
+
}
|
4248
4259
|
} : {};
|
4249
4260
|
return [
|
4250
4261
|
filteredResolvedEntrypoints,
|
@@ -4261,6 +4272,8 @@ function getExports({
|
|
4261
4272
|
];
|
4262
4273
|
}
|
4263
4274
|
|
4275
|
+
var require = /* @__PURE__ */ createRequire$1(import.meta.url);
|
4276
|
+
|
4264
4277
|
let root;
|
4265
4278
|
function getRoot() {
|
4266
4279
|
if (root) return root;
|
@@ -4271,7 +4284,6 @@ function getRoot() {
|
|
4271
4284
|
|
4272
4285
|
let type = "";
|
4273
4286
|
try {
|
4274
|
-
const require = createRequire$1(import.meta.url);
|
4275
4287
|
require.resolve("@pnpm/filter-workspace-packages");
|
4276
4288
|
type = "pnpm";
|
4277
4289
|
} catch {
|
@@ -4301,10 +4313,9 @@ function getWD() {
|
|
4301
4313
|
return { wd, notWorkspace };
|
4302
4314
|
}
|
4303
4315
|
|
4304
|
-
const require$1 = createRequire$1(import.meta.url);
|
4305
4316
|
function packageIsExist(name) {
|
4306
4317
|
try {
|
4307
|
-
require
|
4318
|
+
require.resolve(name);
|
4308
4319
|
return true;
|
4309
4320
|
} catch (e) {
|
4310
4321
|
return false;
|
@@ -4324,7 +4335,6 @@ for (const register of registers) {
|
|
4324
4335
|
}
|
4325
4336
|
}
|
4326
4337
|
|
4327
|
-
const require = createRequire$1(import.meta.url);
|
4328
4338
|
let configName = "jiek.config";
|
4329
4339
|
function getConfigPath(root, dir) {
|
4330
4340
|
const isSupportTsLoader = !!tsRegisterName;
|
@@ -4454,8 +4464,8 @@ const getCompilerOptionsByFilePath = (tsconfigPath, filePath) => {
|
|
4454
4464
|
if (exclude.length > 0 && exclude.some((i) => micromatchExports.isMatch(filePath, i))) return;
|
4455
4465
|
if (tsconfig.files?.length === 0 && tsconfig.include?.length === 0) return;
|
4456
4466
|
let isInclude = false;
|
4457
|
-
isInclude
|
4458
|
-
isInclude
|
4467
|
+
isInclude || (isInclude = files.length > 0 && files.includes(filePath));
|
4468
|
+
isInclude || (isInclude = include.length > 0 && include.some((i) => micromatchExports.isMatch(filePath, i)));
|
4459
4469
|
if (isInclude) {
|
4460
4470
|
return tsconfig.compilerOptions ?? {};
|
4461
4471
|
} else {
|
@@ -4469,43 +4479,16 @@ const getCompilerOptionsByFilePath = (tsconfigPath, filePath) => {
|
|
4469
4479
|
return tsconfig.compilerOptions;
|
4470
4480
|
};
|
4471
4481
|
|
4472
|
-
const
|
4473
|
-
const
|
4474
|
-
|
4475
|
-
|
4476
|
-
|
4477
|
-
export default (
|
4478
|
-
${isEsmVariableName}
|
4479
|
-
? /* @__PURE__ */ createRequire(import.meta.url)
|
4480
|
-
: require
|
4481
|
-
)
|
4482
|
+
const CREATE_REQUIRE_VIRTUAL_MODULE_NAME = "jiek:create-require";
|
4483
|
+
const INSERT_STR = (isESM) => `
|
4484
|
+
${isESM ? `import { createRequire } from 'node:module'` : ""}
|
4485
|
+
export default ${isESM ? "/* @__PURE__ */ createRequire(import.meta.url)" : "require"}
|
4482
4486
|
`.trim();
|
4483
|
-
var createRequire = () => ({
|
4484
|
-
...inject({
|
4485
|
-
require: virtualModuleName
|
4486
|
-
}),
|
4487
|
+
var createRequire = (isEsm) => ({
|
4487
4488
|
name: "create-require",
|
4488
|
-
resolveId: (
|
4489
|
-
load: (id) =>
|
4490
|
-
if (id !== virtualModuleName) {
|
4491
|
-
return null;
|
4492
|
-
}
|
4493
|
-
return INSERT_STR;
|
4494
|
-
}
|
4489
|
+
resolveId: (id) => id === CREATE_REQUIRE_VIRTUAL_MODULE_NAME ? id : null,
|
4490
|
+
load: (id) => id === CREATE_REQUIRE_VIRTUAL_MODULE_NAME ? INSERT_STR(isEsm) : null
|
4495
4491
|
});
|
4496
|
-
const isFormatEsm = (isEsm) => {
|
4497
|
-
const handler = replace({
|
4498
|
-
[isEsmVariableName]: isEsm
|
4499
|
-
}).renderChunk;
|
4500
|
-
return {
|
4501
|
-
name: "create-require-insert-format",
|
4502
|
-
// Pick out renderChunk because it's used as an output plugin
|
4503
|
-
renderChunk: {
|
4504
|
-
order: "pre",
|
4505
|
-
handler: typeof handler === "function" ? handler : handler.handler
|
4506
|
-
}
|
4507
|
-
};
|
4508
|
-
};
|
4509
4492
|
|
4510
4493
|
var progress = (options = {}) => {
|
4511
4494
|
const { onEvent } = options;
|
@@ -4798,7 +4781,16 @@ const generateConfigs = (context, options = {}) => {
|
|
4798
4781
|
({ default: esbuild }) => esbuild({
|
4799
4782
|
sourceMap: sourcemap === "hidden" ? false : !!sourcemap,
|
4800
4783
|
tsconfig: buildTSConfigPath,
|
4801
|
-
|
4784
|
+
loaders: {
|
4785
|
+
cts: "ts",
|
4786
|
+
ctsx: "tsx",
|
4787
|
+
mts: "ts",
|
4788
|
+
mtsx: "tsx",
|
4789
|
+
cjs: "js",
|
4790
|
+
cjsx: "jsx",
|
4791
|
+
mjs: "js",
|
4792
|
+
mjsx: "jsx"
|
4793
|
+
},
|
4802
4794
|
...noTypeResolvedBuilderOptions,
|
4803
4795
|
supported: {
|
4804
4796
|
"import-attributes": features.keepImportAttributes !== false,
|
@@ -4815,6 +4807,12 @@ const generateConfigs = (context, options = {}) => {
|
|
4815
4807
|
...noTypeResolvedBuilderOptions,
|
4816
4808
|
jsc: {
|
4817
4809
|
...resolvedBuilderOptions.jsc,
|
4810
|
+
parser: resolvedBuilderOptions.jsc?.parser ? resolvedBuilderOptions.jsc?.parser : {
|
4811
|
+
syntax: "typescript",
|
4812
|
+
tsx: true,
|
4813
|
+
decorators: true,
|
4814
|
+
dynamicImport: true
|
4815
|
+
},
|
4818
4816
|
experimental: {
|
4819
4817
|
...resolvedBuilderOptions.jsc?.experimental,
|
4820
4818
|
keepImportAttributes: features.keepImportAttributes !== false
|
@@ -4840,9 +4838,7 @@ const generateConfigs = (context, options = {}) => {
|
|
4840
4838
|
strict: typeof options?.output?.strict === "object" ? options.output.strict.js : options?.output?.strict,
|
4841
4839
|
externalImportAttributes: features.keepImportAttributes !== false,
|
4842
4840
|
importAttributesKey: features.keepImportAttributes === false || features.keepImportAttributes === void 0 ? void 0 : features.keepImportAttributes === true ? "with" : features.keepImportAttributes,
|
4843
|
-
plugins: [
|
4844
|
-
isFormatEsm(format === "esm")
|
4845
|
-
]
|
4841
|
+
plugins: []
|
4846
4842
|
}, onlyOncePlugins)
|
4847
4843
|
],
|
4848
4844
|
plugins: [
|
@@ -4854,8 +4850,16 @@ const generateConfigs = (context, options = {}) => {
|
|
4854
4850
|
})
|
4855
4851
|
).catch(() => void 0),
|
4856
4852
|
commonjs(),
|
4857
|
-
createRequire(),
|
4858
4853
|
builder,
|
4854
|
+
// inject plugin can't resolve `import type`, so we should register it after the builder plugin
|
4855
|
+
inject({
|
4856
|
+
sourceMap: sourcemap === "hidden" ? false : !!sourcemap,
|
4857
|
+
modules: {
|
4858
|
+
...build.injects ?? {},
|
4859
|
+
require: CREATE_REQUIRE_VIRTUAL_MODULE_NAME
|
4860
|
+
}
|
4861
|
+
}),
|
4862
|
+
createRequire(format === "esm"),
|
4859
4863
|
ana,
|
4860
4864
|
progress({
|
4861
4865
|
onEvent: (event, message) => void publishInEntry("progress", { event, message, tags: ["js"] })
|
@@ -4865,13 +4869,14 @@ const generateConfigs = (context, options = {}) => {
|
|
4865
4869
|
});
|
4866
4870
|
}
|
4867
4871
|
if (dtsOutput && !WITHOUT_DTS) {
|
4872
|
+
const sourcemap = typeof options?.output?.sourcemap === "object" ? options.output.sourcemap.dts : options?.output?.sourcemap;
|
4868
4873
|
rollupOptions.push({
|
4869
4874
|
input: inputObj,
|
4870
4875
|
external,
|
4871
4876
|
output: [
|
4872
4877
|
{
|
4873
4878
|
dir: dtsOutdir,
|
4874
|
-
sourcemap
|
4879
|
+
sourcemap,
|
4875
4880
|
entryFileNames: (chunkInfo) => Array.isArray(inputObj) ? chunkInfo.facadeModuleId.replace(`${process$1.cwd()}/`, "").replace(globCommonDir, pathCommonDir).replace(/(\.[cm]?)ts$/, tsOutputSuffix) : output.replace(`${jsOutdir}/`, "").replace(/(\.[cm]?)js$/, tsOutputSuffix),
|
4876
4881
|
strict: typeof options?.output?.strict === "object" ? options.output.strict.dts : options?.output?.strict
|
4877
4882
|
}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "jiek",
|
3
3
|
"type": "module",
|
4
|
-
"version": "2.2.
|
4
|
+
"version": "2.2.5-alpha.1",
|
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",
|
@@ -61,7 +61,7 @@
|
|
61
61
|
"jb": "bin/jiek-build.js"
|
62
62
|
},
|
63
63
|
"peerDependencies": {
|
64
|
-
"@pnpm/filter-workspace-packages": "^7.2.13||^8.0.0||^9.0.0||^10.0.0",
|
64
|
+
"@pnpm/filter-workspace-packages": "^7.2.13||^8.0.0||^9.0.0||^10.0.0||>=1000.0.0",
|
65
65
|
"@rollup/plugin-terser": "^0.4.4",
|
66
66
|
"esbuild-register": "^3.5.0",
|
67
67
|
"postcss": "^8.4.47",
|
@@ -72,13 +72,12 @@
|
|
72
72
|
"vite-bundle-analyzer": "0.16.0-beta.1"
|
73
73
|
},
|
74
74
|
"dependencies": {
|
75
|
-
"@inquirer/prompts": "^7.
|
75
|
+
"@inquirer/prompts": "^7.2.0",
|
76
76
|
"@jiek/rollup-plugin-dts": "^6.2.1",
|
77
77
|
"@rollup/plugin-commonjs": "^28.0.0",
|
78
78
|
"@rollup/plugin-inject": "^5.0.5",
|
79
79
|
"@rollup/plugin-json": "^6.0.1",
|
80
80
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
81
|
-
"@rollup/plugin-replace": "^6.0.1",
|
82
81
|
"cli-progress": "^3.12.0",
|
83
82
|
"commander": "^12.0.0",
|
84
83
|
"detect-indent": "^6.1.0",
|
package/rollup/package.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"type":"module","
|
1
|
+
{"type":"module","module":"../dist/rollup/index.js","main":"../dist/rollup/index.cjs"}
|
package/src/commands/build.ts
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
import { existsSync, mkdirSync, writeFileSync } from 'node:fs'
|
2
|
-
import { createRequire } from 'node:module'
|
3
2
|
import path from 'node:path'
|
4
3
|
import process from 'node:process'
|
5
4
|
|
@@ -39,8 +38,6 @@ const FILE_TEMPLATE = (manifest: unknown) => (`
|
|
39
38
|
module.exports = require('jiek/rollup').template(${JSON.stringify(manifest, null, 2)})
|
40
39
|
`.trimStart())
|
41
40
|
|
42
|
-
const require = createRequire(import.meta.url)
|
43
|
-
|
44
41
|
const isDefault = process.env.JIEK_IS_ONLY_BUILD === 'true'
|
45
42
|
|
46
43
|
const description = `
|
@@ -75,6 +72,7 @@ interface BuildOptions extends AnalyzerBuildOptions {
|
|
75
72
|
verbose: boolean
|
76
73
|
entries?: string
|
77
74
|
external?: string
|
75
|
+
noConvert: boolean
|
78
76
|
noJs: boolean
|
79
77
|
noDts: boolean
|
80
78
|
noMin: boolean
|
@@ -154,6 +152,7 @@ command = command
|
|
154
152
|
.option('-o, --outdir <OUTDIR>', outdirDescription, String, 'dist')
|
155
153
|
.option('-e, --entries <ENTRIES>', entriesDescription)
|
156
154
|
.option('--external <EXTERNAL>', 'Specify the external dependencies of the package.', String)
|
155
|
+
.option('--noConvert', 'Specify the `crossModuleConvertor` option to false.', parseBoolean)
|
157
156
|
.option('-nj, --noJs', 'Do not output js files.', parseBoolean)
|
158
157
|
.option('-nd, --noDts', 'Do not output dts files.', parseBoolean)
|
159
158
|
.option('-nm, --noMin', 'Do not output minify files.', parseBoolean)
|
@@ -198,6 +197,7 @@ command
|
|
198
197
|
verbose,
|
199
198
|
entries: optionEntries,
|
200
199
|
external,
|
200
|
+
noConvert,
|
201
201
|
noJs: withoutJs,
|
202
202
|
noDts: withoutDts,
|
203
203
|
noMin: withoutMin,
|
@@ -214,13 +214,8 @@ command
|
|
214
214
|
minifyType = resolvedType
|
215
215
|
}
|
216
216
|
}
|
217
|
-
if (!withoutMin) {
|
218
|
-
await checkDependency(
|
219
|
-
{
|
220
|
-
...BUILDER_TYPE_PACKAGE_NAME_MAP,
|
221
|
-
terser: '@rollup/plugin-terser'
|
222
|
-
}[resolvedType]
|
223
|
-
)
|
217
|
+
if (!withoutMin && minifyType === 'terser') {
|
218
|
+
await checkDependency('@rollup/plugin-terser')
|
224
219
|
}
|
225
220
|
let shouldPassThrough = false
|
226
221
|
|
@@ -274,6 +269,7 @@ command
|
|
274
269
|
JIEK_CLEAN: String(!noClean),
|
275
270
|
JIEK_ENTRIES: entries,
|
276
271
|
JIEK_EXTERNAL: external,
|
272
|
+
JIEK_CROSS_MODULE_CONVERTOR: String(!noConvert),
|
277
273
|
JIEK_WITHOUT_JS: String(withoutJs),
|
278
274
|
JIEK_WITHOUT_DTS: String(withoutDts),
|
279
275
|
JIEK_WITHOUT_MINIFY: String(withoutMin),
|
@@ -471,14 +467,16 @@ command
|
|
471
467
|
}
|
472
468
|
})
|
473
469
|
await new Promise<void>((resolve, reject) => {
|
474
|
-
let errorStr =
|
470
|
+
let errorStr = `rollup build failed\n`
|
471
|
+
+ `package name: ${manifest.name}\n`
|
472
|
+
+ `cwd: ${pkgCWD}\n\n`
|
475
473
|
child.stderr?.on('data', (data) => {
|
476
474
|
errorStr += data
|
477
475
|
})
|
478
476
|
child.once('exit', (code) =>
|
479
477
|
code === 0
|
480
478
|
? resolve()
|
481
|
-
: reject(new Error(
|
479
|
+
: reject(new Error(errorStr)))
|
482
480
|
verbose && child.stdout?.pipe(process.stdout)
|
483
481
|
})
|
484
482
|
})
|