@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/README.md
CHANGED
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
Package that is part of the [ArcGIS Maps SDK for JavaScript](https://developers.arcgis.com/javascript).
|
|
6
6
|
|
|
7
|
-
It is not intended to be used directly, but rather used as a dependency by other packages in the SDK.
|
|
8
|
-
|
|
9
7
|
## License
|
|
10
8
|
|
|
11
9
|
This package is licensed under the terms described in the `LICENSE.md` file, located in the root of the package, and at https://js.arcgis.com/5.1/LICENSE.txt.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { sh as shAliased, sp as spAliased, asyncSh as asyncShAliased, findPath as findPathAliased, asyncFindPath as asyncFindPathAliased } from '@arcgis/node-toolkit/file';
|
|
2
|
+
import { gitIgnoreFileToGlobs as gitIgnoreFileToGlobsAliased } from '@arcgis/node-toolkit/glob';
|
|
3
|
+
import { retrievePackageJson as retrievePackageJsonAliased, asyncRetrievePackageJson as asyncRetrievePackageJsonAliased, fetchPackageLocation as fetchPackageLocationAliased, detectPackageManager as detectPackageManagerAliased, PackageJson as PackageJsonAliased } from '@arcgis/node-toolkit/packageJson';
|
|
4
|
+
import { vitePresetPlugin as vitePresetPluginAliased } from '@arcgis/node-toolkit/vite/presetPlugin';
|
|
5
|
+
import { DependencyManagementOptions as DependencyManagementOptionsAliased, externalizeDependencies as externalizeDependenciesAliased } from '@arcgis/node-toolkit/vite/externalizeDependenciesPlugin';
|
|
6
|
+
/** @deprecated import { existsAsync } from "@arcgis/node-toolkit/file"; instead */
|
|
7
|
+
export declare const existsAsync: (file: string) => Promise<boolean>;
|
|
8
|
+
/** @deprecated import { sh } from "@arcgis/node-toolkit/file"; instead */
|
|
9
|
+
export declare const sh: typeof shAliased;
|
|
10
|
+
/** @deprecated import { sp } from "@arcgis/node-toolkit/file"; instead */
|
|
11
|
+
export declare const sp: typeof spAliased;
|
|
12
|
+
/** @deprecated import { asyncSh } from "@arcgis/node-toolkit/file"; instead */
|
|
13
|
+
export declare const asyncSh: typeof asyncShAliased;
|
|
14
|
+
/** @deprecated import { findPath } from "@arcgis/node-toolkit/file"; instead */
|
|
15
|
+
export declare const findPath: typeof findPathAliased;
|
|
16
|
+
/** @deprecated import { asyncFindPath } from "@arcgis/node-toolkit/file"; instead */
|
|
17
|
+
export declare const asyncFindPath: typeof asyncFindPathAliased;
|
|
18
|
+
/** @deprecated import { gitIgnoreFileToGlobs } from "@arcgis/node-toolkit/glob"; instead */
|
|
19
|
+
export declare const gitIgnoreFileToGlobs: typeof gitIgnoreFileToGlobsAliased;
|
|
20
|
+
/** @deprecated import { gitIgnoreToGlob } from "@arcgis/node-toolkit/glob"; instead */
|
|
21
|
+
export declare const gitIgnoreToGlob: (pattern: string) => string;
|
|
22
|
+
/** @deprecated import { isPosix } from "@arcgis/node-toolkit/path"; instead */
|
|
23
|
+
export declare const isPosix: boolean;
|
|
24
|
+
/** @deprecated import { toPosixPathSeparators } from "@arcgis/node-toolkit/path"; instead */
|
|
25
|
+
export declare const toPosixPathSeparators: (relativePath: string) => string;
|
|
26
|
+
/** @deprecated import { normalizePath } from "@arcgis/node-toolkit/path"; instead */
|
|
27
|
+
export declare const normalizePath: (relativePath: string) => string;
|
|
28
|
+
/** @deprecated import { toSystemPathSeparators } from "@arcgis/node-toolkit/path"; instead */
|
|
29
|
+
export declare const toSystemPathSeparators: (relativePath: string) => string;
|
|
30
|
+
/** @deprecated import { getCwd } from "@arcgis/node-toolkit/path"; instead */
|
|
31
|
+
export declare const getCwd: () => string;
|
|
32
|
+
/** @deprecated import { path } from "@arcgis/node-toolkit/path"; instead */
|
|
33
|
+
export declare const path: import('path').PlatformPath & {
|
|
34
|
+
sep: "/";
|
|
35
|
+
};
|
|
36
|
+
/** @deprecated import type { PackageJson } from "@arcgis/node-toolkit/packageJson"; instead */
|
|
37
|
+
export type PackageJson = PackageJsonAliased;
|
|
38
|
+
/** @deprecated import { retrievePackageJson } from "@arcgis/node-toolkit/packageJson"; instead */
|
|
39
|
+
export declare const retrievePackageJson: typeof retrievePackageJsonAliased;
|
|
40
|
+
/** @deprecated import { asyncRetrievePackageJson } from "@arcgis/node-toolkit/packageJson"; instead */
|
|
41
|
+
export declare const asyncRetrievePackageJson: typeof asyncRetrievePackageJsonAliased;
|
|
42
|
+
/** @deprecated import { fetchPackageLocation } from "@arcgis/node-toolkit/packageJson"; instead */
|
|
43
|
+
export declare const fetchPackageLocation: typeof fetchPackageLocationAliased;
|
|
44
|
+
/** @deprecated import { detectPackageManager } from "@arcgis/node-toolkit/packageJson"; instead */
|
|
45
|
+
export declare const detectPackageManager: typeof detectPackageManagerAliased;
|
|
46
|
+
/** @deprecated import type { DependencyManagementOptions } from "@arcgis/node-toolkit/vite/externalizeDependenciesPlugin"; instead */
|
|
47
|
+
export type DependencyManagementOptions = DependencyManagementOptionsAliased;
|
|
48
|
+
/** @deprecated import { vitePresetPlugin } from "@arcgis/node-toolkit/vite/presetPlugin"; instead */
|
|
49
|
+
export declare const vitePresetPlugin: typeof vitePresetPluginAliased;
|
|
50
|
+
/** @deprecated import { externalizeDependencies } from "@arcgis/node-toolkit/vite/externalizeDependenciesPlugin"; instead */
|
|
51
|
+
export declare const externalizeDependencies: typeof externalizeDependenciesAliased;
|
package/dist/index.js
CHANGED
|
@@ -1,427 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
const output = `${result.stdout ?? ""}${result.stderr ?? ""}`.trim();
|
|
29
|
-
const exitCode = result.status ?? 0;
|
|
30
|
-
if (exitCode !== 0) {
|
|
31
|
-
throw new Error(
|
|
32
|
-
`Command failed with exit code ${String(exitCode)}: ${command} ${args.join(" ")}
|
|
33
|
-
${output}`.trim()
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
return output;
|
|
37
|
-
}
|
|
38
|
-
async function asyncSh(command, options = {}) {
|
|
39
|
-
const normalizedOptions = { encoding: "utf8", ...options };
|
|
40
|
-
return await new Promise((resolve2, reject) => {
|
|
41
|
-
exec(command.trim(), normalizedOptions, (error, stdout, stderr) => {
|
|
42
|
-
if (error) {
|
|
43
|
-
makeExecErrorReadable(error);
|
|
44
|
-
reject(error);
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
resolve2(stdout.trim() || stderr.trim());
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
function makeExecErrorReadable(error) {
|
|
52
|
-
if (error instanceof Error && error.stack && "output" in error && Array.isArray(error.output) && "status" in error) {
|
|
53
|
-
const stackIndex = error.stack.indexOf("\n at ");
|
|
54
|
-
if (stackIndex !== -1) {
|
|
55
|
-
const output = error.output.filter(Boolean).join("\n").trim();
|
|
56
|
-
const newHeader = `${styleText("red", error.message)} (exit code: ${String(error.status)})
|
|
57
|
-
${output}`;
|
|
58
|
-
const oldStackFrames = error.stack.substring(stackIndex);
|
|
59
|
-
error.stack = `Error: ${newHeader}${oldStackFrames}`;
|
|
60
|
-
}
|
|
61
|
-
Object.defineProperties(error, {
|
|
62
|
-
output: { enumerable: false },
|
|
63
|
-
stdout: { enumerable: false },
|
|
64
|
-
stderr: { enumerable: false },
|
|
65
|
-
signal: { enumerable: false },
|
|
66
|
-
status: { enumerable: false },
|
|
67
|
-
pid: { enumerable: false },
|
|
68
|
-
stdio: { enumerable: false }
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
async function createFileIfNotExists(filePath, content) {
|
|
73
|
-
await mkdir(dirname(filePath), { recursive: true });
|
|
74
|
-
if (!await existsAsync(filePath)) {
|
|
75
|
-
await writeFile(filePath, content, { encoding: "utf8" });
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
function findPath(target, startDirectory = process.cwd()) {
|
|
79
|
-
const resolvedStartDirectory = startDirectory.startsWith("file:///") ? dirname(fileURLToPath(startDirectory)) : resolve(startDirectory);
|
|
80
|
-
const parentPath = resolvedStartDirectory.split(sep);
|
|
81
|
-
while (parentPath.length > searchStopIndex) {
|
|
82
|
-
const fullPath = join(
|
|
83
|
-
...sep === "/" ? ["/"] : [],
|
|
84
|
-
...parentPath,
|
|
85
|
-
target
|
|
86
|
-
);
|
|
87
|
-
if (existsSync(fullPath)) {
|
|
88
|
-
return fullPath;
|
|
89
|
-
}
|
|
90
|
-
parentPath.pop();
|
|
91
|
-
}
|
|
92
|
-
return void 0;
|
|
93
|
-
}
|
|
94
|
-
const searchStopIndex = 0;
|
|
95
|
-
async function asyncFindPath(target, startDirectory = process.cwd()) {
|
|
96
|
-
const resolvedStartDirectory = startDirectory.startsWith("file:///") ? dirname(fileURLToPath(startDirectory)) : resolve(startDirectory);
|
|
97
|
-
const parentPath = resolvedStartDirectory.split(sep);
|
|
98
|
-
while (parentPath.length > searchStopIndex) {
|
|
99
|
-
const fullPath = join(
|
|
100
|
-
...sep === "/" ? ["/"] : [],
|
|
101
|
-
...parentPath,
|
|
102
|
-
target
|
|
103
|
-
);
|
|
104
|
-
if (await existsAsync(fullPath)) {
|
|
105
|
-
return fullPath;
|
|
106
|
-
}
|
|
107
|
-
parentPath.pop();
|
|
108
|
-
}
|
|
109
|
-
return void 0;
|
|
110
|
-
}
|
|
111
|
-
function gitIgnoreFileToGlobs(filePath) {
|
|
112
|
-
return readFileSync(filePath, "utf8").split("\n").filter((line) => line.trim().length > 0 && !line.trim().startsWith("#")).map(gitIgnoreToGlob);
|
|
113
|
-
}
|
|
114
|
-
const gitIgnoreToGlob = (pattern) => fixAbsoluteSyntax(fixMatchFilesSyntax(pattern));
|
|
115
|
-
function fixAbsoluteSyntax(pattern) {
|
|
116
|
-
if (pattern.startsWith("/")) {
|
|
117
|
-
return pattern.slice(1);
|
|
118
|
-
}
|
|
119
|
-
if (pattern.startsWith("!/")) {
|
|
120
|
-
return `!${pattern.slice(2)}`;
|
|
121
|
-
}
|
|
122
|
-
const isAlreadyCorrect = pattern.startsWith("**") || pattern.startsWith("!**");
|
|
123
|
-
const basePattern = pattern.startsWith("!") ? pattern.slice(1) : pattern;
|
|
124
|
-
return isAlreadyCorrect ? pattern : `${pattern.startsWith("!") ? "!" : ""}**/${basePattern}`;
|
|
125
|
-
}
|
|
126
|
-
function fixMatchFilesSyntax(pattern) {
|
|
127
|
-
const base = pattern.split("/").at(-1);
|
|
128
|
-
const isAlreadyCorrect = pattern.endsWith("**") || pattern.includes("{") || base?.includes(".");
|
|
129
|
-
if (isAlreadyCorrect) {
|
|
130
|
-
return pattern;
|
|
131
|
-
}
|
|
132
|
-
return pattern.endsWith("/*") ? `${pattern}*` : pattern.endsWith("/") ? `${pattern}**` : `${pattern}/**`;
|
|
133
|
-
}
|
|
134
|
-
const isPosix = sep === posix.sep;
|
|
135
|
-
const toPosixPathSeparators = (relativePath) => relativePath.includes(win32.sep) ? relativePath.replaceAll(win32.sep, posix.sep) : relativePath;
|
|
136
|
-
const normalizePath = isPosix ? (path2) => path2 : toPosixPathSeparators;
|
|
137
|
-
const toWin32PathSeparators = (relativePath) => relativePath.includes(posix.sep) ? relativePath.replaceAll(posix.sep, win32.sep) : relativePath;
|
|
138
|
-
const toSystemPathSeparators = isPosix ? (path2) => path2 : toWin32PathSeparators;
|
|
139
|
-
const getCwd = isPosix ? process.cwd : () => toPosixPathSeparators(process.cwd());
|
|
140
|
-
const path = isPosix ? posix : {
|
|
141
|
-
...win32,
|
|
142
|
-
sep: posix.sep,
|
|
143
|
-
join(...paths) {
|
|
144
|
-
const result = win32.join(...paths);
|
|
145
|
-
return toPosixPathSeparators(result);
|
|
146
|
-
},
|
|
147
|
-
normalize(path2) {
|
|
148
|
-
const result = win32.normalize(path2);
|
|
149
|
-
return toPosixPathSeparators(result);
|
|
150
|
-
},
|
|
151
|
-
relative(from, to) {
|
|
152
|
-
const result = win32.relative(from, to);
|
|
153
|
-
return toPosixPathSeparators(result);
|
|
154
|
-
},
|
|
155
|
-
dirname(path2) {
|
|
156
|
-
const result = win32.dirname(path2);
|
|
157
|
-
return toPosixPathSeparators(result);
|
|
158
|
-
},
|
|
159
|
-
resolve(...paths) {
|
|
160
|
-
const result = win32.resolve(...paths);
|
|
161
|
-
return toPosixPathSeparators(result);
|
|
162
|
-
},
|
|
163
|
-
toNamespacedPath(path2) {
|
|
164
|
-
const result = win32.toNamespacedPath(path2);
|
|
165
|
-
return toPosixPathSeparators(result);
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
const cachedPackageJson = {};
|
|
169
|
-
const cachedPackageJsonPromises = {};
|
|
170
|
-
let rootPackageJsonLocation;
|
|
171
|
-
function retrievePackageJson(location, cache = true) {
|
|
172
|
-
const packageJsonPath = location ? path.resolve(location, "package.json") : rootPackageJsonLocation ??= findPath("package.json");
|
|
173
|
-
if (cache) {
|
|
174
|
-
cachedPackageJson[packageJsonPath] ??= JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
175
|
-
return cachedPackageJson[packageJsonPath];
|
|
176
|
-
}
|
|
177
|
-
return JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
178
|
-
}
|
|
179
|
-
async function asyncRetrievePackageJson(location) {
|
|
180
|
-
const packageJsonPath = location ? path.resolve(location, "package.json") : rootPackageJsonLocation ??= findPath("package.json");
|
|
181
|
-
if (packageJsonPath in cachedPackageJson) {
|
|
182
|
-
return cachedPackageJson[packageJsonPath];
|
|
183
|
-
}
|
|
184
|
-
cachedPackageJsonPromises[packageJsonPath] ??= asyncReadPackageJson(packageJsonPath);
|
|
185
|
-
const result = await cachedPackageJsonPromises[packageJsonPath];
|
|
186
|
-
cachedPackageJson[packageJsonPath] ??= result;
|
|
187
|
-
return result;
|
|
188
|
-
}
|
|
189
|
-
const asyncReadPackageJson = async (location) => JSON.parse(await readFile(location, "utf-8"));
|
|
190
|
-
const cachedPackageLocation = {};
|
|
191
|
-
const cachedPackageLocationPromises = {};
|
|
192
|
-
async function fetchPackageLocation(packageName, cwd) {
|
|
193
|
-
if (packageName in cachedPackageLocation) {
|
|
194
|
-
return cachedPackageLocation[packageName];
|
|
195
|
-
}
|
|
196
|
-
cachedPackageLocationPromises[packageName] ??= asyncFindPath(
|
|
197
|
-
path.join("node_modules", packageName, "package.json"),
|
|
198
|
-
cwd
|
|
199
|
-
).then((packageJsonLocation) => {
|
|
200
|
-
if (packageJsonLocation === void 0) {
|
|
201
|
-
throw Error(
|
|
202
|
-
`@arcgis/components-build-utils: Unable to resolve package.json location for "${packageName}" package. Current working directory: ${process.cwd()}`
|
|
203
|
-
);
|
|
204
|
-
}
|
|
205
|
-
return path.dirname(packageJsonLocation);
|
|
206
|
-
});
|
|
207
|
-
const result = await cachedPackageLocationPromises[packageName];
|
|
208
|
-
cachedPackageLocation[packageName] ??= result;
|
|
209
|
-
return cachedPackageLocation[packageName];
|
|
210
|
-
}
|
|
211
|
-
function detectPackageManager(cwd = process.cwd()) {
|
|
212
|
-
let packageManager = void 0;
|
|
213
|
-
{
|
|
214
|
-
const pathParts = path.resolve(cwd).split(path.sep);
|
|
215
|
-
while (pathParts.length > 1) {
|
|
216
|
-
const packageJson = path.join(pathParts.join(path.sep), "package.json");
|
|
217
|
-
pathParts.pop();
|
|
218
|
-
if (!existsSync(packageJson)) {
|
|
219
|
-
continue;
|
|
220
|
-
}
|
|
221
|
-
const contents = JSON.parse(readFileSync(packageJson, "utf8"));
|
|
222
|
-
if (typeof contents !== "object" || Array.isArray(contents)) {
|
|
223
|
-
continue;
|
|
224
|
-
}
|
|
225
|
-
if (typeof contents.packageManager === "string") {
|
|
226
|
-
packageManager ??= contents.packageManager.match(/\w+/u)?.[0] ?? packageManager;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
packageManager ??= "npm";
|
|
231
|
-
return packageManager;
|
|
232
|
-
}
|
|
233
|
-
function vitePresetPlugin({
|
|
234
|
-
dtsOptions = {},
|
|
235
|
-
externalize,
|
|
236
|
-
bundleIn,
|
|
237
|
-
isApplication
|
|
238
|
-
} = {
|
|
239
|
-
externalize: [],
|
|
240
|
-
dtsOptions: {}
|
|
241
|
-
}) {
|
|
242
|
-
const dist = `${path.resolve("dist")}/`;
|
|
243
|
-
const distSrc = `${dist}src/`;
|
|
244
|
-
let userConfig = void 0;
|
|
245
|
-
let command = void 0;
|
|
246
|
-
return [
|
|
247
|
-
{
|
|
248
|
-
name: "vite-preset-config",
|
|
249
|
-
config({ build: { target } = {} }, env) {
|
|
250
|
-
command = env.command;
|
|
251
|
-
return {
|
|
252
|
-
build: {
|
|
253
|
-
// REFACTOR: get this from tsconfig
|
|
254
|
-
// It's a best practice to let the final bundler down-level as needed.
|
|
255
|
-
target: target ?? "es2024"
|
|
256
|
-
},
|
|
257
|
-
define: env.mode === "test" ? {
|
|
258
|
-
"process.env.ESRI_INTERNAL": true
|
|
259
|
-
} : void 0
|
|
260
|
-
};
|
|
261
|
-
},
|
|
262
|
-
configResolved(config) {
|
|
263
|
-
userConfig = config;
|
|
264
|
-
}
|
|
265
|
-
},
|
|
266
|
-
externalizeDependencies({
|
|
267
|
-
externalize,
|
|
268
|
-
bundleIn,
|
|
269
|
-
isApplication
|
|
270
|
-
}),
|
|
271
|
-
// This dependency pulls in many others. Since components-build-utils has a
|
|
272
|
-
// single entry point, we load a large module tree needlessly. To avoid,
|
|
273
|
-
// load the plugin on demand.
|
|
274
|
-
dtsOptions === false ? void 0 : import("vite-plugin-dts").then(
|
|
275
|
-
({ default: dts }) => dts({
|
|
276
|
-
logLevel: "warn",
|
|
277
|
-
// Copies .d.ts files to d.cjs file for CommonJS.
|
|
278
|
-
// Adds a performance hit as it occurs after the build
|
|
279
|
-
async afterBuild(emitted) {
|
|
280
|
-
if (userConfig?.build?.lib && userConfig.build.lib.formats?.includes("cjs")) {
|
|
281
|
-
await Promise.all(
|
|
282
|
-
emitted.entries().map(async ([filePath, content]) => {
|
|
283
|
-
if (filePath.endsWith(".d.ts")) {
|
|
284
|
-
await writeFile(filePath.replace(".d.ts", ".d.cts"), content);
|
|
285
|
-
}
|
|
286
|
-
})
|
|
287
|
-
);
|
|
288
|
-
}
|
|
289
|
-
await dtsOptions?.afterBuild?.(emitted);
|
|
290
|
-
},
|
|
291
|
-
...dtsOptions,
|
|
292
|
-
compilerOptions: {
|
|
293
|
-
rootDir: ".",
|
|
294
|
-
...dtsOptions.compilerOptions
|
|
295
|
-
},
|
|
296
|
-
/**
|
|
297
|
-
* Do not emit any .d.ts files for files outside the dist directory
|
|
298
|
-
* (i.e vite.config.ts, storybook stories and etc)
|
|
299
|
-
* This also applies for references to node_modules/.../components.d.ts files in
|
|
300
|
-
* tsconfig.json - these must be included in TypeScript program to provide
|
|
301
|
-
* types, but should not be re-emitted during build.
|
|
302
|
-
*/
|
|
303
|
-
beforeWriteFile: async (filePath, content) => {
|
|
304
|
-
if (filePath.startsWith(distSrc) && !shouldSkip(filePath)) {
|
|
305
|
-
const baseBeforeWriteFile = dtsOptions?.beforeWriteFile ?? ((filePath2, content2) => ({ filePath: filePath2, content: content2 }));
|
|
306
|
-
return await baseBeforeWriteFile(`${dist}${filePath.slice(distSrc.length)}`, content);
|
|
307
|
-
} else {
|
|
308
|
-
return false;
|
|
309
|
-
}
|
|
310
|
-
},
|
|
311
|
-
afterDiagnostic(diagnostics) {
|
|
312
|
-
const hasErrors = diagnostics.length > 0;
|
|
313
|
-
const isBuilding = command === "build";
|
|
314
|
-
const stopBuild = hasErrors && isBuilding;
|
|
315
|
-
if (stopBuild) {
|
|
316
|
-
throw new Error("TypeScript errors reported. See error messages above");
|
|
317
|
-
}
|
|
318
|
-
return dtsOptions?.afterDiagnostic?.(diagnostics);
|
|
319
|
-
}
|
|
320
|
-
})
|
|
321
|
-
)
|
|
322
|
-
];
|
|
323
|
-
}
|
|
324
|
-
function shouldSkip(id) {
|
|
325
|
-
return id.includes("__test") || id.includes(".e2e.") || id.includes(".spec.") || id.includes(".test.") || id.includes(".stories.");
|
|
326
|
-
}
|
|
327
|
-
function externalizeDependencies(options) {
|
|
328
|
-
return externalizeDependenciesImplementation(options, retrievePackageJson());
|
|
329
|
-
}
|
|
330
|
-
function externalizeDependenciesImplementation(options, packageJson) {
|
|
331
|
-
const externalDependencies = Object.keys({
|
|
332
|
-
...packageJson.dependencies,
|
|
333
|
-
...packageJson.peerDependencies,
|
|
334
|
-
...packageJson.optionalDependencies
|
|
335
|
-
});
|
|
336
|
-
const isStrictBundling = toPosixPathSeparators(import.meta.dirname).includes(
|
|
337
|
-
"support-packages/components-build-utils"
|
|
338
|
-
);
|
|
339
|
-
const bundleIn = options.bundleIn?.map(stringToStartsWithGlob);
|
|
340
|
-
const explicitExternalize = options.externalize?.map(stringToStartsWithGlob) ?? [];
|
|
341
|
-
const externalize = [
|
|
342
|
-
...explicitExternalize,
|
|
343
|
-
// BUG: we shouldn't silently externalize node in browser packages.
|
|
344
|
-
// Consider erroring instead
|
|
345
|
-
/^node:/u,
|
|
346
|
-
new RegExp(
|
|
347
|
-
`^(?:${externalDependencies.join("|")}${externalDependencies.length === 0 ? "" : "|"}${builtinModules.join("|")})(?:/|$)`,
|
|
348
|
-
"u"
|
|
349
|
-
)
|
|
350
|
-
];
|
|
351
|
-
const plugin = {
|
|
352
|
-
name: pluginName,
|
|
353
|
-
apply: "build",
|
|
354
|
-
// Externalize before Vite's default resolution runs
|
|
355
|
-
enforce: "pre",
|
|
356
|
-
// Rolldown also has "external" option, which can be provided regexes.
|
|
357
|
-
// Theoretically that would be more efficient due to less communication
|
|
358
|
-
// overhead, but in practice they always evaluate it on the JS side:
|
|
359
|
-
// https://github.com/rolldown/rolldown/blob/4f996e637732a26ca04972975884abad5183292b/packages/rolldown/src/utils/bindingify-input-options.ts#L167
|
|
360
|
-
// https://github.com/rolldown/rolldown/blob/4f996e637732a26ca04972975884abad5183292b/crates/rolldown_binding/src/utils/normalize_binding_options.rs#L130
|
|
361
|
-
resolveId: {
|
|
362
|
-
filter: {
|
|
363
|
-
id: {
|
|
364
|
-
include: [
|
|
365
|
-
// In most cases, we want all dependencies in library packages to be
|
|
366
|
-
// externalized. Thus, this regex matches all non-relative imports.
|
|
367
|
-
nonRelativeSpecifierPattern,
|
|
368
|
-
// Also include explicitExternalize because those may target relative
|
|
369
|
-
// paths (e.g. ./draconvert.js in mock-services).
|
|
370
|
-
...explicitExternalize
|
|
371
|
-
],
|
|
372
|
-
exclude: bundleIn
|
|
373
|
-
}
|
|
374
|
-
},
|
|
375
|
-
handler(id, importer, resolveOptions) {
|
|
376
|
-
if (matchesAny(id, externalize)) {
|
|
377
|
-
return false;
|
|
378
|
-
}
|
|
379
|
-
if (
|
|
380
|
-
// Entrypoints look like src/components/button/button.tsx, so are
|
|
381
|
-
// matched by the nonRelativeSpecifierPattern
|
|
382
|
-
resolveOptions.isEntry || // Virtual specifiers are handled by plugins
|
|
383
|
-
id.startsWith("\0") || // data: node: virtual:
|
|
384
|
-
id.includes(":") || // ?raw ?url ?worker - resolved by other plugins
|
|
385
|
-
id.includes("?") || // Applications can bundle in anything
|
|
386
|
-
options.isApplication === true
|
|
387
|
-
) {
|
|
388
|
-
return;
|
|
389
|
-
}
|
|
390
|
-
const error = `[${pluginName}] Vite tried to bundle in "${id}" (imported by ${importer}).
|
|
391
|
-
This is likely undesirable. To externalize it, declare this dependency as a "dependency", "peerDependency" or "optionalDependency" in package.json.
|
|
392
|
-
If this is intentional, add it to the build.dependencies.bundleIn option in useLumina() or bundleIn option in the vitePresetPlugin().
|
|
393
|
-
If this is an application rather than a library, pass isApplication:true in vitePresetPlugin().`;
|
|
394
|
-
if (isStrictBundling) {
|
|
395
|
-
throw Error(error);
|
|
396
|
-
} else {
|
|
397
|
-
console.error(styleText("red", `${error}
|
|
398
|
-
This will be an error in future version.`));
|
|
399
|
-
return;
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
};
|
|
404
|
-
return plugin;
|
|
405
|
-
}
|
|
406
|
-
const pluginName = "@arcgis/components-build-utils:externalize-dependencies";
|
|
407
|
-
const stringToStartsWithGlob = (option) => typeof option === "string" ? new RegExp(
|
|
408
|
-
`^${option.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&")}${option.endsWith("/") ? "(?:.+)?" : "(?:/.+)?"}$`,
|
|
409
|
-
"u"
|
|
410
|
-
) : option;
|
|
411
|
-
const nonRelativeSpecifierPattern = /^[^\.\/]/u;
|
|
412
|
-
function matchesAny(id, patterns) {
|
|
413
|
-
for (let index = 0; index < patterns.length; ++index) {
|
|
414
|
-
if (patterns[index].test(id)) {
|
|
415
|
-
return true;
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
return false;
|
|
419
|
-
}
|
|
1
|
+
import { asyncFindPath as asyncFindPath$1, asyncSh as asyncSh$1, existsAsync as existsAsync$1, findPath as findPath$1, sh as sh$1, sp as sp$1 } from "@arcgis/node-toolkit/file";
|
|
2
|
+
import { gitIgnoreFileToGlobs as gitIgnoreFileToGlobs$1, gitIgnoreToGlob as gitIgnoreToGlob$1 } from "@arcgis/node-toolkit/glob";
|
|
3
|
+
import { getCwd as getCwd$1, isPosix as isPosix$1, normalizePath as normalizePath$1, path as path$1, toPosixPathSeparators as toPosixPathSeparators$1, toSystemPathSeparators as toSystemPathSeparators$1 } from "@arcgis/node-toolkit/path";
|
|
4
|
+
import { asyncRetrievePackageJson as asyncRetrievePackageJson$1, detectPackageManager as detectPackageManager$1, fetchPackageLocation as fetchPackageLocation$1, retrievePackageJson as retrievePackageJson$1 } from "@arcgis/node-toolkit/packageJson";
|
|
5
|
+
import { vitePresetPlugin as vitePresetPlugin$1 } from "@arcgis/node-toolkit/vite/presetPlugin";
|
|
6
|
+
import { externalizeDependencies as externalizeDependencies$1 } from "@arcgis/node-toolkit/vite/externalizeDependenciesPlugin";
|
|
7
|
+
const existsAsync = existsAsync$1;
|
|
8
|
+
const sh = sh$1;
|
|
9
|
+
const sp = sp$1;
|
|
10
|
+
const asyncSh = asyncSh$1;
|
|
11
|
+
const findPath = findPath$1;
|
|
12
|
+
const asyncFindPath = asyncFindPath$1;
|
|
13
|
+
const gitIgnoreFileToGlobs = gitIgnoreFileToGlobs$1;
|
|
14
|
+
const gitIgnoreToGlob = gitIgnoreToGlob$1;
|
|
15
|
+
const isPosix = isPosix$1;
|
|
16
|
+
const toPosixPathSeparators = toPosixPathSeparators$1;
|
|
17
|
+
const normalizePath = normalizePath$1;
|
|
18
|
+
const toSystemPathSeparators = toSystemPathSeparators$1;
|
|
19
|
+
const getCwd = getCwd$1;
|
|
20
|
+
const path = path$1;
|
|
21
|
+
const retrievePackageJson = retrievePackageJson$1;
|
|
22
|
+
const asyncRetrievePackageJson = asyncRetrievePackageJson$1;
|
|
23
|
+
const fetchPackageLocation = fetchPackageLocation$1;
|
|
24
|
+
const detectPackageManager = detectPackageManager$1;
|
|
25
|
+
const vitePresetPlugin = vitePresetPlugin$1;
|
|
26
|
+
const externalizeDependencies = externalizeDependencies$1;
|
|
420
27
|
export {
|
|
421
28
|
asyncFindPath,
|
|
422
29
|
asyncRetrievePackageJson,
|
|
423
30
|
asyncSh,
|
|
424
|
-
createFileIfNotExists,
|
|
425
31
|
detectPackageManager,
|
|
426
32
|
existsAsync,
|
|
427
33
|
externalizeDependencies,
|
package/package.json
CHANGED
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcgis/components-build-utils",
|
|
3
|
-
"version": "5.2.0-next.
|
|
3
|
+
"version": "5.2.0-next.31",
|
|
4
4
|
"description": "Collection of common internal build-time patterns and utilities for ArcGIS Maps SDK for JavaScript components.",
|
|
5
5
|
"homepage": "https://developers.arcgis.com/javascript/latest/",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"main": "./dist/index.
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
8
|
"module": "./dist/index.js",
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
10
10
|
"exports": {
|
|
11
|
-
".":
|
|
12
|
-
|
|
13
|
-
"import": "./dist/index.js",
|
|
14
|
-
"require": "./dist/index.cjs"
|
|
15
|
-
}
|
|
11
|
+
".": "./dist/index.js",
|
|
12
|
+
"./package.json": "./package.json"
|
|
16
13
|
},
|
|
17
14
|
"files": [
|
|
18
15
|
"dist/"
|
|
19
16
|
],
|
|
20
17
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
21
18
|
"dependencies": {
|
|
22
|
-
"@types/node": "
|
|
19
|
+
"@types/node": "~24.11.2",
|
|
23
20
|
"tslib": "^2.8.1",
|
|
24
21
|
"vite": "^7.3.2",
|
|
25
|
-
"
|
|
22
|
+
"@arcgis/node-toolkit": "5.2.0-next.31"
|
|
26
23
|
}
|
|
27
24
|
}
|
package/dist/file.d.cts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ExecSyncOptionsWithStringEncoding, SpawnSyncOptionsWithStringEncoding } from 'node:child_process';
|
|
2
|
-
export declare const existsAsync: (file: string) => Promise<boolean>;
|
|
3
|
-
/** Wrapper for execSync to execute shell commands */
|
|
4
|
-
export declare function sh(command: string, options?: Partial<ExecSyncOptionsWithStringEncoding>): string;
|
|
5
|
-
/** Wrapper for spawnSync to execute commands without shell interpolation. */
|
|
6
|
-
export declare function sp(command: string, args: string[], options?: Partial<SpawnSyncOptionsWithStringEncoding>): string;
|
|
7
|
-
export declare function asyncSh(command: string, options?: Partial<ExecSyncOptionsWithStringEncoding>): Promise<string>;
|
|
8
|
-
export declare function createFileIfNotExists(filePath: string, content: string): Promise<void>;
|
|
9
|
-
/**
|
|
10
|
-
* Climb the directory tree upward, until found a directory that contains the
|
|
11
|
-
* target file, and return resulting full path
|
|
12
|
-
*/
|
|
13
|
-
export declare function findPath(target: string, startDirectory?: string): string | undefined;
|
|
14
|
-
/**
|
|
15
|
-
* Climb the directory tree upward, until found a directory that contains the
|
|
16
|
-
* target file, and return resulting full path
|
|
17
|
-
*/
|
|
18
|
-
export declare function asyncFindPath(target: string, startDirectory?: string): Promise<string | undefined>;
|
package/dist/file.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ExecSyncOptionsWithStringEncoding, SpawnSyncOptionsWithStringEncoding } from 'node:child_process';
|
|
2
|
-
export declare const existsAsync: (file: string) => Promise<boolean>;
|
|
3
|
-
/** Wrapper for execSync to execute shell commands */
|
|
4
|
-
export declare function sh(command: string, options?: Partial<ExecSyncOptionsWithStringEncoding>): string;
|
|
5
|
-
/** Wrapper for spawnSync to execute commands without shell interpolation. */
|
|
6
|
-
export declare function sp(command: string, args: string[], options?: Partial<SpawnSyncOptionsWithStringEncoding>): string;
|
|
7
|
-
export declare function asyncSh(command: string, options?: Partial<ExecSyncOptionsWithStringEncoding>): Promise<string>;
|
|
8
|
-
export declare function createFileIfNotExists(filePath: string, content: string): Promise<void>;
|
|
9
|
-
/**
|
|
10
|
-
* Climb the directory tree upward, until found a directory that contains the
|
|
11
|
-
* target file, and return resulting full path
|
|
12
|
-
*/
|
|
13
|
-
export declare function findPath(target: string, startDirectory?: string): string | undefined;
|
|
14
|
-
/**
|
|
15
|
-
* Climb the directory tree upward, until found a directory that contains the
|
|
16
|
-
* target file, and return resulting full path
|
|
17
|
-
*/
|
|
18
|
-
export declare function asyncFindPath(target: string, startDirectory?: string): Promise<string | undefined>;
|
package/dist/glob.d.cts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Read `.gitignore` files and convert it to globs that are accepted by ESLint
|
|
3
|
-
*
|
|
4
|
-
* @example
|
|
5
|
-
* ```ts
|
|
6
|
-
* // eslint.config.js
|
|
7
|
-
* import { gitIgnoreFileToGlobs } from "@arcgis/components-build-utils";
|
|
8
|
-
* import { globalIgnores } from "eslint/config";
|
|
9
|
-
*
|
|
10
|
-
* export default [
|
|
11
|
-
* globalIgnores([
|
|
12
|
-
* ...gitIgnoreFileToGlobs(import.meta.dirname + "/.gitignore"),
|
|
13
|
-
* ...gitIgnoreFileToGlobs(import.meta.dirname + "/.prettierignore"),
|
|
14
|
-
* ]),
|
|
15
|
-
* // ...
|
|
16
|
-
* ];
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export declare function gitIgnoreFileToGlobs(filePath: string): string[];
|
|
20
|
-
/**
|
|
21
|
-
* @deprecated Use gitIgnoreFileToGlobs from "@arcgis/components-build-utils"
|
|
22
|
-
* instead
|
|
23
|
-
*/
|
|
24
|
-
export declare const gitIgnoreToGlob: (pattern: string) => string;
|
package/dist/glob.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Read `.gitignore` files and convert it to globs that are accepted by ESLint
|
|
3
|
-
*
|
|
4
|
-
* @example
|
|
5
|
-
* ```ts
|
|
6
|
-
* // eslint.config.js
|
|
7
|
-
* import { gitIgnoreFileToGlobs } from "@arcgis/components-build-utils";
|
|
8
|
-
* import { globalIgnores } from "eslint/config";
|
|
9
|
-
*
|
|
10
|
-
* export default [
|
|
11
|
-
* globalIgnores([
|
|
12
|
-
* ...gitIgnoreFileToGlobs(import.meta.dirname + "/.gitignore"),
|
|
13
|
-
* ...gitIgnoreFileToGlobs(import.meta.dirname + "/.prettierignore"),
|
|
14
|
-
* ]),
|
|
15
|
-
* // ...
|
|
16
|
-
* ];
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export declare function gitIgnoreFileToGlobs(filePath: string): string[];
|
|
20
|
-
/**
|
|
21
|
-
* @deprecated Use gitIgnoreFileToGlobs from "@arcgis/components-build-utils"
|
|
22
|
-
* instead
|
|
23
|
-
*/
|
|
24
|
-
export declare const gitIgnoreToGlob: (pattern: string) => string;
|