@arcgis/components-build-utils 5.2.0-next.3 → 5.2.0-next.31
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 +0 -2
- package/dist/index.d.ts +51 -5
- package/dist/index.js +26 -420
- package/package.json +6 -9
- package/dist/file.d.cts +0 -18
- package/dist/file.d.ts +0 -18
- package/dist/glob.d.cts +0 -24
- package/dist/glob.d.ts +0 -24
- package/dist/index.cjs +0 -464
- package/dist/index.d.cts +0 -5
- package/dist/packageJson.d.cts +0 -43
- package/dist/packageJson.d.ts +0 -43
- package/dist/path.d.cts +0 -30
- package/dist/path.d.ts +0 -30
- package/dist/vite.d.cts +0 -101
- package/dist/vite.d.ts +0 -101
package/dist/index.cjs
DELETED
|
@@ -1,464 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
}
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
25
|
-
const node_fs = require("node:fs");
|
|
26
|
-
const promises = require("node:fs/promises");
|
|
27
|
-
const path$1 = require("path");
|
|
28
|
-
const node_url = require("node:url");
|
|
29
|
-
const node_child_process = require("node:child_process");
|
|
30
|
-
const node_util = require("node:util");
|
|
31
|
-
const node_module = require("node:module");
|
|
32
|
-
const existsAsync = async (file) => (
|
|
33
|
-
// Using un-promisified version because promises version creates exceptions
|
|
34
|
-
// which interferes with debugging when "Pause on caught exceptions" is enabled
|
|
35
|
-
await new Promise((resolve2) => node_fs.access(file, promises.constants.F_OK, (error) => resolve2(!error)))
|
|
36
|
-
);
|
|
37
|
-
function sh(command, options = {}) {
|
|
38
|
-
try {
|
|
39
|
-
const normalizedOptions = { encoding: "utf8", ...options };
|
|
40
|
-
return node_child_process.execSync(command.trim(), normalizedOptions).trim();
|
|
41
|
-
} catch (error) {
|
|
42
|
-
makeExecErrorReadable(error);
|
|
43
|
-
throw error;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
function sp(command, args, options = {}) {
|
|
47
|
-
const normalizedOptions = { encoding: "utf8", ...options };
|
|
48
|
-
const result = node_child_process.spawnSync(command, args, normalizedOptions);
|
|
49
|
-
if (result.error) {
|
|
50
|
-
throw result.error;
|
|
51
|
-
}
|
|
52
|
-
const output = `${result.stdout ?? ""}${result.stderr ?? ""}`.trim();
|
|
53
|
-
const exitCode = result.status ?? 0;
|
|
54
|
-
if (exitCode !== 0) {
|
|
55
|
-
throw new Error(
|
|
56
|
-
`Command failed with exit code ${String(exitCode)}: ${command} ${args.join(" ")}
|
|
57
|
-
${output}`.trim()
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
return output;
|
|
61
|
-
}
|
|
62
|
-
async function asyncSh(command, options = {}) {
|
|
63
|
-
const normalizedOptions = { encoding: "utf8", ...options };
|
|
64
|
-
return await new Promise((resolve2, reject) => {
|
|
65
|
-
node_child_process.exec(command.trim(), normalizedOptions, (error, stdout, stderr) => {
|
|
66
|
-
if (error) {
|
|
67
|
-
makeExecErrorReadable(error);
|
|
68
|
-
reject(error);
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
resolve2(stdout.trim() || stderr.trim());
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
function makeExecErrorReadable(error) {
|
|
76
|
-
if (error instanceof Error && error.stack && "output" in error && Array.isArray(error.output) && "status" in error) {
|
|
77
|
-
const stackIndex = error.stack.indexOf("\n at ");
|
|
78
|
-
if (stackIndex !== -1) {
|
|
79
|
-
const output = error.output.filter(Boolean).join("\n").trim();
|
|
80
|
-
const newHeader = `${node_util.styleText("red", error.message)} (exit code: ${String(error.status)})
|
|
81
|
-
${output}`;
|
|
82
|
-
const oldStackFrames = error.stack.substring(stackIndex);
|
|
83
|
-
error.stack = `Error: ${newHeader}${oldStackFrames}`;
|
|
84
|
-
}
|
|
85
|
-
Object.defineProperties(error, {
|
|
86
|
-
output: { enumerable: false },
|
|
87
|
-
stdout: { enumerable: false },
|
|
88
|
-
stderr: { enumerable: false },
|
|
89
|
-
signal: { enumerable: false },
|
|
90
|
-
status: { enumerable: false },
|
|
91
|
-
pid: { enumerable: false },
|
|
92
|
-
stdio: { enumerable: false }
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
async function createFileIfNotExists(filePath, content) {
|
|
97
|
-
await promises.mkdir(path$1.dirname(filePath), { recursive: true });
|
|
98
|
-
if (!await existsAsync(filePath)) {
|
|
99
|
-
await promises.writeFile(filePath, content, { encoding: "utf8" });
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
function findPath(target, startDirectory = process.cwd()) {
|
|
103
|
-
const resolvedStartDirectory = startDirectory.startsWith("file:///") ? path$1.dirname(node_url.fileURLToPath(startDirectory)) : path$1.resolve(startDirectory);
|
|
104
|
-
const parentPath = resolvedStartDirectory.split(path$1.sep);
|
|
105
|
-
while (parentPath.length > searchStopIndex) {
|
|
106
|
-
const fullPath = path$1.join(
|
|
107
|
-
...path$1.sep === "/" ? ["/"] : [],
|
|
108
|
-
...parentPath,
|
|
109
|
-
target
|
|
110
|
-
);
|
|
111
|
-
if (node_fs.existsSync(fullPath)) {
|
|
112
|
-
return fullPath;
|
|
113
|
-
}
|
|
114
|
-
parentPath.pop();
|
|
115
|
-
}
|
|
116
|
-
return void 0;
|
|
117
|
-
}
|
|
118
|
-
const searchStopIndex = 0;
|
|
119
|
-
async function asyncFindPath(target, startDirectory = process.cwd()) {
|
|
120
|
-
const resolvedStartDirectory = startDirectory.startsWith("file:///") ? path$1.dirname(node_url.fileURLToPath(startDirectory)) : path$1.resolve(startDirectory);
|
|
121
|
-
const parentPath = resolvedStartDirectory.split(path$1.sep);
|
|
122
|
-
while (parentPath.length > searchStopIndex) {
|
|
123
|
-
const fullPath = path$1.join(
|
|
124
|
-
...path$1.sep === "/" ? ["/"] : [],
|
|
125
|
-
...parentPath,
|
|
126
|
-
target
|
|
127
|
-
);
|
|
128
|
-
if (await existsAsync(fullPath)) {
|
|
129
|
-
return fullPath;
|
|
130
|
-
}
|
|
131
|
-
parentPath.pop();
|
|
132
|
-
}
|
|
133
|
-
return void 0;
|
|
134
|
-
}
|
|
135
|
-
function gitIgnoreFileToGlobs(filePath) {
|
|
136
|
-
return node_fs.readFileSync(filePath, "utf8").split("\n").filter((line) => line.trim().length > 0 && !line.trim().startsWith("#")).map(gitIgnoreToGlob);
|
|
137
|
-
}
|
|
138
|
-
const gitIgnoreToGlob = (pattern) => fixAbsoluteSyntax(fixMatchFilesSyntax(pattern));
|
|
139
|
-
function fixAbsoluteSyntax(pattern) {
|
|
140
|
-
if (pattern.startsWith("/")) {
|
|
141
|
-
return pattern.slice(1);
|
|
142
|
-
}
|
|
143
|
-
if (pattern.startsWith("!/")) {
|
|
144
|
-
return `!${pattern.slice(2)}`;
|
|
145
|
-
}
|
|
146
|
-
const isAlreadyCorrect = pattern.startsWith("**") || pattern.startsWith("!**");
|
|
147
|
-
const basePattern = pattern.startsWith("!") ? pattern.slice(1) : pattern;
|
|
148
|
-
return isAlreadyCorrect ? pattern : `${pattern.startsWith("!") ? "!" : ""}**/${basePattern}`;
|
|
149
|
-
}
|
|
150
|
-
function fixMatchFilesSyntax(pattern) {
|
|
151
|
-
const base = pattern.split("/").at(-1);
|
|
152
|
-
const isAlreadyCorrect = pattern.endsWith("**") || pattern.includes("{") || base?.includes(".");
|
|
153
|
-
if (isAlreadyCorrect) {
|
|
154
|
-
return pattern;
|
|
155
|
-
}
|
|
156
|
-
return pattern.endsWith("/*") ? `${pattern}*` : pattern.endsWith("/") ? `${pattern}**` : `${pattern}/**`;
|
|
157
|
-
}
|
|
158
|
-
const isPosix = path$1.sep === path$1.posix.sep;
|
|
159
|
-
const toPosixPathSeparators = (relativePath) => relativePath.includes(path$1.win32.sep) ? relativePath.replaceAll(path$1.win32.sep, path$1.posix.sep) : relativePath;
|
|
160
|
-
const normalizePath = isPosix ? (path2) => path2 : toPosixPathSeparators;
|
|
161
|
-
const toWin32PathSeparators = (relativePath) => relativePath.includes(path$1.posix.sep) ? relativePath.replaceAll(path$1.posix.sep, path$1.win32.sep) : relativePath;
|
|
162
|
-
const toSystemPathSeparators = isPosix ? (path2) => path2 : toWin32PathSeparators;
|
|
163
|
-
const getCwd = isPosix ? process.cwd : () => toPosixPathSeparators(process.cwd());
|
|
164
|
-
const path = isPosix ? path$1.posix : {
|
|
165
|
-
...path$1.win32,
|
|
166
|
-
sep: path$1.posix.sep,
|
|
167
|
-
join(...paths) {
|
|
168
|
-
const result = path$1.win32.join(...paths);
|
|
169
|
-
return toPosixPathSeparators(result);
|
|
170
|
-
},
|
|
171
|
-
normalize(path2) {
|
|
172
|
-
const result = path$1.win32.normalize(path2);
|
|
173
|
-
return toPosixPathSeparators(result);
|
|
174
|
-
},
|
|
175
|
-
relative(from, to) {
|
|
176
|
-
const result = path$1.win32.relative(from, to);
|
|
177
|
-
return toPosixPathSeparators(result);
|
|
178
|
-
},
|
|
179
|
-
dirname(path2) {
|
|
180
|
-
const result = path$1.win32.dirname(path2);
|
|
181
|
-
return toPosixPathSeparators(result);
|
|
182
|
-
},
|
|
183
|
-
resolve(...paths) {
|
|
184
|
-
const result = path$1.win32.resolve(...paths);
|
|
185
|
-
return toPosixPathSeparators(result);
|
|
186
|
-
},
|
|
187
|
-
toNamespacedPath(path2) {
|
|
188
|
-
const result = path$1.win32.toNamespacedPath(path2);
|
|
189
|
-
return toPosixPathSeparators(result);
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
const cachedPackageJson = {};
|
|
193
|
-
const cachedPackageJsonPromises = {};
|
|
194
|
-
let rootPackageJsonLocation;
|
|
195
|
-
function retrievePackageJson(location, cache = true) {
|
|
196
|
-
const packageJsonPath = location ? path.resolve(location, "package.json") : rootPackageJsonLocation ??= findPath("package.json");
|
|
197
|
-
if (cache) {
|
|
198
|
-
cachedPackageJson[packageJsonPath] ??= JSON.parse(node_fs.readFileSync(packageJsonPath, "utf-8"));
|
|
199
|
-
return cachedPackageJson[packageJsonPath];
|
|
200
|
-
}
|
|
201
|
-
return JSON.parse(node_fs.readFileSync(packageJsonPath, "utf-8"));
|
|
202
|
-
}
|
|
203
|
-
async function asyncRetrievePackageJson(location) {
|
|
204
|
-
const packageJsonPath = location ? path.resolve(location, "package.json") : rootPackageJsonLocation ??= findPath("package.json");
|
|
205
|
-
if (packageJsonPath in cachedPackageJson) {
|
|
206
|
-
return cachedPackageJson[packageJsonPath];
|
|
207
|
-
}
|
|
208
|
-
cachedPackageJsonPromises[packageJsonPath] ??= asyncReadPackageJson(packageJsonPath);
|
|
209
|
-
const result = await cachedPackageJsonPromises[packageJsonPath];
|
|
210
|
-
cachedPackageJson[packageJsonPath] ??= result;
|
|
211
|
-
return result;
|
|
212
|
-
}
|
|
213
|
-
const asyncReadPackageJson = async (location) => JSON.parse(await promises.readFile(location, "utf-8"));
|
|
214
|
-
const cachedPackageLocation = {};
|
|
215
|
-
const cachedPackageLocationPromises = {};
|
|
216
|
-
async function fetchPackageLocation(packageName, cwd) {
|
|
217
|
-
if (packageName in cachedPackageLocation) {
|
|
218
|
-
return cachedPackageLocation[packageName];
|
|
219
|
-
}
|
|
220
|
-
cachedPackageLocationPromises[packageName] ??= asyncFindPath(
|
|
221
|
-
path.join("node_modules", packageName, "package.json"),
|
|
222
|
-
cwd
|
|
223
|
-
).then((packageJsonLocation) => {
|
|
224
|
-
if (packageJsonLocation === void 0) {
|
|
225
|
-
throw Error(
|
|
226
|
-
`@arcgis/components-build-utils: Unable to resolve package.json location for "${packageName}" package. Current working directory: ${process.cwd()}`
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
return path.dirname(packageJsonLocation);
|
|
230
|
-
});
|
|
231
|
-
const result = await cachedPackageLocationPromises[packageName];
|
|
232
|
-
cachedPackageLocation[packageName] ??= result;
|
|
233
|
-
return cachedPackageLocation[packageName];
|
|
234
|
-
}
|
|
235
|
-
function detectPackageManager(cwd = process.cwd()) {
|
|
236
|
-
let packageManager = void 0;
|
|
237
|
-
{
|
|
238
|
-
const pathParts = path.resolve(cwd).split(path.sep);
|
|
239
|
-
while (pathParts.length > 1) {
|
|
240
|
-
const packageJson = path.join(pathParts.join(path.sep), "package.json");
|
|
241
|
-
pathParts.pop();
|
|
242
|
-
if (!node_fs.existsSync(packageJson)) {
|
|
243
|
-
continue;
|
|
244
|
-
}
|
|
245
|
-
const contents = JSON.parse(node_fs.readFileSync(packageJson, "utf8"));
|
|
246
|
-
if (typeof contents !== "object" || Array.isArray(contents)) {
|
|
247
|
-
continue;
|
|
248
|
-
}
|
|
249
|
-
if (typeof contents.packageManager === "string") {
|
|
250
|
-
packageManager ??= contents.packageManager.match(/\w+/u)?.[0] ?? packageManager;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
packageManager ??= "npm";
|
|
255
|
-
return packageManager;
|
|
256
|
-
}
|
|
257
|
-
function vitePresetPlugin({
|
|
258
|
-
dtsOptions = {},
|
|
259
|
-
externalize,
|
|
260
|
-
bundleIn,
|
|
261
|
-
isApplication
|
|
262
|
-
} = {
|
|
263
|
-
externalize: [],
|
|
264
|
-
dtsOptions: {}
|
|
265
|
-
}) {
|
|
266
|
-
const dist = `${path.resolve("dist")}/`;
|
|
267
|
-
const distSrc = `${dist}src/`;
|
|
268
|
-
let userConfig = void 0;
|
|
269
|
-
let command = void 0;
|
|
270
|
-
return [
|
|
271
|
-
{
|
|
272
|
-
name: "vite-preset-config",
|
|
273
|
-
config({ build: { target } = {} }, env) {
|
|
274
|
-
command = env.command;
|
|
275
|
-
return {
|
|
276
|
-
build: {
|
|
277
|
-
// REFACTOR: get this from tsconfig
|
|
278
|
-
// It's a best practice to let the final bundler down-level as needed.
|
|
279
|
-
target: target ?? "es2024"
|
|
280
|
-
},
|
|
281
|
-
define: env.mode === "test" ? {
|
|
282
|
-
"process.env.ESRI_INTERNAL": true
|
|
283
|
-
} : void 0
|
|
284
|
-
};
|
|
285
|
-
},
|
|
286
|
-
configResolved(config) {
|
|
287
|
-
userConfig = config;
|
|
288
|
-
}
|
|
289
|
-
},
|
|
290
|
-
externalizeDependencies({
|
|
291
|
-
externalize,
|
|
292
|
-
bundleIn,
|
|
293
|
-
isApplication
|
|
294
|
-
}),
|
|
295
|
-
// This dependency pulls in many others. Since components-build-utils has a
|
|
296
|
-
// single entry point, we load a large module tree needlessly. To avoid,
|
|
297
|
-
// load the plugin on demand.
|
|
298
|
-
dtsOptions === false ? void 0 : import("vite-plugin-dts").then(
|
|
299
|
-
({ default: dts }) => dts({
|
|
300
|
-
logLevel: "warn",
|
|
301
|
-
// Copies .d.ts files to d.cjs file for CommonJS.
|
|
302
|
-
// Adds a performance hit as it occurs after the build
|
|
303
|
-
async afterBuild(emitted) {
|
|
304
|
-
if (userConfig?.build?.lib && userConfig.build.lib.formats?.includes("cjs")) {
|
|
305
|
-
await Promise.all(
|
|
306
|
-
emitted.entries().map(async ([filePath, content]) => {
|
|
307
|
-
if (filePath.endsWith(".d.ts")) {
|
|
308
|
-
await promises.writeFile(filePath.replace(".d.ts", ".d.cts"), content);
|
|
309
|
-
}
|
|
310
|
-
})
|
|
311
|
-
);
|
|
312
|
-
}
|
|
313
|
-
await dtsOptions?.afterBuild?.(emitted);
|
|
314
|
-
},
|
|
315
|
-
...dtsOptions,
|
|
316
|
-
compilerOptions: {
|
|
317
|
-
rootDir: ".",
|
|
318
|
-
...dtsOptions.compilerOptions
|
|
319
|
-
},
|
|
320
|
-
/**
|
|
321
|
-
* Do not emit any .d.ts files for files outside the dist directory
|
|
322
|
-
* (i.e vite.config.ts, storybook stories and etc)
|
|
323
|
-
* This also applies for references to node_modules/.../components.d.ts files in
|
|
324
|
-
* tsconfig.json - these must be included in TypeScript program to provide
|
|
325
|
-
* types, but should not be re-emitted during build.
|
|
326
|
-
*/
|
|
327
|
-
beforeWriteFile: async (filePath, content) => {
|
|
328
|
-
if (filePath.startsWith(distSrc) && !shouldSkip(filePath)) {
|
|
329
|
-
const baseBeforeWriteFile = dtsOptions?.beforeWriteFile ?? ((filePath2, content2) => ({ filePath: filePath2, content: content2 }));
|
|
330
|
-
return await baseBeforeWriteFile(`${dist}${filePath.slice(distSrc.length)}`, content);
|
|
331
|
-
} else {
|
|
332
|
-
return false;
|
|
333
|
-
}
|
|
334
|
-
},
|
|
335
|
-
afterDiagnostic(diagnostics) {
|
|
336
|
-
const hasErrors = diagnostics.length > 0;
|
|
337
|
-
const isBuilding = command === "build";
|
|
338
|
-
const stopBuild = hasErrors && isBuilding;
|
|
339
|
-
if (stopBuild) {
|
|
340
|
-
throw new Error("TypeScript errors reported. See error messages above");
|
|
341
|
-
}
|
|
342
|
-
return dtsOptions?.afterDiagnostic?.(diagnostics);
|
|
343
|
-
}
|
|
344
|
-
})
|
|
345
|
-
)
|
|
346
|
-
];
|
|
347
|
-
}
|
|
348
|
-
function shouldSkip(id) {
|
|
349
|
-
return id.includes("__test") || id.includes(".e2e.") || id.includes(".spec.") || id.includes(".test.") || id.includes(".stories.");
|
|
350
|
-
}
|
|
351
|
-
function externalizeDependencies(options) {
|
|
352
|
-
return externalizeDependenciesImplementation(options, retrievePackageJson());
|
|
353
|
-
}
|
|
354
|
-
function externalizeDependenciesImplementation(options, packageJson) {
|
|
355
|
-
const externalDependencies = Object.keys({
|
|
356
|
-
...packageJson.dependencies,
|
|
357
|
-
...packageJson.peerDependencies,
|
|
358
|
-
...packageJson.optionalDependencies
|
|
359
|
-
});
|
|
360
|
-
const isStrictBundling = toPosixPathSeparators(void 0).includes(
|
|
361
|
-
"support-packages/components-build-utils"
|
|
362
|
-
);
|
|
363
|
-
const bundleIn = options.bundleIn?.map(stringToStartsWithGlob);
|
|
364
|
-
const explicitExternalize = options.externalize?.map(stringToStartsWithGlob) ?? [];
|
|
365
|
-
const externalize = [
|
|
366
|
-
...explicitExternalize,
|
|
367
|
-
// BUG: we shouldn't silently externalize node in browser packages.
|
|
368
|
-
// Consider erroring instead
|
|
369
|
-
/^node:/u,
|
|
370
|
-
new RegExp(
|
|
371
|
-
`^(?:${externalDependencies.join("|")}${externalDependencies.length === 0 ? "" : "|"}${node_module.builtinModules.join("|")})(?:/|$)`,
|
|
372
|
-
"u"
|
|
373
|
-
)
|
|
374
|
-
];
|
|
375
|
-
const plugin = {
|
|
376
|
-
name: pluginName,
|
|
377
|
-
apply: "build",
|
|
378
|
-
// Externalize before Vite's default resolution runs
|
|
379
|
-
enforce: "pre",
|
|
380
|
-
// Rolldown also has "external" option, which can be provided regexes.
|
|
381
|
-
// Theoretically that would be more efficient due to less communication
|
|
382
|
-
// overhead, but in practice they always evaluate it on the JS side:
|
|
383
|
-
// https://github.com/rolldown/rolldown/blob/4f996e637732a26ca04972975884abad5183292b/packages/rolldown/src/utils/bindingify-input-options.ts#L167
|
|
384
|
-
// https://github.com/rolldown/rolldown/blob/4f996e637732a26ca04972975884abad5183292b/crates/rolldown_binding/src/utils/normalize_binding_options.rs#L130
|
|
385
|
-
resolveId: {
|
|
386
|
-
filter: {
|
|
387
|
-
id: {
|
|
388
|
-
include: [
|
|
389
|
-
// In most cases, we want all dependencies in library packages to be
|
|
390
|
-
// externalized. Thus, this regex matches all non-relative imports.
|
|
391
|
-
nonRelativeSpecifierPattern,
|
|
392
|
-
// Also include explicitExternalize because those may target relative
|
|
393
|
-
// paths (e.g. ./draconvert.js in mock-services).
|
|
394
|
-
...explicitExternalize
|
|
395
|
-
],
|
|
396
|
-
exclude: bundleIn
|
|
397
|
-
}
|
|
398
|
-
},
|
|
399
|
-
handler(id, importer, resolveOptions) {
|
|
400
|
-
if (matchesAny(id, externalize)) {
|
|
401
|
-
return false;
|
|
402
|
-
}
|
|
403
|
-
if (
|
|
404
|
-
// Entrypoints look like src/components/button/button.tsx, so are
|
|
405
|
-
// matched by the nonRelativeSpecifierPattern
|
|
406
|
-
resolveOptions.isEntry || // Virtual specifiers are handled by plugins
|
|
407
|
-
id.startsWith("\0") || // data: node: virtual:
|
|
408
|
-
id.includes(":") || // ?raw ?url ?worker - resolved by other plugins
|
|
409
|
-
id.includes("?") || // Applications can bundle in anything
|
|
410
|
-
options.isApplication === true
|
|
411
|
-
) {
|
|
412
|
-
return;
|
|
413
|
-
}
|
|
414
|
-
const error = `[${pluginName}] Vite tried to bundle in "${id}" (imported by ${importer}).
|
|
415
|
-
This is likely undesirable. To externalize it, declare this dependency as a "dependency", "peerDependency" or "optionalDependency" in package.json.
|
|
416
|
-
If this is intentional, add it to the build.dependencies.bundleIn option in useLumina() or bundleIn option in the vitePresetPlugin().
|
|
417
|
-
If this is an application rather than a library, pass isApplication:true in vitePresetPlugin().`;
|
|
418
|
-
if (isStrictBundling) {
|
|
419
|
-
throw Error(error);
|
|
420
|
-
} else {
|
|
421
|
-
console.error(node_util.styleText("red", `${error}
|
|
422
|
-
This will be an error in future version.`));
|
|
423
|
-
return;
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
};
|
|
428
|
-
return plugin;
|
|
429
|
-
}
|
|
430
|
-
const pluginName = "@arcgis/components-build-utils:externalize-dependencies";
|
|
431
|
-
const stringToStartsWithGlob = (option) => typeof option === "string" ? new RegExp(
|
|
432
|
-
`^${option.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&")}${option.endsWith("/") ? "(?:.+)?" : "(?:/.+)?"}$`,
|
|
433
|
-
"u"
|
|
434
|
-
) : option;
|
|
435
|
-
const nonRelativeSpecifierPattern = /^[^\.\/]/u;
|
|
436
|
-
function matchesAny(id, patterns) {
|
|
437
|
-
for (let index = 0; index < patterns.length; ++index) {
|
|
438
|
-
if (patterns[index].test(id)) {
|
|
439
|
-
return true;
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
return false;
|
|
443
|
-
}
|
|
444
|
-
exports.asyncFindPath = asyncFindPath;
|
|
445
|
-
exports.asyncRetrievePackageJson = asyncRetrievePackageJson;
|
|
446
|
-
exports.asyncSh = asyncSh;
|
|
447
|
-
exports.createFileIfNotExists = createFileIfNotExists;
|
|
448
|
-
exports.detectPackageManager = detectPackageManager;
|
|
449
|
-
exports.existsAsync = existsAsync;
|
|
450
|
-
exports.externalizeDependencies = externalizeDependencies;
|
|
451
|
-
exports.fetchPackageLocation = fetchPackageLocation;
|
|
452
|
-
exports.findPath = findPath;
|
|
453
|
-
exports.getCwd = getCwd;
|
|
454
|
-
exports.gitIgnoreFileToGlobs = gitIgnoreFileToGlobs;
|
|
455
|
-
exports.gitIgnoreToGlob = gitIgnoreToGlob;
|
|
456
|
-
exports.isPosix = isPosix;
|
|
457
|
-
exports.normalizePath = normalizePath;
|
|
458
|
-
exports.path = path;
|
|
459
|
-
exports.retrievePackageJson = retrievePackageJson;
|
|
460
|
-
exports.sh = sh;
|
|
461
|
-
exports.sp = sp;
|
|
462
|
-
exports.toPosixPathSeparators = toPosixPathSeparators;
|
|
463
|
-
exports.toSystemPathSeparators = toSystemPathSeparators;
|
|
464
|
-
exports.vitePresetPlugin = vitePresetPlugin;
|
package/dist/index.d.cts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { existsAsync, sh, sp, asyncSh, createFileIfNotExists, findPath, asyncFindPath } from './file.ts';
|
|
2
|
-
export { gitIgnoreFileToGlobs, gitIgnoreToGlob } from './glob.ts';
|
|
3
|
-
export { isPosix, toPosixPathSeparators, normalizePath, toSystemPathSeparators, getCwd, path } from './path.ts';
|
|
4
|
-
export { type PackageJson, retrievePackageJson, asyncRetrievePackageJson, fetchPackageLocation, detectPackageManager, } from './packageJson.ts';
|
|
5
|
-
export { vitePresetPlugin, type DependencyManagementOptions, externalizeDependencies } from './vite.ts';
|
package/dist/packageJson.d.cts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A subset of the package.json typing that is interesting to Lumina.
|
|
3
|
-
*
|
|
4
|
-
* The full package.json type is insanely large (20k lines):
|
|
5
|
-
* https://github.com/ffflorian/schemastore-updater/blob/main/schemas/package/index.d.ts#L20067
|
|
6
|
-
*/
|
|
7
|
-
export type PackageJson = {
|
|
8
|
-
"name": string;
|
|
9
|
-
"version": string;
|
|
10
|
-
"private"?: boolean;
|
|
11
|
-
"type"?: "commonjs" | "module";
|
|
12
|
-
"main"?: string;
|
|
13
|
-
"module"?: string;
|
|
14
|
-
"types"?: string;
|
|
15
|
-
"files"?: string[];
|
|
16
|
-
"bin"?: Record<string, string> | string;
|
|
17
|
-
"man"?: string[] | string;
|
|
18
|
-
"dependencies"?: Record<string, string>;
|
|
19
|
-
"devDependencies"?: Record<string, string>;
|
|
20
|
-
"peerDependencies"?: Record<string, string>;
|
|
21
|
-
"peerDependenciesMeta"?: Record<string, {
|
|
22
|
-
optional?: boolean;
|
|
23
|
-
}>;
|
|
24
|
-
"optionalDependencies"?: Record<string, string>;
|
|
25
|
-
"css.customData"?: string[];
|
|
26
|
-
"customElements"?: string;
|
|
27
|
-
"html.customData"?: string[];
|
|
28
|
-
"web-types"?: string;
|
|
29
|
-
"exports"?: Record<string, Record<string, string> | string>;
|
|
30
|
-
"scripts"?: Record<string, string>;
|
|
31
|
-
"packageManager"?: string;
|
|
32
|
-
};
|
|
33
|
-
export declare function retrievePackageJson(location?: string, cache?: boolean): PackageJson;
|
|
34
|
-
export declare function asyncRetrievePackageJson(location?: string): Promise<PackageJson>;
|
|
35
|
-
/**
|
|
36
|
-
* Returns an absolute path to the root of a package in node_modules, without
|
|
37
|
-
* trailing slash.
|
|
38
|
-
*/
|
|
39
|
-
export declare function fetchPackageLocation(packageName: string, cwd?: string): Promise<string>;
|
|
40
|
-
/**
|
|
41
|
-
* Detect if current repository/monorepo uses npm, pnpm, or yarn
|
|
42
|
-
*/
|
|
43
|
-
export declare function detectPackageManager(cwd?: string): string;
|
package/dist/packageJson.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A subset of the package.json typing that is interesting to Lumina.
|
|
3
|
-
*
|
|
4
|
-
* The full package.json type is insanely large (20k lines):
|
|
5
|
-
* https://github.com/ffflorian/schemastore-updater/blob/main/schemas/package/index.d.ts#L20067
|
|
6
|
-
*/
|
|
7
|
-
export type PackageJson = {
|
|
8
|
-
"name": string;
|
|
9
|
-
"version": string;
|
|
10
|
-
"private"?: boolean;
|
|
11
|
-
"type"?: "commonjs" | "module";
|
|
12
|
-
"main"?: string;
|
|
13
|
-
"module"?: string;
|
|
14
|
-
"types"?: string;
|
|
15
|
-
"files"?: string[];
|
|
16
|
-
"bin"?: Record<string, string> | string;
|
|
17
|
-
"man"?: string[] | string;
|
|
18
|
-
"dependencies"?: Record<string, string>;
|
|
19
|
-
"devDependencies"?: Record<string, string>;
|
|
20
|
-
"peerDependencies"?: Record<string, string>;
|
|
21
|
-
"peerDependenciesMeta"?: Record<string, {
|
|
22
|
-
optional?: boolean;
|
|
23
|
-
}>;
|
|
24
|
-
"optionalDependencies"?: Record<string, string>;
|
|
25
|
-
"css.customData"?: string[];
|
|
26
|
-
"customElements"?: string;
|
|
27
|
-
"html.customData"?: string[];
|
|
28
|
-
"web-types"?: string;
|
|
29
|
-
"exports"?: Record<string, Record<string, string> | string>;
|
|
30
|
-
"scripts"?: Record<string, string>;
|
|
31
|
-
"packageManager"?: string;
|
|
32
|
-
};
|
|
33
|
-
export declare function retrievePackageJson(location?: string, cache?: boolean): PackageJson;
|
|
34
|
-
export declare function asyncRetrievePackageJson(location?: string): Promise<PackageJson>;
|
|
35
|
-
/**
|
|
36
|
-
* Returns an absolute path to the root of a package in node_modules, without
|
|
37
|
-
* trailing slash.
|
|
38
|
-
*/
|
|
39
|
-
export declare function fetchPackageLocation(packageName: string, cwd?: string): Promise<string>;
|
|
40
|
-
/**
|
|
41
|
-
* Detect if current repository/monorepo uses npm, pnpm, or yarn
|
|
42
|
-
*/
|
|
43
|
-
export declare function detectPackageManager(cwd?: string): string;
|
package/dist/path.d.cts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { posix } from 'path';
|
|
2
|
-
/**
|
|
3
|
-
* This is called "isPosix" rather than "isNotWindows" because even if we are
|
|
4
|
-
* on Windows, we could be running in a POSIX environment (e.g. WSL2)
|
|
5
|
-
*/
|
|
6
|
-
export declare const isPosix: boolean;
|
|
7
|
-
export declare const toPosixPathSeparators: (relativePath: string) => string;
|
|
8
|
-
export declare const normalizePath: (relativePath: string) => string;
|
|
9
|
-
/**
|
|
10
|
-
* On Windows, replace all `/` in the path back with `\\`. Do this only if you
|
|
11
|
-
* wish to output the path in the console or error message.
|
|
12
|
-
* On POSIX system (macOS, Linux, ...), this does not change the path (because
|
|
13
|
-
* inside the compiler we use `/` everywhere).
|
|
14
|
-
*/
|
|
15
|
-
export declare const toSystemPathSeparators: (relativePath: string) => string;
|
|
16
|
-
/**
|
|
17
|
-
* Like `process.cwd()`, but always returns a POSIX-style path
|
|
18
|
-
* (with `/` as separator).
|
|
19
|
-
*/
|
|
20
|
-
export declare const getCwd: () => string;
|
|
21
|
-
/**
|
|
22
|
-
* A wrapper for Node.js's `path` module that always uses POSIX-style paths
|
|
23
|
-
* (with `/` as separator).
|
|
24
|
-
*/
|
|
25
|
-
export declare const path: typeof posix & {
|
|
26
|
-
sep: "/";
|
|
27
|
-
};
|
|
28
|
-
export declare const exportsForTests: {
|
|
29
|
-
toWin32PathSeparators: (relativePath: string) => string;
|
|
30
|
-
};
|
package/dist/path.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { posix } from 'path';
|
|
2
|
-
/**
|
|
3
|
-
* This is called "isPosix" rather than "isNotWindows" because even if we are
|
|
4
|
-
* on Windows, we could be running in a POSIX environment (e.g. WSL2)
|
|
5
|
-
*/
|
|
6
|
-
export declare const isPosix: boolean;
|
|
7
|
-
export declare const toPosixPathSeparators: (relativePath: string) => string;
|
|
8
|
-
export declare const normalizePath: (relativePath: string) => string;
|
|
9
|
-
/**
|
|
10
|
-
* On Windows, replace all `/` in the path back with `\\`. Do this only if you
|
|
11
|
-
* wish to output the path in the console or error message.
|
|
12
|
-
* On POSIX system (macOS, Linux, ...), this does not change the path (because
|
|
13
|
-
* inside the compiler we use `/` everywhere).
|
|
14
|
-
*/
|
|
15
|
-
export declare const toSystemPathSeparators: (relativePath: string) => string;
|
|
16
|
-
/**
|
|
17
|
-
* Like `process.cwd()`, but always returns a POSIX-style path
|
|
18
|
-
* (with `/` as separator).
|
|
19
|
-
*/
|
|
20
|
-
export declare const getCwd: () => string;
|
|
21
|
-
/**
|
|
22
|
-
* A wrapper for Node.js's `path` module that always uses POSIX-style paths
|
|
23
|
-
* (with `/` as separator).
|
|
24
|
-
*/
|
|
25
|
-
export declare const path: typeof posix & {
|
|
26
|
-
sep: "/";
|
|
27
|
-
};
|
|
28
|
-
export declare const exportsForTests: {
|
|
29
|
-
toWin32PathSeparators: (relativePath: string) => string;
|
|
30
|
-
};
|