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
@@ -0,0 +1 @@
|
|
1
|
+
{"type":"module","module":"../bin-helper.js","main":"../bin-helper.cjs"}
|
package/cli/package.json
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"type":"module","module":"../dist/cli.js","main":"../dist/cli.cjs"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"type":"module","module":"../dist/cli-only-build.js","main":"../dist/cli-only-build.cjs"}
|
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');
|
@@ -9,10 +8,10 @@ var getWorkspaceDir = require('@jiek/utils/getWorkspaceDir');
|
|
9
8
|
var process$1 = require('node:process');
|
10
9
|
var cliProgress = require('cli-progress');
|
11
10
|
var execa = require('execa');
|
11
|
+
var node_child_process = require('node:child_process');
|
12
12
|
var prompts = require('@inquirer/prompts');
|
13
13
|
var Koa = require('koa');
|
14
14
|
|
15
|
-
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
16
15
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
17
16
|
|
18
17
|
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
@@ -20,6 +19,8 @@ var path__default = /*#__PURE__*/_interopDefault(path);
|
|
20
19
|
var process__default = /*#__PURE__*/_interopDefault(process$1);
|
21
20
|
var Koa__default = /*#__PURE__*/_interopDefault(Koa);
|
22
21
|
|
22
|
+
var require$1 = require;
|
23
|
+
|
23
24
|
let root;
|
24
25
|
function getRoot() {
|
25
26
|
if (root) return root;
|
@@ -54,12 +55,11 @@ function getWD() {
|
|
54
55
|
|
55
56
|
let type$1 = "";
|
56
57
|
try {
|
57
|
-
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)));
|
58
58
|
require$1.resolve("@pnpm/filter-workspace-packages");
|
59
59
|
type$1 = "pnpm";
|
60
60
|
} catch {
|
61
61
|
}
|
62
|
-
function filterPackagesGraph(filters) {
|
62
|
+
async function filterPackagesGraph(filters) {
|
63
63
|
return Promise.all(filters.map(async (filter) => getSelectedProjectsGraph(filter)));
|
64
64
|
}
|
65
65
|
async function getSelectedProjectsGraph(filter = commander.program.getOptionValue("filter")) {
|
@@ -118,7 +118,7 @@ async function getSelectedProjectsGraph(filter = commander.program.getOptionValu
|
|
118
118
|
|
119
119
|
var name = "jiek";
|
120
120
|
var type = "module";
|
121
|
-
var version = "2.2.
|
121
|
+
var version = "2.2.5";
|
122
122
|
var description$1 = "A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.";
|
123
123
|
var author = "YiJie <yijie4188@gmail.com>";
|
124
124
|
var homepage = "https://github.com/NWYLZW/jiek/tree/master/packages/jiek#readme";
|
@@ -176,7 +176,7 @@ var scripts = {
|
|
176
176
|
test: "vitest run"
|
177
177
|
};
|
178
178
|
var peerDependencies = {
|
179
|
-
"@pnpm/filter-workspace-packages": "^7.2.13||^8.0.0||^9.0.0||^10.0.0",
|
179
|
+
"@pnpm/filter-workspace-packages": "^7.2.13||^8.0.0||^9.0.0||^10.0.0||>=1000.0.0",
|
180
180
|
"@rollup/plugin-terser": "^0.4.4",
|
181
181
|
"esbuild-register": "^3.5.0",
|
182
182
|
postcss: "^8.4.47",
|
@@ -187,7 +187,7 @@ var peerDependencies = {
|
|
187
187
|
"vite-bundle-analyzer": "0.16.0-beta.1"
|
188
188
|
};
|
189
189
|
var dependencies = {
|
190
|
-
"@inquirer/prompts": "^7.
|
190
|
+
"@inquirer/prompts": "^7.2.0",
|
191
191
|
"@jiek/pkger": "workspace:^",
|
192
192
|
"@jiek/rollup-plugin-dts": "^6.2.1",
|
193
193
|
"@jiek/utils": "workspace:^",
|
@@ -195,7 +195,6 @@ var dependencies = {
|
|
195
195
|
"@rollup/plugin-inject": "^5.0.5",
|
196
196
|
"@rollup/plugin-json": "^6.0.1",
|
197
197
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
198
|
-
"@rollup/plugin-replace": "^6.0.1",
|
199
198
|
"cli-progress": "^3.12.0",
|
200
199
|
commander: "^12.0.0",
|
201
200
|
"detect-indent": "^6.1.0",
|
@@ -378,13 +377,17 @@ function parseBoolean(v) {
|
|
378
377
|
|
379
378
|
async function checkDependency(dependency) {
|
380
379
|
try {
|
381
|
-
require.resolve(dependency);
|
380
|
+
require$1.resolve(dependency);
|
382
381
|
} catch {
|
383
382
|
console.error(`The package '${dependency}' is not installed, please install it first.`);
|
384
383
|
const { notWorkspace } = getWD();
|
385
|
-
const command = `pnpm
|
386
|
-
if (await prompts.confirm({ message:
|
387
|
-
|
384
|
+
const command = `pnpm add -${notWorkspace ? "" : "w"}D ${dependency}`;
|
385
|
+
if (await prompts.confirm({ message: `Do you want to add it now? (${command})` })) {
|
386
|
+
node_child_process.execSync(command, {
|
387
|
+
stdio: "inherit",
|
388
|
+
cwd: process__default.default.cwd(),
|
389
|
+
env: process__default.default.env
|
390
|
+
});
|
388
391
|
} else {
|
389
392
|
console.warn(`You can run the command '${command}' to install it manually.`);
|
390
393
|
process__default.default.exit(1);
|
@@ -501,10 +504,9 @@ const createServer = (port, host) => {
|
|
501
504
|
};
|
502
505
|
};
|
503
506
|
|
504
|
-
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)));
|
505
507
|
function packageIsExist(name) {
|
506
508
|
try {
|
507
|
-
require$
|
509
|
+
require$1.resolve(name);
|
508
510
|
return true;
|
509
511
|
} catch (e) {
|
510
512
|
return false;
|
@@ -524,7 +526,6 @@ for (const register of registers) {
|
|
524
526
|
}
|
525
527
|
}
|
526
528
|
|
527
|
-
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)));
|
528
529
|
let configName = "jiek.config";
|
529
530
|
function getConfigPath(root, dir) {
|
530
531
|
const isSupportTsLoader = !!tsRegisterName;
|
@@ -578,16 +579,16 @@ function loadConfig(dirOrOptions) {
|
|
578
579
|
let module;
|
579
580
|
switch (ext) {
|
580
581
|
case ".js":
|
581
|
-
module = require$
|
582
|
+
module = require$1(configPath);
|
582
583
|
break;
|
583
584
|
case ".json":
|
584
|
-
return require$
|
585
|
+
return require$1(configPath);
|
585
586
|
case ".yaml":
|
586
587
|
return jsYaml.load(fs__default.default.readFileSync(configPath, "utf-8"));
|
587
588
|
case ".ts":
|
588
589
|
if (tsRegisterName) {
|
589
|
-
require$
|
590
|
-
module = require$
|
590
|
+
require$1(tsRegisterName);
|
591
|
+
module = require$1(configPath);
|
591
592
|
break;
|
592
593
|
}
|
593
594
|
throw new Error(
|
@@ -606,7 +607,6 @@ function loadConfig(dirOrOptions) {
|
|
606
607
|
const FILE_TEMPLATE = (manifest) => `
|
607
608
|
module.exports = require('jiek/rollup').template(${JSON.stringify(manifest, null, 2)})
|
608
609
|
`.trimStart();
|
609
|
-
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)));
|
610
610
|
const isDefault = process__default.default.env.JIEK_IS_ONLY_BUILD === "true";
|
611
611
|
const description = `
|
612
612
|
Build the package according to the 'exports' field from the package.json.
|
@@ -646,7 +646,7 @@ command = command.description(description).option("-t, --type <TYPE>", `The type
|
|
646
646
|
throw new Error(`The value of 'type' must be ${BUILDER_TYPES.map((s) => `"${s}"`).join(", ")}`);
|
647
647
|
}
|
648
648
|
return String(v);
|
649
|
-
}, "esbuild").option("-o, --outdir <OUTDIR>", outdirDescription, String, "dist").option("-e, --entries <ENTRIES>", entriesDescription).option("--external <EXTERNAL>", "Specify the external dependencies of the package.", String).option("-nj, --noJs", "Do not output js files.", parseBoolean).option("-nd, --noDts", "Do not output dts files.", parseBoolean).option("-nm, --noMin", "Do not output minify files.", parseBoolean).option(
|
649
|
+
}, "esbuild").option("-o, --outdir <OUTDIR>", outdirDescription, String, "dist").option("-e, --entries <ENTRIES>", entriesDescription).option("--external <EXTERNAL>", "Specify the external dependencies of the package.", String).option("--noConvert", "Specify the `crossModuleConvertor` option to false.", parseBoolean).option("-nj, --noJs", "Do not output js files.", parseBoolean).option("-nd, --noDts", "Do not output dts files.", parseBoolean).option("-nm, --noMin", "Do not output minify files.", parseBoolean).option(
|
650
650
|
"--minType <MINTYPE>",
|
651
651
|
'The type of minify, support "builder" and "terser".',
|
652
652
|
(v) => {
|
@@ -673,6 +673,7 @@ command.action(async (commandFiltersOrEntries, options) => {
|
|
673
673
|
verbose,
|
674
674
|
entries: optionEntries,
|
675
675
|
external,
|
676
|
+
noConvert,
|
676
677
|
noJs: withoutJs,
|
677
678
|
noDts: withoutDts,
|
678
679
|
noMin: withoutMin,
|
@@ -689,13 +690,8 @@ command.action(async (commandFiltersOrEntries, options) => {
|
|
689
690
|
minifyType = resolvedType;
|
690
691
|
}
|
691
692
|
}
|
692
|
-
if (!withoutMin) {
|
693
|
-
await checkDependency(
|
694
|
-
{
|
695
|
-
...BUILDER_TYPE_PACKAGE_NAME_MAP,
|
696
|
-
terser: "@rollup/plugin-terser"
|
697
|
-
}[resolvedType]
|
698
|
-
);
|
693
|
+
if (!withoutMin && minifyType === "terser") {
|
694
|
+
await checkDependency("@rollup/plugin-terser");
|
699
695
|
}
|
700
696
|
let shouldPassThrough = false;
|
701
697
|
const passThroughOptions = process__default.default.argv.reduce(
|
@@ -740,6 +736,7 @@ command.action(async (commandFiltersOrEntries, options) => {
|
|
740
736
|
JIEK_CLEAN: String(!noClean),
|
741
737
|
JIEK_ENTRIES: entries,
|
742
738
|
JIEK_EXTERNAL: external,
|
739
|
+
JIEK_CROSS_MODULE_CONVERTOR: String(!noConvert),
|
743
740
|
JIEK_WITHOUT_JS: String(withoutJs),
|
744
741
|
JIEK_WITHOUT_DTS: String(withoutDts),
|
745
742
|
JIEK_WITHOUT_MINIFY: String(withoutMin),
|
@@ -918,12 +915,15 @@ command.action(async (commandFiltersOrEntries, options) => {
|
|
918
915
|
}
|
919
916
|
});
|
920
917
|
await new Promise((resolve, reject) => {
|
921
|
-
let errorStr =
|
918
|
+
let errorStr = `rollup build failed
|
919
|
+
package name: ${manifest.name}
|
920
|
+
cwd: ${pkgCWD}
|
921
|
+
|
922
|
+
`;
|
922
923
|
child.stderr?.on("data", (data) => {
|
923
924
|
errorStr += data;
|
924
925
|
});
|
925
|
-
child.once("exit", (code) => code === 0 ? resolve() : reject(new Error(
|
926
|
-
${errorStr}`)));
|
926
|
+
child.once("exit", (code) => code === 0 ? resolve() : reject(new Error(errorStr)));
|
927
927
|
verbose && child.stdout?.pipe(process__default.default.stdout);
|
928
928
|
});
|
929
929
|
})
|
@@ -86,6 +86,30 @@ interface TemplateOptions {
|
|
86
86
|
js?: InputPluginOption;
|
87
87
|
dts: InputPluginOption;
|
88
88
|
};
|
89
|
+
/**
|
90
|
+
* https://www.npmjs.com/package/@rollup/plugin-inject#usage
|
91
|
+
*
|
92
|
+
* @example
|
93
|
+
* ```js
|
94
|
+
* {
|
95
|
+
* // import { Promise } from 'es6-promise'
|
96
|
+
* Promise: [ 'es6-promise', 'Promise' ],
|
97
|
+
*
|
98
|
+
* // import { Promise as P } from 'es6-promise'
|
99
|
+
* P: [ 'es6-promise', 'Promise' ],
|
100
|
+
*
|
101
|
+
* // import $ from 'jquery'
|
102
|
+
* $: 'jquery',
|
103
|
+
*
|
104
|
+
* // import * as fs from 'fs'
|
105
|
+
* fs: [ 'fs', '*' ],
|
106
|
+
*
|
107
|
+
* // use a local module instead of a third-party one
|
108
|
+
* 'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
|
109
|
+
* }
|
110
|
+
* ```
|
111
|
+
*/
|
112
|
+
injects?: Record<string, string | [string, string]>;
|
89
113
|
}
|
90
114
|
|
91
115
|
declare module 'jiek' {
|
package/dist/cli-only-build.d.ts
CHANGED
@@ -86,6 +86,30 @@ interface TemplateOptions {
|
|
86
86
|
js?: InputPluginOption;
|
87
87
|
dts: InputPluginOption;
|
88
88
|
};
|
89
|
+
/**
|
90
|
+
* https://www.npmjs.com/package/@rollup/plugin-inject#usage
|
91
|
+
*
|
92
|
+
* @example
|
93
|
+
* ```js
|
94
|
+
* {
|
95
|
+
* // import { Promise } from 'es6-promise'
|
96
|
+
* Promise: [ 'es6-promise', 'Promise' ],
|
97
|
+
*
|
98
|
+
* // import { Promise as P } from 'es6-promise'
|
99
|
+
* P: [ 'es6-promise', 'Promise' ],
|
100
|
+
*
|
101
|
+
* // import $ from 'jquery'
|
102
|
+
* $: 'jquery',
|
103
|
+
*
|
104
|
+
* // import * as fs from 'fs'
|
105
|
+
* fs: [ 'fs', '*' ],
|
106
|
+
*
|
107
|
+
* // use a local module instead of a third-party one
|
108
|
+
* 'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
|
109
|
+
* }
|
110
|
+
* ```
|
111
|
+
*/
|
112
|
+
injects?: Record<string, string | [string, string]>;
|
89
113
|
}
|
90
114
|
|
91
115
|
declare module 'jiek' {
|
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';
|
@@ -7,9 +7,12 @@ import { isWorkspaceDir, getWorkspaceDir } from '@jiek/utils/getWorkspaceDir';
|
|
7
7
|
import process$1 from 'node:process';
|
8
8
|
import { MultiBar, Presets } from 'cli-progress';
|
9
9
|
import { execaCommand } from 'execa';
|
10
|
+
import { execSync } from 'node:child_process';
|
10
11
|
import { confirm } from '@inquirer/prompts';
|
11
12
|
import Koa from 'koa';
|
12
13
|
|
14
|
+
var require = /* @__PURE__ */ createRequire(import.meta.url);
|
15
|
+
|
13
16
|
let root;
|
14
17
|
function getRoot() {
|
15
18
|
if (root) return root;
|
@@ -44,12 +47,11 @@ function getWD() {
|
|
44
47
|
|
45
48
|
let type$1 = "";
|
46
49
|
try {
|
47
|
-
const require = createRequire(import.meta.url);
|
48
50
|
require.resolve("@pnpm/filter-workspace-packages");
|
49
51
|
type$1 = "pnpm";
|
50
52
|
} catch {
|
51
53
|
}
|
52
|
-
function filterPackagesGraph(filters) {
|
54
|
+
async function filterPackagesGraph(filters) {
|
53
55
|
return Promise.all(filters.map(async (filter) => getSelectedProjectsGraph(filter)));
|
54
56
|
}
|
55
57
|
async function getSelectedProjectsGraph(filter = program.getOptionValue("filter")) {
|
@@ -108,7 +110,7 @@ async function getSelectedProjectsGraph(filter = program.getOptionValue("filter"
|
|
108
110
|
|
109
111
|
var name = "jiek";
|
110
112
|
var type = "module";
|
111
|
-
var version = "2.2.
|
113
|
+
var version = "2.2.5";
|
112
114
|
var description$1 = "A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.";
|
113
115
|
var author = "YiJie <yijie4188@gmail.com>";
|
114
116
|
var homepage = "https://github.com/NWYLZW/jiek/tree/master/packages/jiek#readme";
|
@@ -166,7 +168,7 @@ var scripts = {
|
|
166
168
|
test: "vitest run"
|
167
169
|
};
|
168
170
|
var peerDependencies = {
|
169
|
-
"@pnpm/filter-workspace-packages": "^7.2.13||^8.0.0||^9.0.0||^10.0.0",
|
171
|
+
"@pnpm/filter-workspace-packages": "^7.2.13||^8.0.0||^9.0.0||^10.0.0||>=1000.0.0",
|
170
172
|
"@rollup/plugin-terser": "^0.4.4",
|
171
173
|
"esbuild-register": "^3.5.0",
|
172
174
|
postcss: "^8.4.47",
|
@@ -177,7 +179,7 @@ var peerDependencies = {
|
|
177
179
|
"vite-bundle-analyzer": "0.16.0-beta.1"
|
178
180
|
};
|
179
181
|
var dependencies = {
|
180
|
-
"@inquirer/prompts": "^7.
|
182
|
+
"@inquirer/prompts": "^7.2.0",
|
181
183
|
"@jiek/pkger": "workspace:^",
|
182
184
|
"@jiek/rollup-plugin-dts": "^6.2.1",
|
183
185
|
"@jiek/utils": "workspace:^",
|
@@ -185,7 +187,6 @@ var dependencies = {
|
|
185
187
|
"@rollup/plugin-inject": "^5.0.5",
|
186
188
|
"@rollup/plugin-json": "^6.0.1",
|
187
189
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
188
|
-
"@rollup/plugin-replace": "^6.0.1",
|
189
190
|
"cli-progress": "^3.12.0",
|
190
191
|
commander: "^12.0.0",
|
191
192
|
"detect-indent": "^6.1.0",
|
@@ -372,9 +373,13 @@ async function checkDependency(dependency) {
|
|
372
373
|
} catch {
|
373
374
|
console.error(`The package '${dependency}' is not installed, please install it first.`);
|
374
375
|
const { notWorkspace } = getWD();
|
375
|
-
const command = `pnpm
|
376
|
-
if (await confirm({ message:
|
377
|
-
|
376
|
+
const command = `pnpm add -${notWorkspace ? "" : "w"}D ${dependency}`;
|
377
|
+
if (await confirm({ message: `Do you want to add it now? (${command})` })) {
|
378
|
+
execSync(command, {
|
379
|
+
stdio: "inherit",
|
380
|
+
cwd: process$1.cwd(),
|
381
|
+
env: process$1.env
|
382
|
+
});
|
378
383
|
} else {
|
379
384
|
console.warn(`You can run the command '${command}' to install it manually.`);
|
380
385
|
process$1.exit(1);
|
@@ -491,10 +496,9 @@ const createServer = (port, host) => {
|
|
491
496
|
};
|
492
497
|
};
|
493
498
|
|
494
|
-
const require$3 = createRequire(import.meta.url);
|
495
499
|
function packageIsExist(name) {
|
496
500
|
try {
|
497
|
-
require
|
501
|
+
require.resolve(name);
|
498
502
|
return true;
|
499
503
|
} catch (e) {
|
500
504
|
return false;
|
@@ -514,7 +518,6 @@ for (const register of registers) {
|
|
514
518
|
}
|
515
519
|
}
|
516
520
|
|
517
|
-
const require$2 = createRequire(import.meta.url);
|
518
521
|
let configName = "jiek.config";
|
519
522
|
function getConfigPath(root, dir) {
|
520
523
|
const isSupportTsLoader = !!tsRegisterName;
|
@@ -568,16 +571,16 @@ function loadConfig(dirOrOptions) {
|
|
568
571
|
let module;
|
569
572
|
switch (ext) {
|
570
573
|
case ".js":
|
571
|
-
module = require
|
574
|
+
module = require(configPath);
|
572
575
|
break;
|
573
576
|
case ".json":
|
574
|
-
return require
|
577
|
+
return require(configPath);
|
575
578
|
case ".yaml":
|
576
579
|
return load(fs.readFileSync(configPath, "utf-8"));
|
577
580
|
case ".ts":
|
578
581
|
if (tsRegisterName) {
|
579
|
-
require
|
580
|
-
module = require
|
582
|
+
require(tsRegisterName);
|
583
|
+
module = require(configPath);
|
581
584
|
break;
|
582
585
|
}
|
583
586
|
throw new Error(
|
@@ -596,7 +599,6 @@ function loadConfig(dirOrOptions) {
|
|
596
599
|
const FILE_TEMPLATE = (manifest) => `
|
597
600
|
module.exports = require('jiek/rollup').template(${JSON.stringify(manifest, null, 2)})
|
598
601
|
`.trimStart();
|
599
|
-
const require$1 = createRequire(import.meta.url);
|
600
602
|
const isDefault = process$1.env.JIEK_IS_ONLY_BUILD === "true";
|
601
603
|
const description = `
|
602
604
|
Build the package according to the 'exports' field from the package.json.
|
@@ -606,7 +608,7 @@ ${isDefault ? "This command is the default command." : ""}
|
|
606
608
|
let DEFAULT_BUILDER_TYPE;
|
607
609
|
Object.entries(BUILDER_TYPE_PACKAGE_NAME_MAP).forEach(([type, packageName]) => {
|
608
610
|
try {
|
609
|
-
require
|
611
|
+
require.resolve(packageName);
|
610
612
|
DEFAULT_BUILDER_TYPE = type;
|
611
613
|
} catch {
|
612
614
|
}
|
@@ -636,7 +638,7 @@ command = command.description(description).option("-t, --type <TYPE>", `The type
|
|
636
638
|
throw new Error(`The value of 'type' must be ${BUILDER_TYPES.map((s) => `"${s}"`).join(", ")}`);
|
637
639
|
}
|
638
640
|
return String(v);
|
639
|
-
}, "esbuild").option("-o, --outdir <OUTDIR>", outdirDescription, String, "dist").option("-e, --entries <ENTRIES>", entriesDescription).option("--external <EXTERNAL>", "Specify the external dependencies of the package.", String).option("-nj, --noJs", "Do not output js files.", parseBoolean).option("-nd, --noDts", "Do not output dts files.", parseBoolean).option("-nm, --noMin", "Do not output minify files.", parseBoolean).option(
|
641
|
+
}, "esbuild").option("-o, --outdir <OUTDIR>", outdirDescription, String, "dist").option("-e, --entries <ENTRIES>", entriesDescription).option("--external <EXTERNAL>", "Specify the external dependencies of the package.", String).option("--noConvert", "Specify the `crossModuleConvertor` option to false.", parseBoolean).option("-nj, --noJs", "Do not output js files.", parseBoolean).option("-nd, --noDts", "Do not output dts files.", parseBoolean).option("-nm, --noMin", "Do not output minify files.", parseBoolean).option(
|
640
642
|
"--minType <MINTYPE>",
|
641
643
|
'The type of minify, support "builder" and "terser".',
|
642
644
|
(v) => {
|
@@ -663,6 +665,7 @@ command.action(async (commandFiltersOrEntries, options) => {
|
|
663
665
|
verbose,
|
664
666
|
entries: optionEntries,
|
665
667
|
external,
|
668
|
+
noConvert,
|
666
669
|
noJs: withoutJs,
|
667
670
|
noDts: withoutDts,
|
668
671
|
noMin: withoutMin,
|
@@ -679,13 +682,8 @@ command.action(async (commandFiltersOrEntries, options) => {
|
|
679
682
|
minifyType = resolvedType;
|
680
683
|
}
|
681
684
|
}
|
682
|
-
if (!withoutMin) {
|
683
|
-
await checkDependency(
|
684
|
-
{
|
685
|
-
...BUILDER_TYPE_PACKAGE_NAME_MAP,
|
686
|
-
terser: "@rollup/plugin-terser"
|
687
|
-
}[resolvedType]
|
688
|
-
);
|
685
|
+
if (!withoutMin && minifyType === "terser") {
|
686
|
+
await checkDependency("@rollup/plugin-terser");
|
689
687
|
}
|
690
688
|
let shouldPassThrough = false;
|
691
689
|
const passThroughOptions = process$1.argv.reduce(
|
@@ -730,6 +728,7 @@ command.action(async (commandFiltersOrEntries, options) => {
|
|
730
728
|
JIEK_CLEAN: String(!noClean),
|
731
729
|
JIEK_ENTRIES: entries,
|
732
730
|
JIEK_EXTERNAL: external,
|
731
|
+
JIEK_CROSS_MODULE_CONVERTOR: String(!noConvert),
|
733
732
|
JIEK_WITHOUT_JS: String(withoutJs),
|
734
733
|
JIEK_WITHOUT_DTS: String(withoutDts),
|
735
734
|
JIEK_WITHOUT_MINIFY: String(withoutMin),
|
@@ -763,7 +762,7 @@ command.action(async (commandFiltersOrEntries, options) => {
|
|
763
762
|
} catch {
|
764
763
|
}
|
765
764
|
}
|
766
|
-
const rollupBinaryPath = require
|
765
|
+
const rollupBinaryPath = require.resolve("rollup").replace(/dist\/rollup.js$/, "dist/bin/rollup");
|
767
766
|
let i = 0;
|
768
767
|
await Promise.all(
|
769
768
|
Object.entries(value).map(async ([pkgCWD, manifest]) => {
|
@@ -908,12 +907,15 @@ command.action(async (commandFiltersOrEntries, options) => {
|
|
908
907
|
}
|
909
908
|
});
|
910
909
|
await new Promise((resolve, reject) => {
|
911
|
-
let errorStr =
|
910
|
+
let errorStr = `rollup build failed
|
911
|
+
package name: ${manifest.name}
|
912
|
+
cwd: ${pkgCWD}
|
913
|
+
|
914
|
+
`;
|
912
915
|
child.stderr?.on("data", (data) => {
|
913
916
|
errorStr += data;
|
914
917
|
});
|
915
|
-
child.once("exit", (code) => code === 0 ? resolve() : reject(new Error(
|
916
|
-
${errorStr}`)));
|
918
|
+
child.once("exit", (code) => code === 0 ? resolve() : reject(new Error(errorStr)));
|
917
919
|
verbose && child.stdout?.pipe(process$1.stdout);
|
918
920
|
});
|
919
921
|
})
|