@reliverse/dler 1.7.16 → 1.7.17
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/README.md +134 -206
- package/bin/app/agg/run.js +2 -8
- package/bin/app/build/cmd.js +4 -4
- package/bin/app/build/impl.d.ts +2 -6
- package/bin/app/build/impl.js +2 -46
- package/bin/app/conv/cmd.d.ts +8 -33
- package/bin/app/conv/cmd.js +185 -163
- package/bin/app/copy/cmd.js +1 -1
- package/bin/app/init/init-impl.js +3 -3
- package/bin/app/init/init-types.d.ts +8 -8
- package/bin/app/merge/cmd.d.ts +10 -24
- package/bin/app/merge/cmd.js +47 -464
- package/bin/app/migrate/codemods/anything-bun.js +1 -1
- package/bin/app/migrate/codemods/fs-relifso.d.ts +2 -2
- package/bin/app/migrate/codemods/fs-relifso.js +1 -1
- package/bin/app/migrate/codemods/nodenext-bundler.d.ts +2 -2
- package/bin/app/migrate/codemods/nodenext-bundler.js +1 -1
- package/bin/app/migrate/codemods/path-pathkit.d.ts +2 -2
- package/bin/app/migrate/codemods/path-pathkit.js +1 -1
- package/bin/app/migrate/codemods/readdir-glob.d.ts +2 -2
- package/bin/app/migrate/codemods/readdir-glob.js +1 -1
- package/bin/app/mkdist/cmd.js +4 -2
- package/bin/app/pack/cmd.d.ts +44 -0
- package/bin/app/pack/cmd.js +313 -0
- package/bin/app/pub/cmd.js +4 -4
- package/bin/app/pub/impl.d.ts +7 -0
- package/bin/app/pub/impl.js +97 -0
- package/bin/app/rename/cmd.js +1 -1
- package/bin/app/spell/cmd.d.ts +14 -5
- package/bin/app/spell/cmd.js +33 -33
- package/bin/app/spell/old.js +0 -0
- package/bin/app/{mock → unpack}/cmd.d.ts +10 -14
- package/bin/app/unpack/cmd.js +200 -0
- package/bin/cli.js +2 -2
- package/bin/libs/cfg/cfg-mod.d.ts +69 -0
- package/bin/libs/cfg/cfg-mod.js +61 -0
- package/bin/libs/cfg/rse/rse-impl/rse-biome.d.ts +2 -0
- package/bin/libs/cfg/rse/rse-impl/rse-biome.js +34 -0
- package/bin/libs/cfg/rse/rse-impl/rse-consts.d.ts +35 -0
- package/bin/libs/cfg/rse/rse-impl/rse-consts.js +37 -0
- package/bin/libs/cfg/rse/rse-impl/rse-content.d.ts +14 -0
- package/bin/libs/cfg/rse/rse-impl/rse-content.js +15 -0
- package/bin/libs/cfg/rse/rse-impl/rse-core.d.ts +14 -0
- package/bin/libs/cfg/rse/rse-impl/rse-core.js +63 -0
- package/bin/libs/cfg/rse/rse-impl/rse-create.d.ts +36 -0
- package/bin/libs/cfg/rse/rse-impl/rse-create.js +254 -0
- package/bin/libs/cfg/rse/rse-impl/rse-def-utils.d.ts +6 -0
- package/bin/libs/cfg/rse/rse-impl/rse-def-utils.js +225 -0
- package/bin/libs/cfg/rse/rse-impl/rse-default.d.ts +3 -0
- package/bin/libs/cfg/rse/rse-impl/rse-default.js +155 -0
- package/bin/libs/cfg/rse/rse-impl/rse-define.d.ts +125 -0
- package/bin/libs/cfg/rse/rse-impl/rse-define.js +4 -0
- package/bin/libs/cfg/rse/rse-impl/rse-detect.d.ts +23 -0
- package/bin/libs/cfg/rse/rse-impl/rse-detect.js +347 -0
- package/bin/libs/cfg/rse/rse-impl/rse-gen-cfg.d.ts +3 -0
- package/bin/libs/cfg/rse/rse-impl/rse-gen-cfg.js +186 -0
- package/bin/libs/cfg/rse/rse-impl/rse-inject.d.ts +1 -0
- package/bin/libs/cfg/rse/rse-impl/rse-inject.js +57 -0
- package/bin/libs/cfg/rse/rse-impl/rse-migrate.d.ts +5 -0
- package/bin/libs/cfg/rse/rse-impl/rse-migrate.js +56 -0
- package/bin/libs/cfg/rse/rse-impl/rse-path.d.ts +11 -0
- package/bin/libs/cfg/rse/rse-impl/rse-path.js +33 -0
- package/bin/libs/cfg/rse/rse-impl/rse-prompts.d.ts +5 -0
- package/bin/libs/cfg/rse/rse-impl/rse-prompts.js +12 -0
- package/bin/libs/cfg/rse/rse-impl/rse-read.d.ts +11 -0
- package/bin/libs/cfg/rse/rse-impl/rse-read.js +84 -0
- package/bin/libs/cfg/rse/rse-impl/rse-repair.d.ts +16 -0
- package/bin/libs/cfg/rse/rse-impl/rse-repair.js +137 -0
- package/bin/libs/cfg/rse/rse-impl/rse-schema.d.ts +130 -0
- package/bin/libs/cfg/rse/rse-impl/rse-schema.js +444 -0
- package/bin/libs/cfg/rse/rse-impl/rse-types.d.ts +75 -0
- package/bin/libs/cfg/rse/rse-impl/rse-types.js +0 -0
- package/bin/libs/cfg/rse/rse-impl/rse-unstable.d.ts +11 -0
- package/bin/libs/cfg/rse/rse-impl/rse-unstable.js +41 -0
- package/bin/libs/cfg/rse/rse-impl/rse-update.d.ts +10 -0
- package/bin/libs/cfg/rse/rse-impl/rse-update.js +152 -0
- package/bin/libs/cfg/rse/rse-impl/rse-utils.d.ts +17 -0
- package/bin/libs/cfg/rse/rse-impl/rse-utils.js +86 -0
- package/bin/libs/cfg/rse/rse-mod.d.ts +20 -0
- package/bin/libs/cfg/rse/rse-mod.js +20 -0
- package/bin/libs/cfg/types.d.ts +533 -0
- package/bin/libs/cfg/types.js +0 -0
- package/bin/libs/sdk/sdk-impl/build/build-library.d.ts +5 -5
- package/bin/libs/sdk/sdk-impl/build/build-library.js +1 -174
- package/bin/libs/sdk/sdk-impl/build/build-regular.d.ts +2 -1
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/build.js +287 -240
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/vue.d.ts +4 -4
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/make.d.ts +8 -5
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/make.js +199 -119
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/utils/spinner.d.ts +99 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/utils/spinner.js +206 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-mod.js +92 -46
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/plugins/raw.d.ts +2 -2
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/utils.d.ts +2 -2
- package/bin/libs/sdk/sdk-impl/config/default.d.ts +6 -0
- package/bin/libs/sdk/sdk-impl/{cfg → config}/default.js +8 -18
- package/bin/libs/sdk/sdk-impl/{cfg → config}/info.js +1 -1
- package/bin/libs/sdk/sdk-impl/{cfg → config}/init.js +53 -43
- package/bin/libs/sdk/sdk-impl/{cfg → config}/load.d.ts +2 -2
- package/bin/libs/sdk/sdk-impl/{cfg → config}/load.js +6 -6
- package/bin/libs/sdk/sdk-impl/config/types.d.ts +533 -0
- package/bin/libs/sdk/sdk-impl/config/types.js +0 -0
- package/bin/libs/sdk/sdk-impl/library-flow.d.ts +2 -1
- package/bin/libs/sdk/sdk-impl/regular-flow.d.ts +2 -1
- package/bin/libs/sdk/sdk-impl/rules/reliverse/dler-config-health/dler-config-health.js +2 -2
- package/bin/libs/sdk/sdk-impl/rules/reliverse/missing-deps/deps-types.d.ts +6 -6
- package/bin/libs/sdk/sdk-impl/rules/reliverse/missing-deps/filesystem.js +1 -1
- package/bin/libs/sdk/sdk-impl/rules/reliverse/no-index-files/no-index-files.js +1 -1
- package/bin/libs/sdk/sdk-impl/rules/reliverse/self-include/self-include.js +2 -2
- package/bin/libs/sdk/sdk-impl/spell/applyMagicSpells.d.ts +38 -0
- package/bin/libs/sdk/sdk-impl/spell/applyMagicSpells.js +474 -0
- package/bin/libs/sdk/sdk-impl/spell/spells.d.ts +31 -0
- package/bin/libs/sdk/sdk-impl/spell/spells.js +85 -0
- package/bin/libs/sdk/sdk-impl/utils/binary.js +1 -1
- package/bin/libs/sdk/sdk-impl/utils/comments.d.ts +6 -0
- package/bin/libs/sdk/sdk-impl/utils/comments.js +41 -0
- package/bin/libs/sdk/sdk-impl/utils/finalize.d.ts +2 -1
- package/bin/libs/sdk/sdk-impl/utils/finalize.js +1 -0
- package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pu-constants.d.ts +6 -0
- package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pu-constants.js +7 -0
- package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pu-file-utils.d.ts +5 -0
- package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pu-file-utils.js +40 -0
- package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pu-types.d.ts +24 -0
- package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pu-types.js +0 -0
- package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pub-json-utils.d.ts +17 -0
- package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pub-json-utils.js +46 -0
- package/bin/libs/sdk/sdk-impl/utils/replacements.d.ts +0 -0
- package/bin/libs/sdk/sdk-impl/utils/replacements.js +0 -0
- package/bin/libs/sdk/sdk-impl/utils/resolve-cross-libs.d.ts +3 -0
- package/bin/libs/sdk/sdk-impl/utils/resolve-cross-libs.js +194 -0
- package/bin/libs/sdk/sdk-impl/utils/utils-build.d.ts +1 -2
- package/bin/libs/sdk/sdk-impl/utils/utils-clean.d.ts +1 -1
- package/bin/libs/sdk/sdk-impl/utils/utils-deps.d.ts +1 -1
- package/bin/libs/sdk/sdk-impl/utils/utils-determine.d.ts +1 -1
- package/bin/libs/sdk/sdk-impl/utils/utils-error-cwd.d.ts +4 -0
- package/bin/libs/sdk/sdk-impl/utils/utils-error-cwd.js +1 -0
- package/bin/libs/sdk/sdk-impl/utils/utils-jsr-json.d.ts +1 -1
- package/bin/libs/sdk/sdk-impl/utils/utils-package-json-libraries.d.ts +1 -1
- package/bin/libs/sdk/sdk-impl/utils/utils-package-json-regular.d.ts +1 -1
- package/bin/libs/sdk/sdk-impl/utils/utils-security.d.ts +1 -3
- package/bin/libs/sdk/sdk-impl/utils/utils-security.js +11 -10
- package/bin/libs/sdk/sdk-mod.d.ts +1 -6
- package/bin/libs/sdk/sdk-mod.js +0 -31
- package/bin/libs/sdk/sdk-types.d.ts +39 -582
- package/bin/mod.d.ts +1 -1
- package/bin/mod.js +1 -1
- package/package.json +11 -4
- package/bin/app/mock/cmd.js +0 -284
- package/bin/app/mock/mock.d.ts +0 -11
- package/bin/app/mock/mock.js +0 -97
- package/bin/libs/sdk/sdk-impl/cfg/default.d.ts +0 -5
- package/bin/libs/sdk/sdk-impl/cfg/define.d.ts +0 -2
- package/bin/libs/sdk/sdk-impl/cfg/define.js +0 -4
- package/bin/libs/sdk/sdk-impl/spell/spell-executors.d.ts +0 -10
- package/bin/libs/sdk/sdk-impl/spell/spell-executors.js +0 -307
- package/bin/libs/sdk/sdk-impl/spell/spell-filesystem.d.ts +0 -7
- package/bin/libs/sdk/sdk-impl/spell/spell-filesystem.js +0 -74
- package/bin/libs/sdk/sdk-impl/spell/spell-mod.d.ts +0 -4
- package/bin/libs/sdk/sdk-impl/spell/spell-mod.js +0 -87
- package/bin/libs/sdk/sdk-impl/spell/spell-parser.d.ts +0 -4
- package/bin/libs/sdk/sdk-impl/spell/spell-parser.js +0 -58
- package/bin/libs/sdk/sdk-impl/spell/spell-types.d.ts +0 -60
- /package/bin/{libs/sdk/sdk-impl/spell/spell-types.js → app/spell/old.d.ts} +0 -0
- /package/bin/libs/sdk/sdk-impl/{cfg → config}/info.d.ts +0 -0
- /package/bin/libs/sdk/sdk-impl/{cfg → config}/init.d.ts +0 -0
|
@@ -10,6 +10,7 @@ import prettyMilliseconds from "pretty-ms";
|
|
|
10
10
|
import { glob } from "tinyglobby";
|
|
11
11
|
import { createPerfTimer, getElapsedPerfTime } from "../../../utils/utils-perf.js";
|
|
12
12
|
import { copyBuild } from "./copy/copy-mod.js";
|
|
13
|
+
import { useSpinner } from "./mkdist/mkdist-impl/utils/spinner.js";
|
|
13
14
|
import { mkdistBuild } from "./mkdist/mkdist-mod.js";
|
|
14
15
|
import { rollupBuild } from "./rollup/build.js";
|
|
15
16
|
import { typesBuild } from "./untyped/untyped-mod.js";
|
|
@@ -72,259 +73,305 @@ export async function unifiedBuild(inputSourceDir, coreIsCLI, isLib, rootDir, in
|
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
async function _build(rootDir, inputConfig, buildConfig, pkg, cleanedDirs, _transpileStubMode, _transpileWatchMode, outDir, showOutLog, isLib) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
76
|
+
await useSpinner.withTiming(
|
|
77
|
+
async (buildSpinner) => {
|
|
78
|
+
const timer = createPerfTimer();
|
|
79
|
+
buildSpinner.setText("Resolving build configuration...");
|
|
80
|
+
const preset = await resolvePreset(
|
|
81
|
+
buildConfig.preset || pkg.dler?.preset || pkg.build?.preset || inputConfig.preset || "auto",
|
|
82
|
+
rootDir
|
|
83
|
+
);
|
|
84
|
+
const options = defu(buildConfig, pkg.dler || pkg.build, inputConfig, preset, {
|
|
85
|
+
alias: {},
|
|
86
|
+
clean: false,
|
|
87
|
+
declaration: void 0,
|
|
88
|
+
dependencies: [],
|
|
89
|
+
devDependencies: [],
|
|
90
|
+
entries: [],
|
|
91
|
+
externals: [...Module.builtinModules, ...Module.builtinModules.map((m) => `node:${m}`)],
|
|
92
|
+
transpileFailOnWarn: true,
|
|
93
|
+
name: (pkg?.name || "").split("/").pop() || "default",
|
|
94
|
+
outDir,
|
|
95
|
+
parallel: false,
|
|
96
|
+
peerDependencies: [],
|
|
97
|
+
replace: {},
|
|
98
|
+
rollup: {
|
|
99
|
+
alias: {},
|
|
100
|
+
cjsBridge: false,
|
|
101
|
+
commonjs: {
|
|
102
|
+
ignoreTryCatch: true
|
|
103
|
+
},
|
|
104
|
+
dts: {
|
|
105
|
+
compilerOptions: {
|
|
106
|
+
/**
|
|
107
|
+
* @see https://github.com/Swatinem/rollup-plugin-dts/issues/127
|
|
108
|
+
*/
|
|
109
|
+
composite: false,
|
|
110
|
+
/**
|
|
111
|
+
* @see https://github.com/Swatinem/rollup-plugin-dts/issues/143
|
|
112
|
+
*/
|
|
113
|
+
preserveSymlinks: false
|
|
114
|
+
},
|
|
115
|
+
respectExternal: true
|
|
116
|
+
},
|
|
117
|
+
emitCJS: false,
|
|
118
|
+
esbuild: { target: "esnext" },
|
|
119
|
+
inlineDependencies: false,
|
|
120
|
+
json: {
|
|
121
|
+
preferConst: true
|
|
122
|
+
},
|
|
123
|
+
output: {
|
|
124
|
+
/**
|
|
125
|
+
* @see https://v8.dev/features/import-attributes
|
|
126
|
+
*/
|
|
127
|
+
importAttributesKey: "with"
|
|
128
|
+
},
|
|
129
|
+
preserveDynamicImports: true,
|
|
130
|
+
// Plugins
|
|
131
|
+
replace: {
|
|
132
|
+
preventAssignment: true
|
|
133
|
+
},
|
|
134
|
+
resolve: {
|
|
135
|
+
preferBuiltins: true
|
|
136
|
+
},
|
|
137
|
+
watch: false
|
|
138
|
+
},
|
|
139
|
+
rootDir,
|
|
140
|
+
showOutLog: true,
|
|
141
|
+
transpileSourcemap: false,
|
|
142
|
+
transpileStub: _transpileStubMode,
|
|
143
|
+
transpileStubOptions: {
|
|
106
144
|
/**
|
|
107
|
-
* @see https://github.com/
|
|
145
|
+
* @see https://github.com/unjs/jiti#%EF%B8%8F-options
|
|
108
146
|
*/
|
|
109
|
-
|
|
147
|
+
jiti: {
|
|
148
|
+
alias: {},
|
|
149
|
+
interopDefault: true
|
|
150
|
+
}
|
|
110
151
|
},
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
transpileSourcemap: false,
|
|
138
|
-
transpileStub: _transpileStubMode,
|
|
139
|
-
transpileStubOptions: {
|
|
140
|
-
/**
|
|
141
|
-
* @see https://github.com/unjs/jiti#%EF%B8%8F-options
|
|
142
|
-
*/
|
|
143
|
-
jiti: {
|
|
144
|
-
alias: {},
|
|
145
|
-
interopDefault: true
|
|
152
|
+
transpileWatch: _transpileWatchMode,
|
|
153
|
+
transpileWatchOptions: _transpileWatchMode ? {
|
|
154
|
+
exclude: "node_modules/**",
|
|
155
|
+
include: "src/**"
|
|
156
|
+
} : void 0,
|
|
157
|
+
isLib
|
|
158
|
+
});
|
|
159
|
+
shouldStopAtStep(5);
|
|
160
|
+
relinka("log", "Build-specific configuration merged with defaults");
|
|
161
|
+
relinka("verbose", `Build options: clean=${options.clean}, parallel=${options.parallel}`);
|
|
162
|
+
relinka("verbose", `Declaration files: ${options.declaration ? "enabled" : "disabled"}`);
|
|
163
|
+
options.outDir = resolve(options.rootDir, options.outDir);
|
|
164
|
+
const jiti = createJiti(options.rootDir, { interopDefault: true });
|
|
165
|
+
buildSpinner.setText("Initializing build context...");
|
|
166
|
+
const ctx = {
|
|
167
|
+
buildEntries: [],
|
|
168
|
+
hooks: createHooks(),
|
|
169
|
+
jiti,
|
|
170
|
+
options,
|
|
171
|
+
pkg,
|
|
172
|
+
usedImports: /* @__PURE__ */ new Set(),
|
|
173
|
+
warnings: /* @__PURE__ */ new Set(),
|
|
174
|
+
isLib
|
|
175
|
+
};
|
|
176
|
+
if (preset.hooks) {
|
|
177
|
+
ctx.hooks.addHooks(preset.hooks);
|
|
146
178
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
transpileWatchOptions: _transpileWatchMode ? {
|
|
150
|
-
exclude: "node_modules/**",
|
|
151
|
-
include: "src/**"
|
|
152
|
-
} : void 0,
|
|
153
|
-
isLib
|
|
154
|
-
});
|
|
155
|
-
shouldStopAtStep(5);
|
|
156
|
-
relinka("log", "Build-specific configuration merged with defaults");
|
|
157
|
-
relinka("verbose", `Build options: clean=${options.clean}, parallel=${options.parallel}`);
|
|
158
|
-
relinka("verbose", `Declaration files: ${options.declaration ? "enabled" : "disabled"}`);
|
|
159
|
-
options.outDir = resolve(options.rootDir, options.outDir);
|
|
160
|
-
const jiti = createJiti(options.rootDir, { interopDefault: true });
|
|
161
|
-
const ctx = {
|
|
162
|
-
buildEntries: [],
|
|
163
|
-
hooks: createHooks(),
|
|
164
|
-
jiti,
|
|
165
|
-
options,
|
|
166
|
-
pkg,
|
|
167
|
-
usedImports: /* @__PURE__ */ new Set(),
|
|
168
|
-
warnings: /* @__PURE__ */ new Set(),
|
|
169
|
-
isLib
|
|
170
|
-
};
|
|
171
|
-
if (preset.hooks) {
|
|
172
|
-
ctx.hooks.addHooks(preset.hooks);
|
|
173
|
-
}
|
|
174
|
-
if (inputConfig.hooks) {
|
|
175
|
-
ctx.hooks.addHooks(inputConfig.hooks);
|
|
176
|
-
}
|
|
177
|
-
if (buildConfig.hooks) {
|
|
178
|
-
ctx.hooks.addHooks(buildConfig.hooks);
|
|
179
|
-
}
|
|
180
|
-
await ctx.hooks.callHook("build:prepare", ctx);
|
|
181
|
-
options.entries = options.entries.map(
|
|
182
|
-
(entry) => typeof entry === "string" ? { input: entry, isLib } : entry
|
|
183
|
-
);
|
|
184
|
-
for (const entry of options.entries) {
|
|
185
|
-
if (typeof entry.name !== "string") {
|
|
186
|
-
let relativeInput = isAbsolute(entry.input) ? relative(rootDir, entry.input) : normalize(entry.input);
|
|
187
|
-
if (relativeInput.startsWith("./")) {
|
|
188
|
-
relativeInput = relativeInput.slice(2);
|
|
179
|
+
if (inputConfig.hooks) {
|
|
180
|
+
ctx.hooks.addHooks(inputConfig.hooks);
|
|
189
181
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
182
|
+
if (buildConfig.hooks) {
|
|
183
|
+
ctx.hooks.addHooks(buildConfig.hooks);
|
|
184
|
+
}
|
|
185
|
+
await ctx.hooks.callHook("build:prepare", ctx);
|
|
186
|
+
buildSpinner.setText("Processing build entries...");
|
|
187
|
+
options.entries = options.entries.map(
|
|
188
|
+
(entry) => typeof entry === "string" ? { input: entry, isLib } : entry
|
|
189
|
+
);
|
|
190
|
+
for (const entry of options.entries) {
|
|
191
|
+
if (typeof entry.name !== "string") {
|
|
192
|
+
let relativeInput = isAbsolute(entry.input) ? relative(rootDir, entry.input) : normalize(entry.input);
|
|
193
|
+
if (relativeInput.startsWith("./")) {
|
|
194
|
+
relativeInput = relativeInput.slice(2);
|
|
195
|
+
}
|
|
196
|
+
entry.name = removeExtension(relativeInput.replace(/^src\//, ""));
|
|
197
|
+
}
|
|
198
|
+
if (!entry.input) {
|
|
199
|
+
throw new Error(`Missing entry input: ${dumpObject(entry)}`);
|
|
200
|
+
}
|
|
201
|
+
if (!entry.builder) {
|
|
202
|
+
entry.builder = entry.input.endsWith("/") ? "mkdist" : "rollup";
|
|
203
|
+
}
|
|
204
|
+
if (options.declaration !== void 0 && entry.declaration === void 0) {
|
|
205
|
+
entry.declaration = options.declaration;
|
|
206
|
+
}
|
|
207
|
+
entry.input = resolve(options.rootDir, entry.input);
|
|
208
|
+
entry.outDir = resolve(options.rootDir, entry.outDir || options.outDir);
|
|
209
|
+
entry.isLib = isLib;
|
|
210
|
+
}
|
|
211
|
+
options.dependencies = Object.keys(pkg.dependencies || {});
|
|
212
|
+
options.peerDependencies = Object.keys(pkg.peerDependencies || {});
|
|
213
|
+
options.devDependencies = Object.keys(pkg.devDependencies || {});
|
|
214
|
+
options.externals.push(...inferPkgExternals(pkg));
|
|
215
|
+
options.externals = [...new Set(options.externals)];
|
|
216
|
+
await ctx.hooks.callHook("build:before", ctx);
|
|
217
|
+
relinka(
|
|
218
|
+
"verbose",
|
|
219
|
+
`${options.transpileStub ? "Stubbing" : "[unified] Building"} ${options.name}`
|
|
220
|
+
);
|
|
221
|
+
if (process.env.DEBUG) {
|
|
222
|
+
relinka(
|
|
223
|
+
"log",
|
|
224
|
+
`Root dir: ${options.rootDir}
|
|
219
225
|
Entries:
|
|
220
226
|
${options.entries.map((entry) => ` ${dumpObject(entry)}`).join("\n ")}
|
|
221
227
|
`
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
if (options.clean) {
|
|
225
|
-
for (const dir of new Set(
|
|
226
|
-
options.entries.map((e) => e.outDir).filter((p) => !!p).sort()
|
|
227
|
-
)) {
|
|
228
|
-
if (dir === options.rootDir || options.rootDir.startsWith(withTrailingSlash(dir)) || cleanedDirs.some((c) => dir.startsWith(c))) {
|
|
229
|
-
continue;
|
|
228
|
+
);
|
|
230
229
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
copyBuild
|
|
245
|
-
// copy
|
|
246
|
-
];
|
|
247
|
-
if (options.parallel) {
|
|
248
|
-
await Promise.all(buildTasks.map((task) => task(ctx)));
|
|
249
|
-
} else {
|
|
250
|
-
for (const task of buildTasks) {
|
|
251
|
-
await task(ctx);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
if (options.transpileStub || options.transpileWatch) {
|
|
255
|
-
await ctx.hooks.callHook("build:done", ctx);
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
relinka("success", `Build succeeded for ${options.name}`);
|
|
259
|
-
const outFiles = await glob(["**"], { cwd: options.outDir });
|
|
260
|
-
for (const file of outFiles) {
|
|
261
|
-
let entry = ctx.buildEntries.find((e) => e.path === file);
|
|
262
|
-
if (!entry) {
|
|
263
|
-
entry = {
|
|
264
|
-
chunk: true,
|
|
265
|
-
path: file,
|
|
266
|
-
isLib: ctx.options.isLib
|
|
267
|
-
};
|
|
268
|
-
ctx.buildEntries.push(entry);
|
|
269
|
-
}
|
|
270
|
-
if (!entry.bytes) {
|
|
271
|
-
const stat = await fsp.stat(resolve(options.outDir, file));
|
|
272
|
-
entry.bytes = stat.size;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
const rPath = (p) => relative(process.cwd(), resolve(options.outDir, p));
|
|
276
|
-
if (showOutLog) {
|
|
277
|
-
for (const entry of ctx.buildEntries.filter((e) => !e.chunk)) {
|
|
278
|
-
let totalBytes = entry.bytes || 0;
|
|
279
|
-
for (const chunk of entry.chunks || []) {
|
|
280
|
-
totalBytes += ctx.buildEntries.find((e) => e.path === chunk)?.bytes || 0;
|
|
230
|
+
if (options.clean) {
|
|
231
|
+
buildSpinner.setText("Cleaning output directories...");
|
|
232
|
+
for (const dir of new Set(
|
|
233
|
+
options.entries.map((e) => e.outDir).filter((p) => !!p).sort()
|
|
234
|
+
)) {
|
|
235
|
+
if (dir === options.rootDir || options.rootDir.startsWith(withTrailingSlash(dir)) || cleanedDirs.some((c) => dir.startsWith(c))) {
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
cleanedDirs.push(dir);
|
|
239
|
+
relinka("log", `Cleaning dist directory: \`./${relative(process.cwd(), dir)}\``);
|
|
240
|
+
await rmdir(dir);
|
|
241
|
+
await fsp.mkdir(dir, { recursive: true });
|
|
242
|
+
}
|
|
281
243
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
244
|
+
const buildTasks = [
|
|
245
|
+
{ name: "Type generation", task: typesBuild },
|
|
246
|
+
{ name: "mkdist build", task: mkdistBuild },
|
|
247
|
+
{ name: "Rollup build", task: rollupBuild },
|
|
248
|
+
{ name: "Copy files", task: copyBuild }
|
|
249
|
+
];
|
|
250
|
+
const activeTasks = buildTasks.filter(({ task }) => {
|
|
251
|
+
if (task === typesBuild) return options.entries.some((e) => e.builder === "untyped");
|
|
252
|
+
if (task === mkdistBuild) return options.entries.some((e) => e.builder === "mkdist");
|
|
253
|
+
if (task === rollupBuild) return options.entries.some((e) => e.builder === "rollup");
|
|
254
|
+
if (task === copyBuild) return options.entries.some((e) => e.builder === "copy");
|
|
255
|
+
return false;
|
|
256
|
+
});
|
|
257
|
+
if (activeTasks.length === 0) {
|
|
258
|
+
buildSpinner.setText("No build tasks to execute");
|
|
259
|
+
} else {
|
|
260
|
+
let completedTasks = 0;
|
|
261
|
+
if (options.parallel) {
|
|
262
|
+
buildSpinner.setText(`Running ${activeTasks.length} build tasks in parallel...`);
|
|
263
|
+
await Promise.all(
|
|
264
|
+
activeTasks.map(async ({ task }) => {
|
|
265
|
+
await task(ctx);
|
|
266
|
+
completedTasks++;
|
|
267
|
+
buildSpinner.setProgress({
|
|
268
|
+
current: completedTasks,
|
|
269
|
+
total: activeTasks.length
|
|
270
|
+
});
|
|
271
|
+
})
|
|
272
|
+
);
|
|
273
|
+
} else {
|
|
274
|
+
for (const { task, name } of activeTasks) {
|
|
275
|
+
completedTasks++;
|
|
276
|
+
buildSpinner.setProgress({
|
|
277
|
+
current: completedTasks,
|
|
278
|
+
total: activeTasks.length
|
|
279
|
+
});
|
|
280
|
+
buildSpinner.setText(`Running ${name}...`);
|
|
281
|
+
await task(ctx);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
293
284
|
}
|
|
294
|
-
if (
|
|
295
|
-
|
|
285
|
+
if (options.transpileStub || options.transpileWatch) {
|
|
286
|
+
await ctx.hooks.callHook("build:done", ctx);
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
buildSpinner.setText("Finalizing build output...");
|
|
290
|
+
relinka("success", `Build succeeded for ${options.name}`);
|
|
291
|
+
const outFiles = await glob(["**"], { cwd: options.outDir });
|
|
292
|
+
for (const file of outFiles) {
|
|
293
|
+
let entry = ctx.buildEntries.find((e) => e.path === file);
|
|
294
|
+
if (!entry) {
|
|
295
|
+
entry = {
|
|
296
|
+
chunk: true,
|
|
297
|
+
path: file,
|
|
298
|
+
isLib: ctx.options.isLib
|
|
299
|
+
};
|
|
300
|
+
ctx.buildEntries.push(entry);
|
|
301
|
+
}
|
|
302
|
+
if (!entry.bytes) {
|
|
303
|
+
const stat = await fsp.stat(resolve(options.outDir, file));
|
|
304
|
+
entry.bytes = stat.size;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
const rPath = (p) => relative(process.cwd(), resolve(options.outDir, p));
|
|
308
|
+
if (showOutLog) {
|
|
309
|
+
for (const entry of ctx.buildEntries.filter((e) => !e.chunk)) {
|
|
310
|
+
let totalBytes = entry.bytes || 0;
|
|
311
|
+
for (const chunk of entry.chunks || []) {
|
|
312
|
+
totalBytes += ctx.buildEntries.find((e) => e.path === chunk)?.bytes || 0;
|
|
313
|
+
}
|
|
314
|
+
let line = ` ${rPath(entry.path)} (${[
|
|
315
|
+
totalBytes && `total size: ${prettyBytes(totalBytes)}`,
|
|
316
|
+
entry.bytes && `chunk size: ${prettyBytes(entry.bytes)}`,
|
|
317
|
+
entry.exports?.length && `exports: ${entry.exports.join(", ")}`
|
|
318
|
+
].filter(Boolean).join(", ")})`;
|
|
319
|
+
if (entry.chunks?.length) {
|
|
320
|
+
line += `
|
|
321
|
+
${entry.chunks.map((p) => {
|
|
322
|
+
const chunk = ctx.buildEntries.find((e) => e.path === p) || {};
|
|
323
|
+
return ` \u2514\u2500 ${rPath(p)}${chunk.bytes ? ` (${prettyBytes(chunk.bytes)})` : ""}`;
|
|
324
|
+
}).join("\n")}`;
|
|
325
|
+
}
|
|
326
|
+
if (entry.modules?.length) {
|
|
327
|
+
line += `
|
|
296
328
|
${entry.modules.filter((m) => m.id.includes("node_modules")).sort((a, b) => (b.bytes || 0) - (a.bytes || 0)).map((m) => {
|
|
297
|
-
|
|
298
|
-
|
|
329
|
+
return ` \u{1F4E6} ${rPath(m.id)}${m.bytes ? ` (${prettyBytes(m.bytes)})` : ""}`;
|
|
330
|
+
}).join("\n")}`;
|
|
331
|
+
}
|
|
332
|
+
relinka("log", entry.chunk ? line : line);
|
|
333
|
+
}
|
|
334
|
+
const elapsedTime = getElapsedPerfTime(timer);
|
|
335
|
+
const transpileFormattedTime = prettyMilliseconds(elapsedTime, {
|
|
336
|
+
verbose: true
|
|
337
|
+
});
|
|
338
|
+
const totalSize = ctx.buildEntries.reduce((a, e) => a + (e.bytes || 0), 0);
|
|
339
|
+
buildSpinner.setText(
|
|
340
|
+
`Build complete! ${prettyBytes(totalSize)} in ${transpileFormattedTime}`
|
|
341
|
+
);
|
|
342
|
+
relinka(
|
|
343
|
+
"info",
|
|
344
|
+
`\u03A3 Total dist size: ${prettyBytes(totalSize)} (build time: ${transpileFormattedTime})`
|
|
345
|
+
);
|
|
299
346
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
);
|
|
310
|
-
}
|
|
311
|
-
validateDependencies(ctx);
|
|
312
|
-
validatePackage(pkg, rootDir, ctx);
|
|
313
|
-
await ctx.hooks.callHook("build:done", ctx);
|
|
314
|
-
if (ctx.warnings.size > 0) {
|
|
315
|
-
relinka(
|
|
316
|
-
"warn",
|
|
317
|
-
`Build is done with some warnings:
|
|
347
|
+
validateDependencies(ctx);
|
|
348
|
+
validatePackage(pkg, rootDir, ctx);
|
|
349
|
+
await ctx.hooks.callHook("build:done", ctx);
|
|
350
|
+
if (ctx.warnings.size > 0) {
|
|
351
|
+
const warningMessage = `Build completed with ${ctx.warnings.size} warnings`;
|
|
352
|
+
buildSpinner.warn(warningMessage);
|
|
353
|
+
relinka(
|
|
354
|
+
"warn",
|
|
355
|
+
`Build is done with some warnings:
|
|
318
356
|
${[...ctx.warnings].map((msg) => `- ${msg}`).join("\n")}`
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
357
|
+
);
|
|
358
|
+
if (ctx.options.transpileFailOnWarn) {
|
|
359
|
+
relinka(
|
|
360
|
+
"error",
|
|
361
|
+
"Exiting with code (1). You can change this behavior by setting `transpileFailOnWarn: false` ."
|
|
362
|
+
);
|
|
363
|
+
process.exit(1);
|
|
364
|
+
}
|
|
365
|
+
shouldStopAtStep(15);
|
|
366
|
+
relinka("info", `Build complete (with ${ctx.warnings.size} warnings)`);
|
|
367
|
+
}
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
text: _transpileStubMode ? `Stubbing ${pkg?.name || "project"}...` : `Building ${pkg?.name || "project"}...`,
|
|
371
|
+
color: "green",
|
|
372
|
+
successText: `${pkg?.name || "Project"} built successfully!`,
|
|
373
|
+
failText: `Build failed for ${pkg?.name || "project"}`,
|
|
374
|
+
prefixText: "[unified]"
|
|
326
375
|
}
|
|
327
|
-
|
|
328
|
-
relinka("info", `Build complete (with ${ctx.warnings.size} warnings)`);
|
|
329
|
-
}
|
|
376
|
+
);
|
|
330
377
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import type { SFCBlock } from "vue/compiler-sfc";
|
|
2
2
|
import type { InputFile, Loader, LoaderContext, OutputFile } from "../../../../../../../sdk-types.js";
|
|
3
|
-
export
|
|
3
|
+
export interface DefineVueLoaderOptions {
|
|
4
4
|
blockLoaders?: Record<string, VueBlockLoader | undefined>;
|
|
5
|
-
}
|
|
5
|
+
}
|
|
6
6
|
export type VueBlock = Pick<SFCBlock, "type" | "content" | "attrs">;
|
|
7
7
|
export type VueBlockLoader = (block: VueBlock, context: LoaderContext & {
|
|
8
8
|
rawInput: InputFile;
|
|
9
9
|
addOutput: (...files: OutputFile[]) => void;
|
|
10
10
|
}) => Promise<VueBlock | undefined>;
|
|
11
|
-
export
|
|
11
|
+
export interface DefaultBlockLoaderOptions {
|
|
12
12
|
type: "script" | "style" | "template";
|
|
13
13
|
outputLang: string;
|
|
14
14
|
validExtensions?: string[];
|
|
15
|
-
}
|
|
15
|
+
}
|
|
16
16
|
export declare const fallbackVueLoader: Loader;
|
|
17
17
|
export declare const vueLoader: Loader;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { MkdistOptions } from "../../../../../../sdk-types.js";
|
|
2
2
|
export declare function mkdist(options?: MkdistOptions): Promise<{
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
result: {
|
|
4
|
+
errors: {
|
|
5
|
+
filename: string;
|
|
6
|
+
errors: TypeError[];
|
|
7
|
+
}[];
|
|
8
|
+
writtenFiles: string[];
|
|
9
|
+
};
|
|
10
|
+
duration: number;
|
|
8
11
|
}>;
|