@arcgis/components-build-utils 4.34.0-next.126 → 4.34.0-next.128

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/dist/glob.d.cts CHANGED
@@ -1 +1,24 @@
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
+ */
1
24
  export declare const gitIgnoreToGlob: (pattern: string) => string;
package/dist/glob.d.ts CHANGED
@@ -1 +1,24 @@
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
+ */
1
24
  export declare const gitIgnoreToGlob: (pattern: string) => string;
package/dist/index.cjs CHANGED
@@ -3,10 +3,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const node_fs = require("node:fs");
4
4
  const promises = require("node:fs/promises");
5
5
  const node_child_process = require("node:child_process");
6
- const node_path = require("node:path");
6
+ const path$1 = require("path");
7
7
  const node_url = require("node:url");
8
- const posix = require("node:path/posix");
9
- const win32 = require("node:path/win32");
8
+ const posix = require("path/posix");
9
+ const win32 = require("path/win32");
10
10
  const dts = require("vite-plugin-dts");
11
11
  const node_module = require("node:module");
12
12
  const existsAsync = async (file) => (
@@ -16,17 +16,17 @@ const existsAsync = async (file) => (
16
16
  );
17
17
  const sh = (command, cwd) => node_child_process.execSync(command.trim(), { encoding: "utf8", cwd }).trim();
18
18
  async function createFileIfNotExists(filePath, content) {
19
- await promises.mkdir(node_path.dirname(filePath), { recursive: true });
19
+ await promises.mkdir(path$1.dirname(filePath), { recursive: true });
20
20
  if (!await existsAsync(filePath)) {
21
21
  await promises.writeFile(filePath, content, { encoding: "utf8" });
22
22
  }
23
23
  }
24
24
  function findPath(target, startDirectory = process.cwd()) {
25
- const resolvedStartDirectory = startDirectory.startsWith("file:///") ? node_path.dirname(node_url.fileURLToPath(startDirectory)) : node_path.resolve(startDirectory);
26
- const parentPath = resolvedStartDirectory.split(node_path.sep);
25
+ const resolvedStartDirectory = startDirectory.startsWith("file:///") ? path$1.dirname(node_url.fileURLToPath(startDirectory)) : path$1.resolve(startDirectory);
26
+ const parentPath = resolvedStartDirectory.split(path$1.sep);
27
27
  while (parentPath.length > 2) {
28
- const fullPath = node_path.join(
29
- ...node_path.sep === "/" ? ["/"] : [],
28
+ const fullPath = path$1.join(
29
+ ...path$1.sep === "/" ? ["/"] : [],
30
30
  ...parentPath,
31
31
  target
32
32
  );
@@ -38,11 +38,11 @@ function findPath(target, startDirectory = process.cwd()) {
38
38
  return void 0;
39
39
  }
40
40
  async function asyncFindPath(target, startDirectory = process.cwd()) {
41
- const resolvedStartDirectory = startDirectory.startsWith("file:///") ? node_path.dirname(node_url.fileURLToPath(startDirectory)) : node_path.resolve(startDirectory);
42
- const parentPath = resolvedStartDirectory.split(node_path.sep);
41
+ const resolvedStartDirectory = startDirectory.startsWith("file:///") ? path$1.dirname(node_url.fileURLToPath(startDirectory)) : path$1.resolve(startDirectory);
42
+ const parentPath = resolvedStartDirectory.split(path$1.sep);
43
43
  while (parentPath.length > 2) {
44
- const fullPath = node_path.join(
45
- ...node_path.sep === "/" ? ["/"] : [],
44
+ const fullPath = path$1.join(
45
+ ...path$1.sep === "/" ? ["/"] : [],
46
46
  ...parentPath,
47
47
  target
48
48
  );
@@ -53,6 +53,9 @@ async function asyncFindPath(target, startDirectory = process.cwd()) {
53
53
  }
54
54
  return void 0;
55
55
  }
56
+ function gitIgnoreFileToGlobs(filePath) {
57
+ return node_fs.readFileSync(filePath, "utf8").split("\n").filter((line) => line.trim().length > 0 && !line.trim().startsWith("#")).map(gitIgnoreToGlob);
58
+ }
56
59
  const gitIgnoreToGlob = (pattern) => fixAbsoluteSyntax(fixMatchFilesSyntax(pattern));
57
60
  function fixAbsoluteSyntax(pattern) {
58
61
  if (pattern.startsWith("/")) {
@@ -73,7 +76,7 @@ function fixMatchFilesSyntax(pattern) {
73
76
  }
74
77
  return pattern.endsWith("/*") ? `${pattern}*` : pattern.endsWith("/") ? `${pattern}**` : `${pattern}/**`;
75
78
  }
76
- const isPosix = node_path.sep === posix.sep;
79
+ const isPosix = path$1.sep === posix.sep;
77
80
  const toPosixPathSeparators = (relativePath) => relativePath.includes(win32.sep) ? relativePath.replaceAll(win32.sep, posix.sep) : relativePath;
78
81
  const normalizePath = isPosix ? (path2) => path2 : toPosixPathSeparators;
79
82
  const toWin32PathSeparators = (relativePath) => relativePath.includes(posix.sep) ? relativePath.replaceAll(posix.sep, win32.sep) : relativePath;
@@ -107,7 +110,6 @@ const path = isPosix ? posix : {
107
110
  return toPosixPathSeparators(result);
108
111
  }
109
112
  };
110
- const exportsForTests = { toWin32PathSeparators };
111
113
  const cachedPackageJson = {};
112
114
  const cachedPackageJsonPromises = {};
113
115
  let rootPackageJsonLocation;
@@ -266,34 +268,34 @@ function externalizeDependencies(options) {
266
268
  ...packageJson.peerDependencies,
267
269
  ...packageJson.optionalDependencies
268
270
  });
269
- const bundleIn = options.bundleIn?.map(stringToStartsWithGlob) ?? [];
271
+ const bundleIn = options.bundleIn?.map(stringToStartsWithGlob);
270
272
  const externalize = [
271
273
  ...options.externalize?.map(stringToStartsWithGlob) ?? [],
272
- ...externalDependencies.length > 0 ? [new RegExp(`^(?:${externalDependencies.join("|")})(?:/.+)?$`, "u")] : []
274
+ /^node:/u,
275
+ new RegExp(
276
+ `^(?:${externalDependencies.join("|")}${externalDependencies.length === 0 ? "" : "|"}${node_module.builtinModules.join("|")})(?:/.+)?$`,
277
+ "u"
278
+ )
273
279
  ];
274
- const isExternalized = (id) => externalize.some((regex) => regex.test(id));
275
- const isBundledIn = (id) => bundleIn.some((regex) => regex.test(id));
276
280
  const plugin = {
277
281
  name: "@arcgis/components-build-utils:externalize-dependencies",
278
282
  apply: "build",
279
283
  enforce: "pre",
280
- resolveId(specifier, _, { isEntry }) {
281
- if (
282
- // Ignore entry points
283
- isEntry || // Ignore virtual modules
284
- specifier.startsWith("\0") || // Ignore relative
285
- specifier.startsWith(".") || path.isAbsolute(specifier)
286
- ) {
287
- return null;
288
- }
289
- if (node_module.isBuiltin(specifier)) {
290
- return {
291
- id: specifier.startsWith("node:") ? specifier : `node:${specifier}`,
292
- external: true,
293
- moduleSideEffects: false
294
- };
284
+ // Rolldown also has "external" option, which can be provided regexes.
285
+ // Theoretically that would be more efficient due to less communication
286
+ // overhead, but in practice they always evaluate it on the JS side:
287
+ // https://github.com/rolldown/rolldown/blob/4f996e637732a26ca04972975884abad5183292b/packages/rolldown/src/utils/bindingify-input-options.ts#L167
288
+ // https://github.com/rolldown/rolldown/blob/4f996e637732a26ca04972975884abad5183292b/crates/rolldown_binding/src/utils/normalize_binding_options.rs#L130
289
+ resolveId: {
290
+ filter: {
291
+ id: {
292
+ include: externalize,
293
+ exclude: bundleIn
294
+ }
295
+ },
296
+ handler() {
297
+ return false;
295
298
  }
296
- return isExternalized(specifier) && !isBundledIn(specifier) ? false : null;
297
299
  }
298
300
  };
299
301
  return plugin;
@@ -304,18 +306,17 @@ exports.asyncRetrievePackageJson = asyncRetrievePackageJson;
304
306
  exports.createFileIfNotExists = createFileIfNotExists;
305
307
  exports.detectPackageManager = detectPackageManager;
306
308
  exports.existsAsync = existsAsync;
307
- exports.exportsForTests = exportsForTests;
308
309
  exports.externalizeDependencies = externalizeDependencies;
309
310
  exports.fetchPackageLocation = fetchPackageLocation;
310
311
  exports.findPath = findPath;
311
312
  exports.getCwd = getCwd;
313
+ exports.gitIgnoreFileToGlobs = gitIgnoreFileToGlobs;
312
314
  exports.gitIgnoreToGlob = gitIgnoreToGlob;
313
315
  exports.isPosix = isPosix;
314
316
  exports.normalizePath = normalizePath;
315
317
  exports.path = path;
316
318
  exports.retrievePackageJson = retrievePackageJson;
317
319
  exports.sh = sh;
318
- exports.stringToStartsWithGlob = stringToStartsWithGlob;
319
320
  exports.toPosixPathSeparators = toPosixPathSeparators;
320
321
  exports.toSystemPathSeparators = toSystemPathSeparators;
321
322
  exports.vitePresetPlugin = vitePresetPlugin;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- export * from './file';
2
- export * from './glob';
3
- export * from './path';
4
- export * from './packageJson';
5
- export * from './vite';
1
+ export { existsAsync, sh, createFileIfNotExists, findPath, asyncFindPath } from './file';
2
+ export { gitIgnoreFileToGlobs, gitIgnoreToGlob } from './glob';
3
+ export { isPosix, toPosixPathSeparators, normalizePath, toSystemPathSeparators, getCwd, path } from './path';
4
+ export { type MiniPackageJson, retrievePackageJson, asyncRetrievePackageJson, fetchPackageLocation, detectPackageManager, } from './packageJson';
5
+ export { vitePresetPlugin, type DependencyManagementOptions, externalizeDependencies } from './vite';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export * from './file';
2
- export * from './glob';
3
- export * from './path';
4
- export * from './packageJson';
5
- export * from './vite';
1
+ export { existsAsync, sh, createFileIfNotExists, findPath, asyncFindPath } from './file';
2
+ export { gitIgnoreFileToGlobs, gitIgnoreToGlob } from './glob';
3
+ export { isPosix, toPosixPathSeparators, normalizePath, toSystemPathSeparators, getCwd, path } from './path';
4
+ export { type MiniPackageJson, retrievePackageJson, asyncRetrievePackageJson, fetchPackageLocation, detectPackageManager, } from './packageJson';
5
+ export { vitePresetPlugin, type DependencyManagementOptions, externalizeDependencies } from './vite';
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { access, existsSync, readFileSync } from "node:fs";
2
2
  import { constants, mkdir, writeFile, readFile } from "node:fs/promises";
3
3
  import { execSync } from "node:child_process";
4
- import { dirname, resolve, sep, join } from "node:path";
4
+ import { dirname, resolve, sep, join } from "path";
5
5
  import { fileURLToPath } from "node:url";
6
- import posix from "node:path/posix";
7
- import win32 from "node:path/win32";
6
+ import posix from "path/posix";
7
+ import win32 from "path/win32";
8
8
  import dts from "vite-plugin-dts";
9
- import { isBuiltin } from "node:module";
9
+ import { builtinModules } from "node:module";
10
10
  const existsAsync = async (file) => (
11
11
  // Using un-promisified version because promises version creates exceptions
12
12
  // which interferes with debugging when "Pause on caught exceptions" is enabled
@@ -51,6 +51,9 @@ async function asyncFindPath(target, startDirectory = process.cwd()) {
51
51
  }
52
52
  return void 0;
53
53
  }
54
+ function gitIgnoreFileToGlobs(filePath) {
55
+ return readFileSync(filePath, "utf8").split("\n").filter((line) => line.trim().length > 0 && !line.trim().startsWith("#")).map(gitIgnoreToGlob);
56
+ }
54
57
  const gitIgnoreToGlob = (pattern) => fixAbsoluteSyntax(fixMatchFilesSyntax(pattern));
55
58
  function fixAbsoluteSyntax(pattern) {
56
59
  if (pattern.startsWith("/")) {
@@ -105,7 +108,6 @@ const path = isPosix ? posix : {
105
108
  return toPosixPathSeparators(result);
106
109
  }
107
110
  };
108
- const exportsForTests = { toWin32PathSeparators };
109
111
  const cachedPackageJson = {};
110
112
  const cachedPackageJsonPromises = {};
111
113
  let rootPackageJsonLocation;
@@ -264,34 +266,34 @@ function externalizeDependencies(options) {
264
266
  ...packageJson.peerDependencies,
265
267
  ...packageJson.optionalDependencies
266
268
  });
267
- const bundleIn = options.bundleIn?.map(stringToStartsWithGlob) ?? [];
269
+ const bundleIn = options.bundleIn?.map(stringToStartsWithGlob);
268
270
  const externalize = [
269
271
  ...options.externalize?.map(stringToStartsWithGlob) ?? [],
270
- ...externalDependencies.length > 0 ? [new RegExp(`^(?:${externalDependencies.join("|")})(?:/.+)?$`, "u")] : []
272
+ /^node:/u,
273
+ new RegExp(
274
+ `^(?:${externalDependencies.join("|")}${externalDependencies.length === 0 ? "" : "|"}${builtinModules.join("|")})(?:/.+)?$`,
275
+ "u"
276
+ )
271
277
  ];
272
- const isExternalized = (id) => externalize.some((regex) => regex.test(id));
273
- const isBundledIn = (id) => bundleIn.some((regex) => regex.test(id));
274
278
  const plugin = {
275
279
  name: "@arcgis/components-build-utils:externalize-dependencies",
276
280
  apply: "build",
277
281
  enforce: "pre",
278
- resolveId(specifier, _, { isEntry }) {
279
- if (
280
- // Ignore entry points
281
- isEntry || // Ignore virtual modules
282
- specifier.startsWith("\0") || // Ignore relative
283
- specifier.startsWith(".") || path.isAbsolute(specifier)
284
- ) {
285
- return null;
286
- }
287
- if (isBuiltin(specifier)) {
288
- return {
289
- id: specifier.startsWith("node:") ? specifier : `node:${specifier}`,
290
- external: true,
291
- moduleSideEffects: false
292
- };
282
+ // Rolldown also has "external" option, which can be provided regexes.
283
+ // Theoretically that would be more efficient due to less communication
284
+ // overhead, but in practice they always evaluate it on the JS side:
285
+ // https://github.com/rolldown/rolldown/blob/4f996e637732a26ca04972975884abad5183292b/packages/rolldown/src/utils/bindingify-input-options.ts#L167
286
+ // https://github.com/rolldown/rolldown/blob/4f996e637732a26ca04972975884abad5183292b/crates/rolldown_binding/src/utils/normalize_binding_options.rs#L130
287
+ resolveId: {
288
+ filter: {
289
+ id: {
290
+ include: externalize,
291
+ exclude: bundleIn
292
+ }
293
+ },
294
+ handler() {
295
+ return false;
293
296
  }
294
- return isExternalized(specifier) && !isBundledIn(specifier) ? false : null;
295
297
  }
296
298
  };
297
299
  return plugin;
@@ -303,18 +305,17 @@ export {
303
305
  createFileIfNotExists,
304
306
  detectPackageManager,
305
307
  existsAsync,
306
- exportsForTests,
307
308
  externalizeDependencies,
308
309
  fetchPackageLocation,
309
310
  findPath,
310
311
  getCwd,
312
+ gitIgnoreFileToGlobs,
311
313
  gitIgnoreToGlob,
312
314
  isPosix,
313
315
  normalizePath,
314
316
  path,
315
317
  retrievePackageJson,
316
318
  sh,
317
- stringToStartsWithGlob,
318
319
  toPosixPathSeparators,
319
320
  toSystemPathSeparators,
320
321
  vitePresetPlugin
package/dist/path.d.cts CHANGED
@@ -13,7 +13,15 @@ export declare const normalizePath: (relativePath: string) => string;
13
13
  * inside the compiler we use `/` everywhere).
14
14
  */
15
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
+ */
16
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
+ */
17
25
  export declare const path: typeof posix & {
18
26
  sep: "/";
19
27
  };
package/dist/path.d.ts CHANGED
@@ -13,7 +13,15 @@ export declare const normalizePath: (relativePath: string) => string;
13
13
  * inside the compiler we use `/` everywhere).
14
14
  */
15
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
+ */
16
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
+ */
17
25
  export declare const path: typeof posix & {
18
26
  sep: "/";
19
27
  };
package/dist/vite.d.cts CHANGED
@@ -78,3 +78,6 @@ export declare function externalizeDependencies(options: DependencyManagementOpt
78
78
  * "monaco-editor/sub-path", but not "monaco-editor-beta".
79
79
  */
80
80
  export declare const stringToStartsWithGlob: (option: RegExp | string) => RegExp;
81
+ export declare const exportsForTests: {
82
+ stringToStartsWithGlob: (option: RegExp | string) => RegExp;
83
+ };
package/dist/vite.d.ts CHANGED
@@ -78,3 +78,6 @@ export declare function externalizeDependencies(options: DependencyManagementOpt
78
78
  * "monaco-editor/sub-path", but not "monaco-editor-beta".
79
79
  */
80
80
  export declare const stringToStartsWithGlob: (option: RegExp | string) => RegExp;
81
+ export declare const exportsForTests: {
82
+ stringToStartsWithGlob: (option: RegExp | string) => RegExp;
83
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/components-build-utils",
3
- "version": "4.34.0-next.126",
3
+ "version": "4.34.0-next.128",
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",