jiek 2.1.11 → 2.1.13
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.cjs +18 -0
- package/bin-helper.js +3 -0
- package/dist/cli-only-build.cjs +338 -146
- package/dist/cli-only-build.js +333 -143
- package/dist/cli.cjs +40 -4
- package/dist/cli.js +36 -1
- package/dist/rollup/index.cjs +147 -55
- package/dist/rollup/index.js +146 -57
- package/package.json +46 -42
- package/src/bin/build.ts +0 -0
- package/src/bridge.ts +42 -0
- package/src/cli-only-build.ts +5 -3
- package/src/cli.ts +2 -2
- package/src/commands/base.ts +1 -0
- package/src/commands/build.ts +281 -100
- package/src/commands/publish.ts +11 -0
- package/src/parseArgv.ts +26 -0
- package/src/rollup/base.ts +0 -35
- package/src/rollup/bundle-analyzer.ts +62 -0
- package/src/rollup/index.ts +70 -55
- package/src/rollup/plugins/create-require.ts +74 -0
- package/src/server.ts +22 -0
package/dist/cli.cjs
CHANGED
@@ -14,6 +14,7 @@ var entrypoints = require('@jiek/pkger/entrypoints');
|
|
14
14
|
var require$$0 = require('util');
|
15
15
|
var require$$0$1 = require('path');
|
16
16
|
require('jiek/cli-only-build');
|
17
|
+
var process$1 = require('node:process');
|
17
18
|
|
18
19
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
19
20
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
@@ -42,6 +43,7 @@ var path__default = /*#__PURE__*/_interopDefault(path);
|
|
42
43
|
var detectIndent__default = /*#__PURE__*/_interopDefault(detectIndent);
|
43
44
|
var require$$0__default = /*#__PURE__*/_interopDefault(require$$0);
|
44
45
|
var require$$0__default$1 = /*#__PURE__*/_interopDefault(require$$0$1);
|
46
|
+
var process__default = /*#__PURE__*/_interopDefault(process$1);
|
45
47
|
|
46
48
|
let root;
|
47
49
|
function getRoot() {
|
@@ -79,7 +81,7 @@ function getWD() {
|
|
79
81
|
|
80
82
|
let type = "";
|
81
83
|
try {
|
82
|
-
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href)));
|
84
|
+
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
85
|
require$1.resolve("@pnpm/filter-workspace-packages");
|
84
86
|
type = "pnpm";
|
85
87
|
} catch {
|
@@ -4335,7 +4337,7 @@ function getExports({
|
|
4335
4337
|
];
|
4336
4338
|
}
|
4337
4339
|
|
4338
|
-
const require$2 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href)));
|
4340
|
+
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)));
|
4339
4341
|
function packageIsExist(name) {
|
4340
4342
|
try {
|
4341
4343
|
require$2.resolve(name);
|
@@ -4358,7 +4360,7 @@ for (const register of registers) {
|
|
4358
4360
|
}
|
4359
4361
|
}
|
4360
4362
|
|
4361
|
-
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href)));
|
4363
|
+
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)));
|
4362
4364
|
let configName = "jiek.config";
|
4363
4365
|
function getConfigPath(root, dir) {
|
4364
4366
|
const isSupportTsLoader = !!tsRegisterName;
|
@@ -4606,6 +4608,17 @@ async function prepublish() {
|
|
4606
4608
|
}
|
4607
4609
|
}
|
4608
4610
|
}
|
4611
|
+
if (oldJSON["devDependencies"]) {
|
4612
|
+
newJSONString = jsoncParser.applyEdits(
|
4613
|
+
newJSONString,
|
4614
|
+
jsoncParser.modify(
|
4615
|
+
newJSONString,
|
4616
|
+
["devDependencies"],
|
4617
|
+
void 0,
|
4618
|
+
{ formattingOptions }
|
4619
|
+
)
|
4620
|
+
);
|
4621
|
+
}
|
4609
4622
|
if (oldJSON["peerDependencies"]) {
|
4610
4623
|
const peerDependenciesMeta = Object.keys(oldJSON["peerDependencies"]).reduce(
|
4611
4624
|
(acc, key) => {
|
@@ -4802,4 +4815,27 @@ Restore package.json after publish, you can add \`jk\` to the \`postpublish\` sc
|
|
4802
4815
|
`.trim();
|
4803
4816
|
commander.program.command("postpublish").description(postpublishDescription).action(postpublish);
|
4804
4817
|
|
4805
|
-
|
4818
|
+
const { argv } = process__default.default;
|
4819
|
+
const env = {};
|
4820
|
+
let isPassThrough = false;
|
4821
|
+
const newArgv = argv.filter((arg) => {
|
4822
|
+
if (isPassThrough) {
|
4823
|
+
return true;
|
4824
|
+
}
|
4825
|
+
if (arg === "--") {
|
4826
|
+
isPassThrough = true;
|
4827
|
+
return false;
|
4828
|
+
}
|
4829
|
+
const m = /^--env\.(\w+)=(.*)$/.exec(arg);
|
4830
|
+
if (m) {
|
4831
|
+
env[m[1]] = m[2];
|
4832
|
+
return false;
|
4833
|
+
}
|
4834
|
+
return true;
|
4835
|
+
});
|
4836
|
+
for (const [key, value] of Object.entries(env)) {
|
4837
|
+
process__default.default.env[key] = value;
|
4838
|
+
}
|
4839
|
+
var parseArgv = () => commander.program.parse(newArgv);
|
4840
|
+
|
4841
|
+
parseArgv();
|
package/dist/cli.js
CHANGED
@@ -12,6 +12,7 @@ import { resolveEntrypoints, filterLeafs, DEFAULT_SKIP_VALUES, entrypoints2Expor
|
|
12
12
|
import require$$0 from 'util';
|
13
13
|
import require$$0$1 from 'path';
|
14
14
|
import 'jiek/cli-only-build';
|
15
|
+
import process$1 from 'node:process';
|
15
16
|
|
16
17
|
let root;
|
17
18
|
function getRoot() {
|
@@ -4576,6 +4577,17 @@ async function prepublish() {
|
|
4576
4577
|
}
|
4577
4578
|
}
|
4578
4579
|
}
|
4580
|
+
if (oldJSON["devDependencies"]) {
|
4581
|
+
newJSONString = applyEdits(
|
4582
|
+
newJSONString,
|
4583
|
+
modify(
|
4584
|
+
newJSONString,
|
4585
|
+
["devDependencies"],
|
4586
|
+
void 0,
|
4587
|
+
{ formattingOptions }
|
4588
|
+
)
|
4589
|
+
);
|
4590
|
+
}
|
4579
4591
|
if (oldJSON["peerDependencies"]) {
|
4580
4592
|
const peerDependenciesMeta = Object.keys(oldJSON["peerDependencies"]).reduce(
|
4581
4593
|
(acc, key) => {
|
@@ -4772,4 +4784,27 @@ Restore package.json after publish, you can add \`jk\` to the \`postpublish\` sc
|
|
4772
4784
|
`.trim();
|
4773
4785
|
program.command("postpublish").description(postpublishDescription).action(postpublish);
|
4774
4786
|
|
4775
|
-
|
4787
|
+
const { argv } = process$1;
|
4788
|
+
const env = {};
|
4789
|
+
let isPassThrough = false;
|
4790
|
+
const newArgv = argv.filter((arg) => {
|
4791
|
+
if (isPassThrough) {
|
4792
|
+
return true;
|
4793
|
+
}
|
4794
|
+
if (arg === "--") {
|
4795
|
+
isPassThrough = true;
|
4796
|
+
return false;
|
4797
|
+
}
|
4798
|
+
const m = /^--env\.(\w+)=(.*)$/.exec(arg);
|
4799
|
+
if (m) {
|
4800
|
+
env[m[1]] = m[2];
|
4801
|
+
return false;
|
4802
|
+
}
|
4803
|
+
return true;
|
4804
|
+
});
|
4805
|
+
for (const [key, value] of Object.entries(env)) {
|
4806
|
+
process$1.env[key] = value;
|
4807
|
+
}
|
4808
|
+
var parseArgv = () => program.parse(newArgv);
|
4809
|
+
|
4810
|
+
parseArgv();
|
package/dist/rollup/index.cjs
CHANGED
@@ -2,31 +2,37 @@
|
|
2
2
|
|
3
3
|
var fs = require('node:fs');
|
4
4
|
var path = require('node:path');
|
5
|
+
var process$1 = require('node:process');
|
5
6
|
var entrypoints = require('@jiek/pkger/entrypoints');
|
6
7
|
var rollupPluginDts = require('@jiek/rollup-plugin-dts');
|
7
8
|
var getWorkspaceDir = require('@jiek/utils/getWorkspaceDir');
|
8
9
|
var commonjs = require('@rollup/plugin-commonjs');
|
9
10
|
var json = require('@rollup/plugin-json');
|
10
11
|
var pluginNodeResolve = require('@rollup/plugin-node-resolve');
|
11
|
-
var execa = require('execa');
|
12
12
|
var require$$0 = require('util');
|
13
13
|
var require$$0$1 = require('path');
|
14
14
|
var ts = require('typescript');
|
15
|
+
var execa = require('execa');
|
15
16
|
var node_module = require('node:module');
|
16
17
|
var commander = require('commander');
|
17
18
|
var jsYaml = require('js-yaml');
|
18
19
|
var jsoncParser = require('jsonc-parser');
|
20
|
+
var inject = require('@rollup/plugin-inject');
|
21
|
+
var replace = require('@rollup/plugin-replace');
|
19
22
|
|
20
23
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
21
24
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
22
25
|
|
23
26
|
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
24
27
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
28
|
+
var process__default = /*#__PURE__*/_interopDefault(process$1);
|
25
29
|
var commonjs__default = /*#__PURE__*/_interopDefault(commonjs);
|
26
30
|
var json__default = /*#__PURE__*/_interopDefault(json);
|
27
31
|
var require$$0__default = /*#__PURE__*/_interopDefault(require$$0);
|
28
32
|
var require$$0__default$1 = /*#__PURE__*/_interopDefault(require$$0$1);
|
29
33
|
var ts__default = /*#__PURE__*/_interopDefault(ts);
|
34
|
+
var inject__default = /*#__PURE__*/_interopDefault(inject);
|
35
|
+
var replace__default = /*#__PURE__*/_interopDefault(replace);
|
30
36
|
|
31
37
|
var utils$1 = {};
|
32
38
|
|
@@ -4134,15 +4140,52 @@ function requireMicromatch () {
|
|
4134
4140
|
|
4135
4141
|
var micromatchExports = requireMicromatch();
|
4136
4142
|
|
4137
|
-
const
|
4138
|
-
|
4139
|
-
|
4140
|
-
|
4141
|
-
|
4142
|
-
|
4143
|
+
const publish = async (type, data) => {
|
4144
|
+
return execa.sendMessage({ type, data });
|
4145
|
+
};
|
4146
|
+
|
4147
|
+
const {
|
4148
|
+
JIEK_ANALYZER
|
4149
|
+
} = process__default.default.env;
|
4150
|
+
const ANALYZER = JIEK_ANALYZER != null && JSON.parse(JIEK_ANALYZER);
|
4151
|
+
function bundleAnalyzer(modulesResolved) {
|
4152
|
+
if (!ANALYZER) {
|
4153
|
+
return [];
|
4143
4154
|
}
|
4144
|
-
|
4145
|
-
|
4155
|
+
const defaultSizes = {
|
4156
|
+
parsed: "parsed",
|
4157
|
+
stat: "stat",
|
4158
|
+
gzip: "gzip"
|
4159
|
+
}[ANALYZER.size ?? "stat"] ?? "parsed";
|
4160
|
+
let ana;
|
4161
|
+
async function initAna() {
|
4162
|
+
const { adapter, analyzer } = await import('vite-bundle-analyzer');
|
4163
|
+
ana = ana ?? adapter(analyzer({
|
4164
|
+
defaultSizes,
|
4165
|
+
analyzerMode: modulesResolved
|
4166
|
+
}));
|
4167
|
+
}
|
4168
|
+
return [
|
4169
|
+
(async () => {
|
4170
|
+
await initAna();
|
4171
|
+
return {
|
4172
|
+
name: "jiek:bundle-analyzer",
|
4173
|
+
async closeBundle(...args) {
|
4174
|
+
if (typeof ana.closeBundle !== "function")
|
4175
|
+
return;
|
4176
|
+
return ana.closeBundle?.call(this, ...args);
|
4177
|
+
}
|
4178
|
+
};
|
4179
|
+
})(),
|
4180
|
+
(async () => {
|
4181
|
+
await initAna();
|
4182
|
+
return {
|
4183
|
+
...ana,
|
4184
|
+
name: "jiek:bundle-analyzer-output"
|
4185
|
+
};
|
4186
|
+
})()
|
4187
|
+
];
|
4188
|
+
}
|
4146
4189
|
|
4147
4190
|
const intersection = (a, b) => new Set([...a].filter((i) => b.has(i)));
|
4148
4191
|
const {
|
@@ -4246,7 +4289,7 @@ function getRoot() {
|
|
4246
4289
|
|
4247
4290
|
let type = "";
|
4248
4291
|
try {
|
4249
|
-
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('rollup/index.cjs', document.baseURI).href)));
|
4292
|
+
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)));
|
4250
4293
|
require$1.resolve("@pnpm/filter-workspace-packages");
|
4251
4294
|
type = "pnpm";
|
4252
4295
|
} catch {
|
@@ -4277,7 +4320,7 @@ function getWD() {
|
|
4277
4320
|
return { wd, notWorkspace };
|
4278
4321
|
}
|
4279
4322
|
|
4280
|
-
const require$2 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('rollup/index.cjs', document.baseURI).href)));
|
4323
|
+
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)));
|
4281
4324
|
function packageIsExist(name) {
|
4282
4325
|
try {
|
4283
4326
|
require$2.resolve(name);
|
@@ -4300,7 +4343,7 @@ for (const register of registers) {
|
|
4300
4343
|
}
|
4301
4344
|
}
|
4302
4345
|
|
4303
|
-
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('rollup/index.cjs', document.baseURI).href)));
|
4346
|
+
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)));
|
4304
4347
|
let configName = "jiek.config";
|
4305
4348
|
function getConfigPath(root, dir) {
|
4306
4349
|
const isSupportTsLoader = !!tsRegisterName;
|
@@ -4383,6 +4426,16 @@ function loadConfig(dirOrOptions) {
|
|
4383
4426
|
return module.default ?? module;
|
4384
4427
|
}
|
4385
4428
|
|
4429
|
+
const recusiveListFiles = (dir) => fs__default.default.readdirSync(dir).reduce((acc, file) => {
|
4430
|
+
const filePath = path.resolve(dir, file);
|
4431
|
+
if (fs__default.default.statSync(filePath).isDirectory()) {
|
4432
|
+
if (filePath.endsWith("/node_modules"))
|
4433
|
+
return acc;
|
4434
|
+
return [...acc, ...recusiveListFiles(filePath)];
|
4435
|
+
}
|
4436
|
+
return [...acc, filePath];
|
4437
|
+
}, []);
|
4438
|
+
|
4386
4439
|
const getTSConfig = (p) => !fs__default.default.existsSync(p) || !fs__default.default.statSync(p).isFile() ? {} : jsoncParser.parse(fs__default.default.readFileSync(p, "utf-8"), [], { allowTrailingComma: true, allowEmptyContent: true });
|
4387
4440
|
const getExtendTSConfig = (tsconfigPath) => {
|
4388
4441
|
tsconfigPath = path.resolve(tsconfigPath);
|
@@ -4442,6 +4495,44 @@ const getCompilerOptionsByFilePath = (tsconfigPath, filePath) => {
|
|
4442
4495
|
return tsconfig.compilerOptions;
|
4443
4496
|
};
|
4444
4497
|
|
4498
|
+
const virtualModuleName = "jiek:create-require";
|
4499
|
+
const isEsmVariableName = `IS_ESM${Math.random().toString(36).slice(2)}`;
|
4500
|
+
const INSERT_STR = `
|
4501
|
+
import { createRequire } from 'node:module'
|
4502
|
+
|
4503
|
+
export default (
|
4504
|
+
${isEsmVariableName}
|
4505
|
+
? /* @__PURE__ */ createRequire(import.meta.url)
|
4506
|
+
: require
|
4507
|
+
)
|
4508
|
+
`.trim();
|
4509
|
+
var createRequire = () => ({
|
4510
|
+
...inject__default.default({
|
4511
|
+
require: virtualModuleName
|
4512
|
+
}),
|
4513
|
+
name: "create-require",
|
4514
|
+
resolveId: (source) => source === virtualModuleName ? source : null,
|
4515
|
+
load: (id) => {
|
4516
|
+
if (id !== virtualModuleName) {
|
4517
|
+
return null;
|
4518
|
+
}
|
4519
|
+
return INSERT_STR;
|
4520
|
+
}
|
4521
|
+
});
|
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
|
+
|
4445
4536
|
var progress = (options = {}) => {
|
4446
4537
|
const { onEvent } = options;
|
4447
4538
|
return {
|
@@ -4507,7 +4598,7 @@ const {
|
|
4507
4598
|
JIEK_ONLY_MINIFY,
|
4508
4599
|
JIEK_TSCONFIG,
|
4509
4600
|
JIEK_DTSCONFIG
|
4510
|
-
} =
|
4601
|
+
} = process__default.default.env;
|
4511
4602
|
const resolveArrayString = (str) => {
|
4512
4603
|
const arr = [
|
4513
4604
|
...new Set(
|
@@ -4590,10 +4681,15 @@ const resolvedMinifyOptions = resolveMinifyOptions(build.output?.minifyOptions ?
|
|
4590
4681
|
const { type: _resolvedMinifyOptionsType, ...noTypeResolvedMinifyOptions } = resolvedMinifyOptions;
|
4591
4682
|
const resolvedBuilderOptions = resolveBuilderOptions(build.builder ?? BUILDER_OPTIONS);
|
4592
4683
|
const { type: _resolvedBuilderOptionsType, ...noTypeResolvedBuilderOptions } = resolvedBuilderOptions;
|
4593
|
-
const withMinify = (output,
|
4594
|
-
|
4684
|
+
const withMinify = (output, onlyOncePlugins = []) => {
|
4685
|
+
const minify = build?.output?.minify ?? MINIFY_DEFAULT_VALUE;
|
4686
|
+
output.plugins = output.plugins ?? [];
|
4687
|
+
if (minify === false) {
|
4688
|
+
output.plugins.push(...onlyOncePlugins);
|
4595
4689
|
return [output];
|
4690
|
+
}
|
4596
4691
|
const minifyPlugin = resolvedMinifyOptions.type === "esbuild" ? import('rollup-plugin-esbuild').then(({ minify: minify2 }) => minify2(noTypeResolvedMinifyOptions)) : resolvedMinifyOptions.type === "swc" ? import('rollup-plugin-swc3').then(({ minify: minify2 }) => minify2(noTypeResolvedMinifyOptions)) : import('@rollup/plugin-terser').then(({ default: minify2 }) => minify2(noTypeResolvedMinifyOptions));
|
4692
|
+
const notOnlyOncePlugins = output.plugins;
|
4597
4693
|
return minify === "only-minify" ? [{
|
4598
4694
|
...output,
|
4599
4695
|
// TODO replace suffix when pubish to npm and the `build.output.minify` is 'only-minify'
|
@@ -4602,7 +4698,7 @@ const withMinify = (output, minify = build?.output?.minify ?? MINIFY_DEFAULT_VAL
|
|
4602
4698
|
throw new Error("entryFileNames must be a function");
|
4603
4699
|
})(),
|
4604
4700
|
plugins: [
|
4605
|
-
...
|
4701
|
+
...notOnlyOncePlugins,
|
4606
4702
|
minifyPlugin
|
4607
4703
|
]
|
4608
4704
|
}] : [
|
@@ -4614,7 +4710,7 @@ const withMinify = (output, minify = build?.output?.minify ?? MINIFY_DEFAULT_VAL
|
|
4614
4710
|
})(),
|
4615
4711
|
file: output.file?.replace(/(\.[cm]?js)$/, ".min$1"),
|
4616
4712
|
plugins: [
|
4617
|
-
...
|
4713
|
+
...notOnlyOncePlugins,
|
4618
4714
|
minifyPlugin
|
4619
4715
|
]
|
4620
4716
|
}
|
@@ -4634,6 +4730,7 @@ const generateConfigs = (context, options = {}) => {
|
|
4634
4730
|
const isModule = conditionals.includes("import");
|
4635
4731
|
const isCommonJS = conditionals.includes("require");
|
4636
4732
|
const isBrowser = conditionals.includes("browser");
|
4733
|
+
const format = isModule ? "esm" : isCommonJS ? "cjs" : isBrowser ? "umd" : pkgIsModule ? "esm" : "cjs";
|
4637
4734
|
const dtsTSConfigPaths = [
|
4638
4735
|
resolveWorkspacePath("tsconfig.json"),
|
4639
4736
|
resolveWorkspacePath("tsconfig.dts.json")
|
@@ -4671,17 +4768,26 @@ const generateConfigs = (context, options = {}) => {
|
|
4671
4768
|
delete compilerOptions.composite;
|
4672
4769
|
}
|
4673
4770
|
const exportConditions = [...conditionals, ...compilerOptions.customConditions ?? []];
|
4674
|
-
const
|
4675
|
-
|
4676
|
-
|
4677
|
-
|
4771
|
+
const publishInEntry = (type, data) => (
|
4772
|
+
// eslint-disable-next-line ts/no-unsafe-argument
|
4773
|
+
void publish(type, {
|
4774
|
+
...{
|
4775
|
+
type: format,
|
4776
|
+
name,
|
4777
|
+
path: path$1,
|
4778
|
+
exportConditions,
|
4779
|
+
input
|
4780
|
+
},
|
4781
|
+
...data
|
4782
|
+
})
|
4783
|
+
);
|
4678
4784
|
const { js: jsPlugins, dts: dtsPlugins } = resolveBuildPlugins(context, build.plugins);
|
4679
4785
|
if (input.includes("**")) {
|
4680
4786
|
throw new Error(
|
4681
4787
|
'input should not include "**", please read the [documentation](https://nodejs.org/api/packages.html#subpath-patterns).'
|
4682
4788
|
);
|
4683
4789
|
}
|
4684
|
-
const inputObj = !input.includes("*") ? input : recusiveListFiles(
|
4790
|
+
const inputObj = !input.includes("*") ? input : recusiveListFiles(process__default.default.cwd()).filter((p) => /(?<!\.d)\.[cm]?tsx?$/.test(p)).map((p) => path.relative(process__default.default.cwd(), p)).filter((p) => micromatchExports.isMatch(p, input.slice(2)));
|
4685
4791
|
const globCommonDir = input.includes("*") ? input.split("*")[0].replace("./", "") : "";
|
4686
4792
|
const pathCommonDir = path$1.includes("*") ? path$1.split("*")[0].replace("./", "") : "";
|
4687
4793
|
if (globCommonDir.length > 0 && pathCommonDir.length === 0 || globCommonDir.length === 0 && pathCommonDir.length > 0) {
|
@@ -4712,6 +4818,10 @@ const generateConfigs = (context, options = {}) => {
|
|
4712
4818
|
...noTypeResolvedBuilderOptions
|
4713
4819
|
})
|
4714
4820
|
);
|
4821
|
+
const [ana, anaOutputPlugin] = bundleAnalyzer((modules) => void publishInEntry("modulesAnalyze", { modules }));
|
4822
|
+
const onlyOncePlugins = [
|
4823
|
+
anaOutputPlugin
|
4824
|
+
];
|
4715
4825
|
rollupOptions.push({
|
4716
4826
|
input: inputObj,
|
4717
4827
|
external,
|
@@ -4720,11 +4830,14 @@ const generateConfigs = (context, options = {}) => {
|
|
4720
4830
|
dir: jsOutdir,
|
4721
4831
|
name,
|
4722
4832
|
interop: "auto",
|
4723
|
-
entryFileNames: (chunkInfo) => Array.isArray(inputObj) ? chunkInfo.facadeModuleId.replace(`${
|
4833
|
+
entryFileNames: (chunkInfo) => Array.isArray(inputObj) ? chunkInfo.facadeModuleId.replace(`${process__default.default.cwd()}/`, "").replace(globCommonDir, pathCommonDir).replace(/(\.[cm]?)ts$/, jsOutputSuffix) : output.replace(`${jsOutdir}/`, ""),
|
4724
4834
|
sourcemap,
|
4725
|
-
format
|
4726
|
-
strict: typeof options?.output?.strict === "object" ? options.output.strict.js : options?.output?.strict
|
4727
|
-
|
4835
|
+
format,
|
4836
|
+
strict: typeof options?.output?.strict === "object" ? options.output.strict.js : options?.output?.strict,
|
4837
|
+
plugins: [
|
4838
|
+
isFormatEsm(format === "esm")
|
4839
|
+
]
|
4840
|
+
}, onlyOncePlugins)
|
4728
4841
|
],
|
4729
4842
|
plugins: [
|
4730
4843
|
...commonPlugins,
|
@@ -4734,15 +4847,12 @@ const generateConfigs = (context, options = {}) => {
|
|
4734
4847
|
minimize: true
|
4735
4848
|
})
|
4736
4849
|
).catch(() => void 0),
|
4737
|
-
builder,
|
4738
4850
|
commonjs__default.default(),
|
4851
|
+
createRequire(),
|
4852
|
+
builder,
|
4853
|
+
ana,
|
4739
4854
|
progress({
|
4740
|
-
onEvent: (event, message) =>
|
4741
|
-
{
|
4742
|
-
...throughEventProps,
|
4743
|
-
data: { ...throughEventProps.data, event, message, tags: ["js"] }
|
4744
|
-
}
|
4745
|
-
)
|
4855
|
+
onEvent: (event, message) => void publishInEntry("progress", { event, message, tags: ["js"] })
|
4746
4856
|
}),
|
4747
4857
|
jsPlugins
|
4748
4858
|
]
|
@@ -4756,7 +4866,7 @@ const generateConfigs = (context, options = {}) => {
|
|
4756
4866
|
{
|
4757
4867
|
dir: dtsOutdir,
|
4758
4868
|
sourcemap: typeof options?.output?.sourcemap === "object" ? options.output.sourcemap.dts : options?.output?.sourcemap,
|
4759
|
-
entryFileNames: (chunkInfo) => Array.isArray(inputObj) ? chunkInfo.facadeModuleId.replace(`${
|
4869
|
+
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),
|
4760
4870
|
strict: typeof options?.output?.strict === "object" ? options.output.strict.dts : options?.output?.strict
|
4761
4871
|
}
|
4762
4872
|
],
|
@@ -4779,12 +4889,7 @@ const generateConfigs = (context, options = {}) => {
|
|
4779
4889
|
tsconfig: dtsTSConfigPath
|
4780
4890
|
}),
|
4781
4891
|
progress({
|
4782
|
-
onEvent: (event, message) =>
|
4783
|
-
{
|
4784
|
-
...throughEventProps,
|
4785
|
-
data: { ...throughEventProps.data, event, message, tags: ["dts"] }
|
4786
|
-
}
|
4787
|
-
)
|
4892
|
+
onEvent: (event, message) => void publishInEntry("progress", { event, message, tags: ["dts"] })
|
4788
4893
|
}),
|
4789
4894
|
dtsPlugins
|
4790
4895
|
]
|
@@ -4794,12 +4899,7 @@ const generateConfigs = (context, options = {}) => {
|
|
4794
4899
|
rollupOptions[0].plugins = [
|
4795
4900
|
{
|
4796
4901
|
name: "jiek-plugin-watcher",
|
4797
|
-
watchChange: (id) =>
|
4798
|
-
{
|
4799
|
-
type: "watchChange",
|
4800
|
-
data: { id, name: JIEK_NAME, path: path$1, input }
|
4801
|
-
}
|
4802
|
-
)
|
4902
|
+
watchChange: (id) => void publishInEntry("watchChange", { id })
|
4803
4903
|
},
|
4804
4904
|
...rollupOptions[0].plugins
|
4805
4905
|
];
|
@@ -4871,15 +4971,7 @@ function template(packageJSON) {
|
|
4871
4971
|
}
|
4872
4972
|
})
|
4873
4973
|
);
|
4874
|
-
|
4875
|
-
{
|
4876
|
-
type: "init",
|
4877
|
-
data: {
|
4878
|
-
leafMap,
|
4879
|
-
targetsLength: configs.length
|
4880
|
-
}
|
4881
|
-
}
|
4882
|
-
);
|
4974
|
+
void publish("init", { leafMap, targetsLength: configs.length });
|
4883
4975
|
return configs.map((c) => ({
|
4884
4976
|
...COMMON_OPTIONS,
|
4885
4977
|
...c,
|