@arcgis/components-build-utils 5.2.0-next.30 → 5.2.0-next.32

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 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
- 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';
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,409 +1,33 @@
1
- import { access, existsSync, readFileSync } from "node:fs";
2
- import { constants, mkdir, writeFile, readFile } from "node:fs/promises";
3
- import { dirname, resolve, sep, join, posix, win32 } from "path";
4
- import { fileURLToPath } from "node:url";
5
- import { execSync, spawnSync, exec } from "node:child_process";
6
- import { styleText } from "node:util";
7
- import { builtinModules } from "node:module";
8
- const existsAsync = async (file) => (
9
- // Using un-promisified version because promises version creates exceptions
10
- // which interferes with debugging when "Pause on caught exceptions" is enabled
11
- await new Promise((resolve2) => access(file, constants.F_OK, (error) => resolve2(!error)))
12
- );
13
- function sh(command, options = {}) {
14
- try {
15
- const normalizedOptions = { encoding: "utf8", ...options };
16
- return execSync(command.trim(), normalizedOptions).trim();
17
- } catch (error) {
18
- makeExecErrorReadable(error);
19
- throw error;
20
- }
21
- }
22
- function sp(command, args, options = {}) {
23
- const normalizedOptions = { encoding: "utf8", ...options };
24
- const result = spawnSync(command, args, normalizedOptions);
25
- if (result.error) {
26
- throw result.error;
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 command = void 0;
245
- return [
246
- {
247
- name: "vite-preset-config",
248
- config({ build: { target } = {} }, env) {
249
- command = env.command;
250
- return {
251
- build: {
252
- // REFACTOR: get this from tsconfig
253
- // It's a best practice to let the final bundler down-level as needed.
254
- target: target ?? "es2024"
255
- },
256
- define: env.mode === "test" ? {
257
- "process.env.ESRI_INTERNAL": true
258
- } : void 0
259
- };
260
- }
261
- },
262
- externalizeDependencies({
263
- externalize,
264
- bundleIn,
265
- isApplication
266
- }),
267
- // This dependency pulls in many others. Since components-build-utils has a
268
- // single entry point, we load a large module tree needlessly. To avoid,
269
- // load the plugin on demand.
270
- dtsOptions === false ? void 0 : import("vite-plugin-dts").then(
271
- ({ default: dts }) => dts({
272
- logLevel: "warn",
273
- ...dtsOptions,
274
- compilerOptions: {
275
- rootDir: ".",
276
- ...dtsOptions.compilerOptions
277
- },
278
- /**
279
- * Do not emit any .d.ts files for files outside the dist directory
280
- * (i.e vite.config.ts, storybook stories and etc)
281
- * This also applies for references to node_modules/.../components.d.ts files in
282
- * tsconfig.json - these must be included in TypeScript program to provide
283
- * types, but should not be re-emitted during build.
284
- */
285
- beforeWriteFile: async (filePath, content) => {
286
- if (filePath.startsWith(distSrc) && !shouldSkip(filePath)) {
287
- const baseBeforeWriteFile = dtsOptions?.beforeWriteFile ?? ((filePath2, content2) => ({ filePath: filePath2, content: content2 }));
288
- return await baseBeforeWriteFile(`${dist}${filePath.slice(distSrc.length)}`, content);
289
- } else {
290
- return false;
291
- }
292
- },
293
- afterDiagnostic(diagnostics) {
294
- const hasErrors = diagnostics.length > 0;
295
- const isBuilding = command === "build";
296
- const stopBuild = hasErrors && isBuilding;
297
- if (stopBuild) {
298
- throw new Error("TypeScript errors reported. See error messages above");
299
- }
300
- return dtsOptions?.afterDiagnostic?.(diagnostics);
301
- }
302
- })
303
- )
304
- ];
305
- }
306
- function shouldSkip(id) {
307
- return id.includes("__test") || id.includes(".e2e.") || id.includes(".spec.") || id.includes(".test.") || id.includes(".stories.");
308
- }
309
- function externalizeDependencies(options) {
310
- return externalizeDependenciesImplementation(options, retrievePackageJson());
311
- }
312
- function externalizeDependenciesImplementation(options, packageJson) {
313
- const externalDependencies = Object.keys({
314
- ...packageJson.dependencies,
315
- ...packageJson.peerDependencies,
316
- ...packageJson.optionalDependencies
317
- });
318
- const isStrictBundling = toPosixPathSeparators(import.meta.dirname).includes(
319
- "support-packages/components-build-utils"
320
- );
321
- const bundleIn = options.bundleIn?.map(stringToStartsWithGlob);
322
- const explicitExternalize = options.externalize?.map(stringToStartsWithGlob) ?? [];
323
- const externalize = [
324
- ...explicitExternalize,
325
- // BUG: we shouldn't silently externalize node in browser packages.
326
- // Consider erroring instead
327
- /^node:/u,
328
- new RegExp(
329
- `^(?:${externalDependencies.join("|")}${externalDependencies.length === 0 ? "" : "|"}${builtinModules.join("|")})(?:/|$)`,
330
- "u"
331
- )
332
- ];
333
- const plugin = {
334
- name: pluginName,
335
- apply: "build",
336
- // Externalize before Vite's default resolution runs
337
- enforce: "pre",
338
- // Rolldown also has "external" option, which can be provided regexes.
339
- // Theoretically that would be more efficient due to less communication
340
- // overhead, but in practice they always evaluate it on the JS side:
341
- // https://github.com/rolldown/rolldown/blob/4f996e637732a26ca04972975884abad5183292b/packages/rolldown/src/utils/bindingify-input-options.ts#L167
342
- // https://github.com/rolldown/rolldown/blob/4f996e637732a26ca04972975884abad5183292b/crates/rolldown_binding/src/utils/normalize_binding_options.rs#L130
343
- resolveId: {
344
- filter: {
345
- id: {
346
- include: [
347
- // In most cases, we want all dependencies in library packages to be
348
- // externalized. Thus, this regex matches all non-relative imports.
349
- nonRelativeSpecifierPattern,
350
- // Also include explicitExternalize because those may target relative
351
- // paths (e.g. ./draconvert.js in mock-services).
352
- ...explicitExternalize
353
- ],
354
- exclude: bundleIn
355
- }
356
- },
357
- handler(id, importer, resolveOptions) {
358
- if (matchesAny(id, externalize)) {
359
- return false;
360
- }
361
- if (
362
- // Entrypoints look like src/components/button/button.tsx, so are
363
- // matched by the nonRelativeSpecifierPattern
364
- resolveOptions.isEntry || // Virtual specifiers are handled by plugins
365
- id.startsWith("\0") || // data: node: virtual:
366
- id.includes(":") || // ?raw ?url ?worker - resolved by other plugins
367
- id.includes("?") || // Applications can bundle in anything
368
- options.isApplication === true
369
- ) {
370
- return;
371
- }
372
- const error = `[${pluginName}] Vite tried to bundle in "${id}" (imported by ${importer}).
373
- This is likely undesirable. To externalize it, declare this dependency as a "dependency", "peerDependency" or "optionalDependency" in package.json.
374
- If this is intentional, add it to the build.dependencies.bundleIn option in useLumina() or bundleIn option in the vitePresetPlugin().
375
- If this is an application rather than a library, pass isApplication:true in vitePresetPlugin().`;
376
- if (isStrictBundling) {
377
- throw Error(error);
378
- } else {
379
- console.error(styleText("red", `${error}
380
- This will be an error in future version.`));
381
- return;
382
- }
383
- }
384
- }
385
- };
386
- return plugin;
387
- }
388
- const pluginName = "@arcgis/components-build-utils:externalize-dependencies";
389
- const stringToStartsWithGlob = (option) => typeof option === "string" ? new RegExp(
390
- `^${option.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&")}${option.endsWith("/") ? "(?:.+)?" : "(?:/.+)?"}$`,
391
- "u"
392
- ) : option;
393
- const nonRelativeSpecifierPattern = /^[^\.\/]/u;
394
- function matchesAny(id, patterns) {
395
- for (let index = 0; index < patterns.length; ++index) {
396
- if (patterns[index].test(id)) {
397
- return true;
398
- }
399
- }
400
- return false;
401
- }
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;
402
27
  export {
403
28
  asyncFindPath,
404
29
  asyncRetrievePackageJson,
405
30
  asyncSh,
406
- createFileIfNotExists,
407
31
  detectPackageManager,
408
32
  existsAsync,
409
33
  externalizeDependencies,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/components-build-utils",
3
- "version": "5.2.0-next.30",
3
+ "version": "5.2.0-next.32",
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",
@@ -8,16 +8,17 @@
8
8
  "module": "./dist/index.js",
9
9
  "types": "./dist/index.d.ts",
10
10
  "exports": {
11
- ".": "./dist/index.js"
11
+ ".": "./dist/index.js",
12
+ "./package.json": "./package.json"
12
13
  },
13
14
  "files": [
14
15
  "dist/"
15
16
  ],
16
17
  "license": "SEE LICENSE IN LICENSE.md",
17
18
  "dependencies": {
18
- "@types/node": "^24.10.0",
19
+ "@types/node": "~24.11.2",
19
20
  "tslib": "^2.8.1",
20
21
  "vite": "^7.3.2",
21
- "vite-plugin-dts": "^4.5.4"
22
+ "@arcgis/node-toolkit": "5.2.0-next.32"
22
23
  }
23
24
  }
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.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;
@@ -1,50 +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
- /**
19
- * @see https://pnpm.io/package_json#publishconfigdirectory
20
- */
21
- "publishConfig"?: {
22
- directory?: string;
23
- linkDirectory?: boolean;
24
- };
25
- "dependencies"?: Record<string, string>;
26
- "devDependencies"?: Record<string, string>;
27
- "peerDependencies"?: Record<string, string>;
28
- "peerDependenciesMeta"?: Record<string, {
29
- optional?: boolean;
30
- }>;
31
- "optionalDependencies"?: Record<string, string>;
32
- "css.customData"?: string[];
33
- "customElements"?: string;
34
- "html.customData"?: string[];
35
- "web-types"?: string;
36
- "exports"?: Record<string, Record<string, string> | string>;
37
- "scripts"?: Record<string, string>;
38
- "packageManager"?: string;
39
- };
40
- export declare function retrievePackageJson(location?: string, cache?: boolean): PackageJson;
41
- export declare function asyncRetrievePackageJson(location?: string): Promise<PackageJson>;
42
- /**
43
- * Returns an absolute path to the root of a package in node_modules, without
44
- * trailing slash.
45
- */
46
- export declare function fetchPackageLocation(packageName: string, cwd?: string): Promise<string>;
47
- /**
48
- * Detect if current repository/monorepo uses npm, pnpm, or yarn
49
- */
50
- export declare function detectPackageManager(cwd?: string): string;
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
- };
package/dist/vite.d.ts DELETED
@@ -1,101 +0,0 @@
1
- import { Plugin } from 'vite';
2
- import { default as dts } from 'vite-plugin-dts';
3
- import { PackageJson } from './packageJson.ts';
4
- /**
5
- * Vite preset for all our support packages:
6
- * - externalizes all non-dev-dependencies
7
- * - generates type declarations (using `vite-plugin-dts`)
8
- */
9
- export declare function vitePresetPlugin({ dtsOptions, externalize, bundleIn, isApplication, }?: DependencyManagementOptions & {
10
- /** Additional options for `vite-plugin-dts` */
11
- dtsOptions?: Parameters<typeof dts>[0] | false;
12
- }): [Plugin, Plugin, Promise<Plugin> | undefined];
13
- /**
14
- * Options for externalizing dependencies.
15
- */
16
- export type DependencyManagementOptions = {
17
- /**
18
- * Force bundle in these dependencies even if they are declared as
19
- * dependencies or peerDependencies.
20
- *
21
- * @example
22
- * This is desirable if you wish to control the version of a dependency or
23
- * need to post-process the dependency in some way. Usually, you will declare
24
- * such as a devDependency, but there is a use case for declaring it as a
25
- * dependency instead:
26
- *
27
- * - If TypeScript types from the bundled in dependencies are referenced in
28
- * the `.d.ts` files of your library, you will need to declare the package
29
- * as a `dependency`, so that it is still installed on the consumer's
30
- * computer so that TypeScript can correctly resolve the types of that
31
- * library.
32
- */
33
- readonly bundleIn?: (RegExp | string)[];
34
- /**
35
- * Force externalize these dependencies, even if they are declared as
36
- * devDependencies.
37
- *
38
- * @example
39
- * This is desirable if you are sure the end user will have these dependencies
40
- * available, yet do not wish to declare these as devDependencies for some
41
- * technical reasons.
42
- */
43
- readonly externalize?: (RegExp | string)[];
44
- /**
45
- * By default, this plugin errors if any devDependency is used in runtime code
46
- * to avoid bundling in dependencies in a library. In application packages,
47
- * bundling in everything is desirable, so enable this option.
48
- *
49
- * @default false
50
- */
51
- readonly isApplication?: boolean;
52
- };
53
- /**
54
- * By default, Rollup will bundle-in all dependencies.
55
- *
56
- * We change it as follows:
57
- * Externalize all packages that are defined as
58
- * "dependency" or "peerDependency" in the package.json.
59
- * If you wish to bundle-in some package, define it as a "devDependency".
60
- *
61
- * Bundling-in packages is not recommended because:
62
- * - it makes our build take longer
63
- * - it pushes larger packages to NPM
64
- * - user of our library is locked into the version of the package we bundled in
65
- * - if user has two packages using the same library, there will be two copies
66
- * served on the page
67
- * - It may break some libraries/prevent them from optimizing correctly
68
- * depending on the production/development mode, or prevent them from loading
69
- * correct code depending on browser/node.js environment.
70
- *
71
- * For example, see this statement from Lit:
72
- * https://lit.dev/docs/ssr/authoring/#:~:text=Don%27t%20bundle%20Lit,based%20on%20environment.
73
- *
74
- * @see {@link ./buildCdn.ts} for CDN dependency bundling details
75
- *
76
- * @remarks
77
- * If a dependency is both a peerDependency and a devDependency, it will still
78
- * be externalized (because all peerDependencies are externalized).
79
- */
80
- export declare function externalizeDependencies(options: DependencyManagementOptions): Plugin;
81
- interface PluginShape extends Plugin {
82
- resolveId: {
83
- filter: {
84
- id: {
85
- include: RegExp[];
86
- exclude: RegExp[] | undefined;
87
- };
88
- };
89
- handler: (id: string, importer: string | undefined, options: {
90
- isEntry: boolean;
91
- }) => false | undefined;
92
- };
93
- }
94
- declare function externalizeDependenciesImplementation(options: DependencyManagementOptions, packageJson: PackageJson): PluginShape;
95
- declare function matchesAny(id: string, patterns: readonly RegExp[]): boolean;
96
- export declare const exportsForTests: {
97
- stringToStartsWithGlob: (option: RegExp | string) => RegExp;
98
- externalizeDependenciesImplementation: typeof externalizeDependenciesImplementation;
99
- matchesAny: typeof matchesAny;
100
- };
101
- export {};