jiek 2.2.3-alpha.4 → 2.2.3-alpha.5
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/dist/cli-only-build.cjs +10 -15
- package/dist/cli-only-build.js +12 -15
- package/dist/cli.cjs +3 -6
- package/dist/cli.js +3 -4
- package/dist/rollup/index.cjs +19 -48
- package/dist/rollup/index.js +17 -44
- package/package.json +1 -2
- package/src/commands/build.ts +0 -3
- package/src/rollup/index.ts +8 -6
- package/src/rollup/plugins/create-require.ts +14 -65
- package/src/utils/checkDependency.ts +1 -1
- package/src/utils/filterSupport.ts +0 -2
- package/src/utils/loadConfig.ts +0 -3
- package/src/utils/tsRegister.ts +0 -4
package/dist/cli-only-build.cjs
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
3
|
var fs = require('node:fs');
|
4
|
-
var node_module = require('node:module');
|
5
4
|
var path = require('node:path');
|
6
5
|
var commander = require('commander');
|
7
6
|
var jsYaml = require('js-yaml');
|
@@ -13,7 +12,6 @@ var node_child_process = require('node:child_process');
|
|
13
12
|
var prompts = require('@inquirer/prompts');
|
14
13
|
var Koa = require('koa');
|
15
14
|
|
16
|
-
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
17
15
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
18
16
|
|
19
17
|
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
@@ -21,6 +19,8 @@ var path__default = /*#__PURE__*/_interopDefault(path);
|
|
21
19
|
var process__default = /*#__PURE__*/_interopDefault(process$1);
|
22
20
|
var Koa__default = /*#__PURE__*/_interopDefault(Koa);
|
23
21
|
|
22
|
+
var require$1 = require;
|
23
|
+
|
24
24
|
let root;
|
25
25
|
function getRoot() {
|
26
26
|
if (root) return root;
|
@@ -55,7 +55,6 @@ function getWD() {
|
|
55
55
|
|
56
56
|
let type$1 = "";
|
57
57
|
try {
|
58
|
-
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-only-build.cjs', document.baseURI).href)));
|
59
58
|
require$1.resolve("@pnpm/filter-workspace-packages");
|
60
59
|
type$1 = "pnpm";
|
61
60
|
} catch {
|
@@ -119,7 +118,7 @@ async function getSelectedProjectsGraph(filter = commander.program.getOptionValu
|
|
119
118
|
|
120
119
|
var name = "jiek";
|
121
120
|
var type = "module";
|
122
|
-
var version = "2.2.3-alpha.
|
121
|
+
var version = "2.2.3-alpha.4";
|
123
122
|
var description$1 = "A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.";
|
124
123
|
var author = "YiJie <yijie4188@gmail.com>";
|
125
124
|
var homepage = "https://github.com/NWYLZW/jiek/tree/master/packages/jiek#readme";
|
@@ -196,7 +195,6 @@ var dependencies = {
|
|
196
195
|
"@rollup/plugin-inject": "^5.0.5",
|
197
196
|
"@rollup/plugin-json": "^6.0.1",
|
198
197
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
199
|
-
"@rollup/plugin-replace": "^6.0.1",
|
200
198
|
"cli-progress": "^3.12.0",
|
201
199
|
commander: "^12.0.0",
|
202
200
|
"detect-indent": "^6.1.0",
|
@@ -379,12 +377,12 @@ function parseBoolean(v) {
|
|
379
377
|
|
380
378
|
async function checkDependency(dependency) {
|
381
379
|
try {
|
382
|
-
require.resolve(dependency);
|
380
|
+
require$1.resolve(dependency);
|
383
381
|
} catch {
|
384
382
|
console.error(`The package '${dependency}' is not installed, please install it first.`);
|
385
383
|
const { notWorkspace } = getWD();
|
386
384
|
const command = `pnpm install -${notWorkspace ? "" : "w"}D ${dependency}`;
|
387
|
-
if (await prompts.confirm({ message:
|
385
|
+
if (await prompts.confirm({ message: `Do you want to install it now? (${command})` })) {
|
388
386
|
node_child_process.execSync(command, {
|
389
387
|
stdio: "inherit",
|
390
388
|
cwd: process__default.default.cwd(),
|
@@ -506,10 +504,9 @@ const createServer = (port, host) => {
|
|
506
504
|
};
|
507
505
|
};
|
508
506
|
|
509
|
-
const require$3 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-only-build.cjs', document.baseURI).href)));
|
510
507
|
function packageIsExist(name) {
|
511
508
|
try {
|
512
|
-
require$
|
509
|
+
require$1.resolve(name);
|
513
510
|
return true;
|
514
511
|
} catch (e) {
|
515
512
|
return false;
|
@@ -529,7 +526,6 @@ for (const register of registers) {
|
|
529
526
|
}
|
530
527
|
}
|
531
528
|
|
532
|
-
const require$2 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-only-build.cjs', document.baseURI).href)));
|
533
529
|
let configName = "jiek.config";
|
534
530
|
function getConfigPath(root, dir) {
|
535
531
|
const isSupportTsLoader = !!tsRegisterName;
|
@@ -583,16 +579,16 @@ function loadConfig(dirOrOptions) {
|
|
583
579
|
let module;
|
584
580
|
switch (ext) {
|
585
581
|
case ".js":
|
586
|
-
module = require$
|
582
|
+
module = require$1(configPath);
|
587
583
|
break;
|
588
584
|
case ".json":
|
589
|
-
return require$
|
585
|
+
return require$1(configPath);
|
590
586
|
case ".yaml":
|
591
587
|
return jsYaml.load(fs__default.default.readFileSync(configPath, "utf-8"));
|
592
588
|
case ".ts":
|
593
589
|
if (tsRegisterName) {
|
594
|
-
require$
|
595
|
-
module = require$
|
590
|
+
require$1(tsRegisterName);
|
591
|
+
module = require$1(configPath);
|
596
592
|
break;
|
597
593
|
}
|
598
594
|
throw new Error(
|
@@ -611,7 +607,6 @@ function loadConfig(dirOrOptions) {
|
|
611
607
|
const FILE_TEMPLATE = (manifest) => `
|
612
608
|
module.exports = require('jiek/rollup').template(${JSON.stringify(manifest, null, 2)})
|
613
609
|
`.trimStart();
|
614
|
-
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-only-build.cjs', document.baseURI).href)));
|
615
610
|
const isDefault = process__default.default.env.JIEK_IS_ONLY_BUILD === "true";
|
616
611
|
const description = `
|
617
612
|
Build the package according to the 'exports' field from the package.json.
|
package/dist/cli-only-build.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import fs, { existsSync, mkdirSync, writeFileSync, statSync } from 'node:fs';
|
2
1
|
import { createRequire } from 'node:module';
|
2
|
+
import fs, { existsSync, mkdirSync, writeFileSync, statSync } from 'node:fs';
|
3
3
|
import path from 'node:path';
|
4
4
|
import { program } from 'commander';
|
5
5
|
import { load } from 'js-yaml';
|
@@ -11,6 +11,8 @@ import { execSync } from 'node:child_process';
|
|
11
11
|
import { confirm } from '@inquirer/prompts';
|
12
12
|
import Koa from 'koa';
|
13
13
|
|
14
|
+
var require = /* @__PURE__ */ createRequire(import.meta.url);
|
15
|
+
|
14
16
|
let root;
|
15
17
|
function getRoot() {
|
16
18
|
if (root) return root;
|
@@ -45,7 +47,6 @@ function getWD() {
|
|
45
47
|
|
46
48
|
let type$1 = "";
|
47
49
|
try {
|
48
|
-
const require = createRequire(import.meta.url);
|
49
50
|
require.resolve("@pnpm/filter-workspace-packages");
|
50
51
|
type$1 = "pnpm";
|
51
52
|
} catch {
|
@@ -109,7 +110,7 @@ async function getSelectedProjectsGraph(filter = program.getOptionValue("filter"
|
|
109
110
|
|
110
111
|
var name = "jiek";
|
111
112
|
var type = "module";
|
112
|
-
var version = "2.2.3-alpha.
|
113
|
+
var version = "2.2.3-alpha.4";
|
113
114
|
var description$1 = "A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.";
|
114
115
|
var author = "YiJie <yijie4188@gmail.com>";
|
115
116
|
var homepage = "https://github.com/NWYLZW/jiek/tree/master/packages/jiek#readme";
|
@@ -186,7 +187,6 @@ var dependencies = {
|
|
186
187
|
"@rollup/plugin-inject": "^5.0.5",
|
187
188
|
"@rollup/plugin-json": "^6.0.1",
|
188
189
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
189
|
-
"@rollup/plugin-replace": "^6.0.1",
|
190
190
|
"cli-progress": "^3.12.0",
|
191
191
|
commander: "^12.0.0",
|
192
192
|
"detect-indent": "^6.1.0",
|
@@ -374,7 +374,7 @@ async function checkDependency(dependency) {
|
|
374
374
|
console.error(`The package '${dependency}' is not installed, please install it first.`);
|
375
375
|
const { notWorkspace } = getWD();
|
376
376
|
const command = `pnpm install -${notWorkspace ? "" : "w"}D ${dependency}`;
|
377
|
-
if (await confirm({ message:
|
377
|
+
if (await confirm({ message: `Do you want to install it now? (${command})` })) {
|
378
378
|
execSync(command, {
|
379
379
|
stdio: "inherit",
|
380
380
|
cwd: process$1.cwd(),
|
@@ -496,10 +496,9 @@ const createServer = (port, host) => {
|
|
496
496
|
};
|
497
497
|
};
|
498
498
|
|
499
|
-
const require$3 = createRequire(import.meta.url);
|
500
499
|
function packageIsExist(name) {
|
501
500
|
try {
|
502
|
-
require
|
501
|
+
require.resolve(name);
|
503
502
|
return true;
|
504
503
|
} catch (e) {
|
505
504
|
return false;
|
@@ -519,7 +518,6 @@ for (const register of registers) {
|
|
519
518
|
}
|
520
519
|
}
|
521
520
|
|
522
|
-
const require$2 = createRequire(import.meta.url);
|
523
521
|
let configName = "jiek.config";
|
524
522
|
function getConfigPath(root, dir) {
|
525
523
|
const isSupportTsLoader = !!tsRegisterName;
|
@@ -573,16 +571,16 @@ function loadConfig(dirOrOptions) {
|
|
573
571
|
let module;
|
574
572
|
switch (ext) {
|
575
573
|
case ".js":
|
576
|
-
module = require
|
574
|
+
module = require(configPath);
|
577
575
|
break;
|
578
576
|
case ".json":
|
579
|
-
return require
|
577
|
+
return require(configPath);
|
580
578
|
case ".yaml":
|
581
579
|
return load(fs.readFileSync(configPath, "utf-8"));
|
582
580
|
case ".ts":
|
583
581
|
if (tsRegisterName) {
|
584
|
-
require
|
585
|
-
module = require
|
582
|
+
require(tsRegisterName);
|
583
|
+
module = require(configPath);
|
586
584
|
break;
|
587
585
|
}
|
588
586
|
throw new Error(
|
@@ -601,7 +599,6 @@ function loadConfig(dirOrOptions) {
|
|
601
599
|
const FILE_TEMPLATE = (manifest) => `
|
602
600
|
module.exports = require('jiek/rollup').template(${JSON.stringify(manifest, null, 2)})
|
603
601
|
`.trimStart();
|
604
|
-
const require$1 = createRequire(import.meta.url);
|
605
602
|
const isDefault = process$1.env.JIEK_IS_ONLY_BUILD === "true";
|
606
603
|
const description = `
|
607
604
|
Build the package according to the 'exports' field from the package.json.
|
@@ -611,7 +608,7 @@ ${isDefault ? "This command is the default command." : ""}
|
|
611
608
|
let DEFAULT_BUILDER_TYPE;
|
612
609
|
Object.entries(BUILDER_TYPE_PACKAGE_NAME_MAP).forEach(([type, packageName]) => {
|
613
610
|
try {
|
614
|
-
require
|
611
|
+
require.resolve(packageName);
|
615
612
|
DEFAULT_BUILDER_TYPE = type;
|
616
613
|
} catch {
|
617
614
|
}
|
@@ -763,7 +760,7 @@ command.action(async (commandFiltersOrEntries, options) => {
|
|
763
760
|
} catch {
|
764
761
|
}
|
765
762
|
}
|
766
|
-
const rollupBinaryPath = require
|
763
|
+
const rollupBinaryPath = require.resolve("rollup").replace(/dist\/rollup.js$/, "dist/bin/rollup");
|
767
764
|
let i = 0;
|
768
765
|
await Promise.all(
|
769
766
|
Object.entries(value).map(async ([pkgCWD, manifest]) => {
|
package/dist/cli.cjs
CHANGED
@@ -8,7 +8,6 @@ var bumper = require('@jiek/utils/bumper');
|
|
8
8
|
var commander = require('commander');
|
9
9
|
var detectIndent = require('detect-indent');
|
10
10
|
var jsoncParser = require('jsonc-parser');
|
11
|
-
var node_module = require('node:module');
|
12
11
|
var jsYaml = require('js-yaml');
|
13
12
|
var getWorkspaceDir = require('@jiek/utils/getWorkspaceDir');
|
14
13
|
var entrypoints = require('@jiek/pkger/entrypoints');
|
@@ -16,7 +15,6 @@ var require$$0 = require('util');
|
|
16
15
|
var require$$0$1 = require('path');
|
17
16
|
require('jiek/cli-only-build');
|
18
17
|
|
19
|
-
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
20
18
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
21
19
|
|
22
20
|
function _interopNamespace(e) {
|
@@ -45,6 +43,8 @@ var detectIndent__default = /*#__PURE__*/_interopDefault(detectIndent);
|
|
45
43
|
var require$$0__default = /*#__PURE__*/_interopDefault(require$$0);
|
46
44
|
var require$$0__default$1 = /*#__PURE__*/_interopDefault(require$$0$1);
|
47
45
|
|
46
|
+
var require$1 = require;
|
47
|
+
|
48
48
|
let root;
|
49
49
|
function getRoot() {
|
50
50
|
if (root) return root;
|
@@ -79,7 +79,6 @@ function getWD() {
|
|
79
79
|
|
80
80
|
let type = "";
|
81
81
|
try {
|
82
|
-
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href)));
|
83
82
|
require$1.resolve("@pnpm/filter-workspace-packages");
|
84
83
|
type = "pnpm";
|
85
84
|
} catch {
|
@@ -4345,10 +4344,9 @@ function getExports({
|
|
4345
4344
|
];
|
4346
4345
|
}
|
4347
4346
|
|
4348
|
-
const require$2 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href)));
|
4349
4347
|
function packageIsExist(name) {
|
4350
4348
|
try {
|
4351
|
-
require$
|
4349
|
+
require$1.resolve(name);
|
4352
4350
|
return true;
|
4353
4351
|
} catch (e) {
|
4354
4352
|
return false;
|
@@ -4368,7 +4366,6 @@ for (const register of registers) {
|
|
4368
4366
|
}
|
4369
4367
|
}
|
4370
4368
|
|
4371
|
-
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href)));
|
4372
4369
|
let configName = "jiek.config";
|
4373
4370
|
function getConfigPath(root, dir) {
|
4374
4371
|
const isSupportTsLoader = !!tsRegisterName;
|
package/dist/cli.js
CHANGED
@@ -14,6 +14,8 @@ import require$$0 from 'util';
|
|
14
14
|
import require$$0$1 from 'path';
|
15
15
|
import 'jiek/cli-only-build';
|
16
16
|
|
17
|
+
var require = /* @__PURE__ */ createRequire(import.meta.url);
|
18
|
+
|
17
19
|
let root;
|
18
20
|
function getRoot() {
|
19
21
|
if (root) return root;
|
@@ -48,7 +50,6 @@ function getWD() {
|
|
48
50
|
|
49
51
|
let type = "";
|
50
52
|
try {
|
51
|
-
const require = createRequire(import.meta.url);
|
52
53
|
require.resolve("@pnpm/filter-workspace-packages");
|
53
54
|
type = "pnpm";
|
54
55
|
} catch {
|
@@ -4314,10 +4315,9 @@ function getExports({
|
|
4314
4315
|
];
|
4315
4316
|
}
|
4316
4317
|
|
4317
|
-
const require$1 = createRequire(import.meta.url);
|
4318
4318
|
function packageIsExist(name) {
|
4319
4319
|
try {
|
4320
|
-
require
|
4320
|
+
require.resolve(name);
|
4321
4321
|
return true;
|
4322
4322
|
} catch (e) {
|
4323
4323
|
return false;
|
@@ -4337,7 +4337,6 @@ for (const register of registers) {
|
|
4337
4337
|
}
|
4338
4338
|
}
|
4339
4339
|
|
4340
|
-
const require = createRequire(import.meta.url);
|
4341
4340
|
let configName = "jiek.config";
|
4342
4341
|
function getConfigPath(root, dir) {
|
4343
4342
|
const isSupportTsLoader = !!tsRegisterName;
|
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
|
|
@@ -4287,6 +4284,8 @@ function getExports({
|
|
4287
4284
|
];
|
4288
4285
|
}
|
4289
4286
|
|
4287
|
+
var require$1 = require;
|
4288
|
+
|
4290
4289
|
let root;
|
4291
4290
|
function getRoot() {
|
4292
4291
|
if (root) return root;
|
@@ -4297,7 +4296,6 @@ function getRoot() {
|
|
4297
4296
|
|
4298
4297
|
let type = "";
|
4299
4298
|
try {
|
4300
|
-
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)));
|
4301
4299
|
require$1.resolve("@pnpm/filter-workspace-packages");
|
4302
4300
|
type = "pnpm";
|
4303
4301
|
} catch {
|
@@ -4327,10 +4325,9 @@ function getWD() {
|
|
4327
4325
|
return { wd, notWorkspace };
|
4328
4326
|
}
|
4329
4327
|
|
4330
|
-
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)));
|
4331
4328
|
function packageIsExist(name) {
|
4332
4329
|
try {
|
4333
|
-
require$
|
4330
|
+
require$1.resolve(name);
|
4334
4331
|
return true;
|
4335
4332
|
} catch (e) {
|
4336
4333
|
return false;
|
@@ -4350,7 +4347,6 @@ for (const register of registers) {
|
|
4350
4347
|
}
|
4351
4348
|
}
|
4352
4349
|
|
4353
|
-
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)));
|
4354
4350
|
let configName = "jiek.config";
|
4355
4351
|
function getConfigPath(root, dir) {
|
4356
4352
|
const isSupportTsLoader = !!tsRegisterName;
|
@@ -4495,43 +4491,16 @@ const getCompilerOptionsByFilePath = (tsconfigPath, filePath) => {
|
|
4495
4491
|
return tsconfig.compilerOptions;
|
4496
4492
|
};
|
4497
4493
|
|
4498
|
-
const
|
4499
|
-
const
|
4500
|
-
|
4501
|
-
|
4502
|
-
|
4503
|
-
export default (
|
4504
|
-
${isEsmVariableName}
|
4505
|
-
? /* @__PURE__ */ createRequire(import.meta.url)
|
4506
|
-
: require
|
4507
|
-
)
|
4494
|
+
const CREATE_REQUIRE_VIRTUAL_MODULE_NAME = "jiek:create-require";
|
4495
|
+
const INSERT_STR = (isESM) => `
|
4496
|
+
${isESM ? `import { createRequire } from 'node:module'` : ""}
|
4497
|
+
export default ${isESM ? "/* @__PURE__ */ createRequire(import.meta.url)" : "require"}
|
4508
4498
|
`.trim();
|
4509
|
-
var createRequire = () => ({
|
4510
|
-
...inject__default.default({
|
4511
|
-
require: virtualModuleName
|
4512
|
-
}),
|
4499
|
+
var createRequire = (isEsm) => ({
|
4513
4500
|
name: "create-require",
|
4514
|
-
resolveId: (
|
4515
|
-
load: (id) =>
|
4516
|
-
if (id !== virtualModuleName) {
|
4517
|
-
return null;
|
4518
|
-
}
|
4519
|
-
return INSERT_STR;
|
4520
|
-
}
|
4501
|
+
resolveId: (id) => id === CREATE_REQUIRE_VIRTUAL_MODULE_NAME ? id : null,
|
4502
|
+
load: (id) => id === CREATE_REQUIRE_VIRTUAL_MODULE_NAME ? INSERT_STR(isEsm) : null
|
4521
4503
|
});
|
4522
|
-
const isFormatEsm = (isEsm) => {
|
4523
|
-
const handler = replace__default.default({
|
4524
|
-
[isEsmVariableName]: isEsm
|
4525
|
-
}).renderChunk;
|
4526
|
-
return {
|
4527
|
-
name: "create-require-insert-format",
|
4528
|
-
// Pick out renderChunk because it's used as an output plugin
|
4529
|
-
renderChunk: {
|
4530
|
-
order: "pre",
|
4531
|
-
handler: typeof handler === "function" ? handler : handler.handler
|
4532
|
-
}
|
4533
|
-
};
|
4534
|
-
};
|
4535
4504
|
|
4536
4505
|
var progress = (options = {}) => {
|
4537
4506
|
const { onEvent } = options;
|
@@ -4881,9 +4850,7 @@ const generateConfigs = (context, options = {}) => {
|
|
4881
4850
|
strict: typeof options?.output?.strict === "object" ? options.output.strict.js : options?.output?.strict,
|
4882
4851
|
externalImportAttributes: features.keepImportAttributes !== false,
|
4883
4852
|
importAttributesKey: features.keepImportAttributes === false || features.keepImportAttributes === void 0 ? void 0 : features.keepImportAttributes === true ? "with" : features.keepImportAttributes,
|
4884
|
-
plugins: [
|
4885
|
-
isFormatEsm(format === "esm")
|
4886
|
-
]
|
4853
|
+
plugins: []
|
4887
4854
|
}, onlyOncePlugins)
|
4888
4855
|
],
|
4889
4856
|
plugins: [
|
@@ -4895,8 +4862,12 @@ const generateConfigs = (context, options = {}) => {
|
|
4895
4862
|
})
|
4896
4863
|
).catch(() => void 0),
|
4897
4864
|
commonjs__default.default(),
|
4898
|
-
createRequire(),
|
4899
4865
|
builder,
|
4866
|
+
// inject plugin can't resolve `import type`, so we should register it after the builder plugin
|
4867
|
+
inject__default.default({
|
4868
|
+
require: CREATE_REQUIRE_VIRTUAL_MODULE_NAME
|
4869
|
+
}),
|
4870
|
+
createRequire(format === "esm"),
|
4900
4871
|
ana,
|
4901
4872
|
progress({
|
4902
4873
|
onEvent: (event, message) => void publishInEntry("progress", { event, message, tags: ["js"] })
|
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
|
|
@@ -4271,6 +4270,8 @@ function getExports({
|
|
4271
4270
|
];
|
4272
4271
|
}
|
4273
4272
|
|
4273
|
+
var require = /* @__PURE__ */ createRequire$1(import.meta.url);
|
4274
|
+
|
4274
4275
|
let root;
|
4275
4276
|
function getRoot() {
|
4276
4277
|
if (root) return root;
|
@@ -4281,7 +4282,6 @@ function getRoot() {
|
|
4281
4282
|
|
4282
4283
|
let type = "";
|
4283
4284
|
try {
|
4284
|
-
const require = createRequire$1(import.meta.url);
|
4285
4285
|
require.resolve("@pnpm/filter-workspace-packages");
|
4286
4286
|
type = "pnpm";
|
4287
4287
|
} catch {
|
@@ -4311,10 +4311,9 @@ function getWD() {
|
|
4311
4311
|
return { wd, notWorkspace };
|
4312
4312
|
}
|
4313
4313
|
|
4314
|
-
const require$1 = createRequire$1(import.meta.url);
|
4315
4314
|
function packageIsExist(name) {
|
4316
4315
|
try {
|
4317
|
-
require
|
4316
|
+
require.resolve(name);
|
4318
4317
|
return true;
|
4319
4318
|
} catch (e) {
|
4320
4319
|
return false;
|
@@ -4334,7 +4333,6 @@ for (const register of registers) {
|
|
4334
4333
|
}
|
4335
4334
|
}
|
4336
4335
|
|
4337
|
-
const require = createRequire$1(import.meta.url);
|
4338
4336
|
let configName = "jiek.config";
|
4339
4337
|
function getConfigPath(root, dir) {
|
4340
4338
|
const isSupportTsLoader = !!tsRegisterName;
|
@@ -4479,43 +4477,16 @@ const getCompilerOptionsByFilePath = (tsconfigPath, filePath) => {
|
|
4479
4477
|
return tsconfig.compilerOptions;
|
4480
4478
|
};
|
4481
4479
|
|
4482
|
-
const
|
4483
|
-
const
|
4484
|
-
|
4485
|
-
|
4486
|
-
|
4487
|
-
export default (
|
4488
|
-
${isEsmVariableName}
|
4489
|
-
? /* @__PURE__ */ createRequire(import.meta.url)
|
4490
|
-
: require
|
4491
|
-
)
|
4480
|
+
const CREATE_REQUIRE_VIRTUAL_MODULE_NAME = "jiek:create-require";
|
4481
|
+
const INSERT_STR = (isESM) => `
|
4482
|
+
${isESM ? `import { createRequire } from 'node:module'` : ""}
|
4483
|
+
export default ${isESM ? "/* @__PURE__ */ createRequire(import.meta.url)" : "require"}
|
4492
4484
|
`.trim();
|
4493
|
-
var createRequire = () => ({
|
4494
|
-
...inject({
|
4495
|
-
require: virtualModuleName
|
4496
|
-
}),
|
4485
|
+
var createRequire = (isEsm) => ({
|
4497
4486
|
name: "create-require",
|
4498
|
-
resolveId: (
|
4499
|
-
load: (id) =>
|
4500
|
-
if (id !== virtualModuleName) {
|
4501
|
-
return null;
|
4502
|
-
}
|
4503
|
-
return INSERT_STR;
|
4504
|
-
}
|
4487
|
+
resolveId: (id) => id === CREATE_REQUIRE_VIRTUAL_MODULE_NAME ? id : null,
|
4488
|
+
load: (id) => id === CREATE_REQUIRE_VIRTUAL_MODULE_NAME ? INSERT_STR(isEsm) : null
|
4505
4489
|
});
|
4506
|
-
const isFormatEsm = (isEsm) => {
|
4507
|
-
const handler = replace({
|
4508
|
-
[isEsmVariableName]: isEsm
|
4509
|
-
}).renderChunk;
|
4510
|
-
return {
|
4511
|
-
name: "create-require-insert-format",
|
4512
|
-
// Pick out renderChunk because it's used as an output plugin
|
4513
|
-
renderChunk: {
|
4514
|
-
order: "pre",
|
4515
|
-
handler: typeof handler === "function" ? handler : handler.handler
|
4516
|
-
}
|
4517
|
-
};
|
4518
|
-
};
|
4519
4490
|
|
4520
4491
|
var progress = (options = {}) => {
|
4521
4492
|
const { onEvent } = options;
|
@@ -4865,9 +4836,7 @@ const generateConfigs = (context, options = {}) => {
|
|
4865
4836
|
strict: typeof options?.output?.strict === "object" ? options.output.strict.js : options?.output?.strict,
|
4866
4837
|
externalImportAttributes: features.keepImportAttributes !== false,
|
4867
4838
|
importAttributesKey: features.keepImportAttributes === false || features.keepImportAttributes === void 0 ? void 0 : features.keepImportAttributes === true ? "with" : features.keepImportAttributes,
|
4868
|
-
plugins: [
|
4869
|
-
isFormatEsm(format === "esm")
|
4870
|
-
]
|
4839
|
+
plugins: []
|
4871
4840
|
}, onlyOncePlugins)
|
4872
4841
|
],
|
4873
4842
|
plugins: [
|
@@ -4879,8 +4848,12 @@ const generateConfigs = (context, options = {}) => {
|
|
4879
4848
|
})
|
4880
4849
|
).catch(() => void 0),
|
4881
4850
|
commonjs(),
|
4882
|
-
createRequire(),
|
4883
4851
|
builder,
|
4852
|
+
// inject plugin can't resolve `import type`, so we should register it after the builder plugin
|
4853
|
+
inject({
|
4854
|
+
require: CREATE_REQUIRE_VIRTUAL_MODULE_NAME
|
4855
|
+
}),
|
4856
|
+
createRequire(format === "esm"),
|
4884
4857
|
ana,
|
4885
4858
|
progress({
|
4886
4859
|
onEvent: (event, message) => void publishInEntry("progress", { event, message, tags: ["js"] })
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "jiek",
|
3
3
|
"type": "module",
|
4
|
-
"version": "2.2.3-alpha.
|
4
|
+
"version": "2.2.3-alpha.5",
|
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",
|
@@ -78,7 +78,6 @@
|
|
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/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 = `
|
package/src/rollup/index.ts
CHANGED
@@ -8,6 +8,7 @@ import { getAllLeafs } from '@jiek/pkger/entrypoints'
|
|
8
8
|
import { dts } from '@jiek/rollup-plugin-dts'
|
9
9
|
import { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'
|
10
10
|
import commonjs from '@rollup/plugin-commonjs'
|
11
|
+
import inject from '@rollup/plugin-inject'
|
11
12
|
import json from '@rollup/plugin-json'
|
12
13
|
import { nodeResolve } from '@rollup/plugin-node-resolve'
|
13
14
|
import { isMatch } from 'micromatch'
|
@@ -23,7 +24,7 @@ import { recusiveListFiles } from '#~/utils/recusiveListFiles.ts'
|
|
23
24
|
import { getCompilerOptionsByFilePath } from '#~/utils/ts.ts'
|
24
25
|
|
25
26
|
import type { ConfigGenerateContext, TemplateOptions } from './base'
|
26
|
-
import createRequire, {
|
27
|
+
import createRequire, { CREATE_REQUIRE_VIRTUAL_MODULE_NAME } from './plugins/create-require'
|
27
28
|
import progress from './plugins/progress'
|
28
29
|
import skip from './plugins/skip'
|
29
30
|
import externalResolver from './utils/externalResolver'
|
@@ -468,9 +469,7 @@ const generateConfigs = (context: ConfigGenerateContext, options: TemplateOption
|
|
468
469
|
: features.keepImportAttributes === true
|
469
470
|
? 'with'
|
470
471
|
: features.keepImportAttributes,
|
471
|
-
plugins: [
|
472
|
-
isFormatEsm(format === 'esm')
|
473
|
-
]
|
472
|
+
plugins: []
|
474
473
|
}, onlyOncePlugins)
|
475
474
|
],
|
476
475
|
plugins: [
|
@@ -484,8 +483,12 @@ const generateConfigs = (context: ConfigGenerateContext, options: TemplateOption
|
|
484
483
|
)
|
485
484
|
.catch(() => void 0),
|
486
485
|
commonjs(),
|
487
|
-
createRequire(),
|
488
486
|
builder,
|
487
|
+
// inject plugin can't resolve `import type`, so we should register it after the builder plugin
|
488
|
+
inject({
|
489
|
+
require: CREATE_REQUIRE_VIRTUAL_MODULE_NAME
|
490
|
+
}),
|
491
|
+
createRequire(format === 'esm'),
|
489
492
|
ana,
|
490
493
|
progress({
|
491
494
|
onEvent: (event, message) => void publishInEntry('progress', { event, message, tags: ['js'] })
|
@@ -586,7 +589,6 @@ export function template(packageJSON: PackageJSON): RollupOptions[] {
|
|
586
589
|
return false
|
587
590
|
})
|
588
591
|
|
589
|
-
// console.log(exports)
|
590
592
|
const configs: RollupOptions[] = []
|
591
593
|
leafMap.forEach((keysArr, input) =>
|
592
594
|
keysArr.forEach((keys) => {
|
@@ -1,74 +1,23 @@
|
|
1
|
-
// https://github.com/privatenumber/pkgroll/blob/73559f8864203a50a5aa12c0a6503ceed3690aff/src/utils/rollup-plugins/create-require.ts#L1
|
2
|
-
// Thanks to @privatenumber for the snippet
|
3
|
-
|
4
|
-
import inject from '@rollup/plugin-inject'
|
5
|
-
import replace from '@rollup/plugin-replace'
|
6
1
|
import type { Plugin } from 'rollup'
|
7
2
|
|
8
|
-
const
|
9
|
-
|
10
|
-
/**
|
11
|
-
* Since rollup is bundled by rollup, it needs to add a run-time
|
12
|
-
* suffix so that this doesn't get replaced.
|
13
|
-
*/
|
14
|
-
const isEsmVariableName = `IS_ESM${Math.random().toString(36).slice(2)}`
|
15
|
-
|
16
|
-
const INSERT_STR = `
|
17
|
-
import { createRequire } from 'node:module'
|
3
|
+
export const CREATE_REQUIRE_VIRTUAL_MODULE_NAME = 'jiek:create-require'
|
18
4
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
)
|
5
|
+
const INSERT_STR = (isESM: boolean) =>
|
6
|
+
`
|
7
|
+
${isESM ? `import { createRequire } from 'node:module'` : ''}
|
8
|
+
export default ${isESM ? '/* @__PURE__ */ createRequire(import.meta.url)' : 'require'}
|
24
9
|
`.trim()
|
25
10
|
|
26
|
-
|
27
|
-
* Plugin to seamlessly allow usage of `require`
|
28
|
-
* across CJS and ESM modules.
|
29
|
-
*
|
30
|
-
* This is usually nor a problem for CJS outputs,
|
31
|
-
* but for ESM outputs, it must be used via
|
32
|
-
* createRequire.
|
33
|
-
*
|
34
|
-
* This plugin automatically injects it for ESM.
|
35
|
-
*/
|
36
|
-
export default (): Plugin => ({
|
37
|
-
...inject({
|
38
|
-
require: virtualModuleName
|
39
|
-
}),
|
40
|
-
|
11
|
+
export default (isEsm: boolean): Plugin => ({
|
41
12
|
name: 'create-require',
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
? source
|
13
|
+
resolveId: id => (
|
14
|
+
id === CREATE_REQUIRE_VIRTUAL_MODULE_NAME
|
15
|
+
? id
|
46
16
|
: null
|
47
17
|
),
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
return INSERT_STR
|
55
|
-
}
|
18
|
+
load: id => (
|
19
|
+
id === CREATE_REQUIRE_VIRTUAL_MODULE_NAME
|
20
|
+
? INSERT_STR(isEsm)
|
21
|
+
: null
|
22
|
+
)
|
56
23
|
})
|
57
|
-
|
58
|
-
export const isFormatEsm = (
|
59
|
-
isEsm: boolean
|
60
|
-
): Plugin => {
|
61
|
-
const handler = replace({
|
62
|
-
[isEsmVariableName]: isEsm
|
63
|
-
}).renderChunk!
|
64
|
-
|
65
|
-
return ({
|
66
|
-
name: 'create-require-insert-format',
|
67
|
-
|
68
|
-
// Pick out renderChunk because it's used as an output plugin
|
69
|
-
renderChunk: {
|
70
|
-
order: 'pre',
|
71
|
-
handler: typeof handler === 'function' ? handler : handler.handler
|
72
|
-
}
|
73
|
-
})
|
74
|
-
}
|
@@ -12,7 +12,7 @@ export async function checkDependency(dependency: string) {
|
|
12
12
|
console.error(`The package '${dependency}' is not installed, please install it first.`)
|
13
13
|
const { notWorkspace } = getWD()
|
14
14
|
const command = `pnpm install -${notWorkspace ? '' : 'w'}D ${dependency}`
|
15
|
-
if (await confirm({ message:
|
15
|
+
if (await confirm({ message: `Do you want to install it now? (${command})` })) {
|
16
16
|
execSync(command, {
|
17
17
|
stdio: 'inherit',
|
18
18
|
cwd: process.cwd(),
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import fs from 'node:fs'
|
2
|
-
import { createRequire } from 'node:module'
|
3
2
|
import path from 'node:path'
|
4
3
|
|
5
4
|
import { program } from 'commander'
|
@@ -11,7 +10,6 @@ import { getWD } from '#~/utils/getWD.ts'
|
|
11
10
|
export let type = ''
|
12
11
|
|
13
12
|
try {
|
14
|
-
const require = createRequire(import.meta.url)
|
15
13
|
require.resolve('@pnpm/filter-workspace-packages')
|
16
14
|
type = 'pnpm'
|
17
15
|
} catch { /* empty */ }
|
package/src/utils/loadConfig.ts
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
import fs from 'node:fs'
|
2
|
-
import { createRequire } from 'node:module'
|
3
2
|
import path from 'node:path'
|
4
3
|
|
5
4
|
import { program } from 'commander'
|
@@ -9,8 +8,6 @@ import { load } from 'js-yaml'
|
|
9
8
|
import { getWD } from './getWD'
|
10
9
|
import { tsRegisterName } from './tsRegister'
|
11
10
|
|
12
|
-
const require = createRequire(import.meta.url)
|
13
|
-
|
14
11
|
let configName = 'jiek.config'
|
15
12
|
|
16
13
|
function getConfigPath(root: string, dir?: string) {
|