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

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/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
  );
@@ -73,7 +73,7 @@ function fixMatchFilesSyntax(pattern) {
73
73
  }
74
74
  return pattern.endsWith("/*") ? `${pattern}*` : pattern.endsWith("/") ? `${pattern}**` : `${pattern}/**`;
75
75
  }
76
- const isPosix = node_path.sep === posix.sep;
76
+ const isPosix = path$1.sep === posix.sep;
77
77
  const toPosixPathSeparators = (relativePath) => relativePath.includes(win32.sep) ? relativePath.replaceAll(win32.sep, posix.sep) : relativePath;
78
78
  const normalizePath = isPosix ? (path2) => path2 : toPosixPathSeparators;
79
79
  const toWin32PathSeparators = (relativePath) => relativePath.includes(posix.sep) ? relativePath.replaceAll(posix.sep, win32.sep) : relativePath;
@@ -266,34 +266,34 @@ function externalizeDependencies(options) {
266
266
  ...packageJson.peerDependencies,
267
267
  ...packageJson.optionalDependencies
268
268
  });
269
- const bundleIn = options.bundleIn?.map(stringToStartsWithGlob) ?? [];
269
+ const bundleIn = options.bundleIn?.map(stringToStartsWithGlob);
270
270
  const externalize = [
271
271
  ...options.externalize?.map(stringToStartsWithGlob) ?? [],
272
- ...externalDependencies.length > 0 ? [new RegExp(`^(?:${externalDependencies.join("|")})(?:/.+)?$`, "u")] : []
272
+ /^node:/u,
273
+ new RegExp(
274
+ `^(?:${externalDependencies.join("|")}${externalDependencies.length === 0 ? "" : "|"}${node_module.builtinModules.join("|")})(?:/.+)?$`,
275
+ "u"
276
+ )
273
277
  ];
274
- const isExternalized = (id) => externalize.some((regex) => regex.test(id));
275
- const isBundledIn = (id) => bundleIn.some((regex) => regex.test(id));
276
278
  const plugin = {
277
279
  name: "@arcgis/components-build-utils:externalize-dependencies",
278
280
  apply: "build",
279
281
  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
- };
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;
295
296
  }
296
- return isExternalized(specifier) && !isBundledIn(specifier) ? false : null;
297
297
  }
298
298
  };
299
299
  return plugin;
@@ -315,7 +315,6 @@ exports.normalizePath = normalizePath;
315
315
  exports.path = path;
316
316
  exports.retrievePackageJson = retrievePackageJson;
317
317
  exports.sh = sh;
318
- exports.stringToStartsWithGlob = stringToStartsWithGlob;
319
318
  exports.toPosixPathSeparators = toPosixPathSeparators;
320
319
  exports.toSystemPathSeparators = toSystemPathSeparators;
321
320
  exports.vitePresetPlugin = vitePresetPlugin;
package/dist/index.d.cts CHANGED
@@ -2,4 +2,4 @@ export * from './file';
2
2
  export * from './glob';
3
3
  export * from './path';
4
4
  export * from './packageJson';
5
- export * from './vite';
5
+ export { vitePresetPlugin, type DependencyManagementOptions, externalizeDependencies } from './vite';
package/dist/index.d.ts CHANGED
@@ -2,4 +2,4 @@ export * from './file';
2
2
  export * from './glob';
3
3
  export * from './path';
4
4
  export * from './packageJson';
5
- export * from './vite';
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
@@ -264,34 +264,34 @@ function externalizeDependencies(options) {
264
264
  ...packageJson.peerDependencies,
265
265
  ...packageJson.optionalDependencies
266
266
  });
267
- const bundleIn = options.bundleIn?.map(stringToStartsWithGlob) ?? [];
267
+ const bundleIn = options.bundleIn?.map(stringToStartsWithGlob);
268
268
  const externalize = [
269
269
  ...options.externalize?.map(stringToStartsWithGlob) ?? [],
270
- ...externalDependencies.length > 0 ? [new RegExp(`^(?:${externalDependencies.join("|")})(?:/.+)?$`, "u")] : []
270
+ /^node:/u,
271
+ new RegExp(
272
+ `^(?:${externalDependencies.join("|")}${externalDependencies.length === 0 ? "" : "|"}${builtinModules.join("|")})(?:/.+)?$`,
273
+ "u"
274
+ )
271
275
  ];
272
- const isExternalized = (id) => externalize.some((regex) => regex.test(id));
273
- const isBundledIn = (id) => bundleIn.some((regex) => regex.test(id));
274
276
  const plugin = {
275
277
  name: "@arcgis/components-build-utils:externalize-dependencies",
276
278
  apply: "build",
277
279
  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
- };
280
+ // Rolldown also has "external" option, which can be provided regexes.
281
+ // Theoretically that would be more efficient due to less communication
282
+ // overhead, but in practice they always evaluate it on the JS side:
283
+ // https://github.com/rolldown/rolldown/blob/4f996e637732a26ca04972975884abad5183292b/packages/rolldown/src/utils/bindingify-input-options.ts#L167
284
+ // https://github.com/rolldown/rolldown/blob/4f996e637732a26ca04972975884abad5183292b/crates/rolldown_binding/src/utils/normalize_binding_options.rs#L130
285
+ resolveId: {
286
+ filter: {
287
+ id: {
288
+ include: externalize,
289
+ exclude: bundleIn
290
+ }
291
+ },
292
+ handler() {
293
+ return false;
293
294
  }
294
- return isExternalized(specifier) && !isBundledIn(specifier) ? false : null;
295
295
  }
296
296
  };
297
297
  return plugin;
@@ -314,7 +314,6 @@ export {
314
314
  path,
315
315
  retrievePackageJson,
316
316
  sh,
317
- stringToStartsWithGlob,
318
317
  toPosixPathSeparators,
319
318
  toSystemPathSeparators,
320
319
  vitePresetPlugin
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.127",
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",