@arcgis/components-build-utils 5.1.0-next.11 → 5.1.0-next.111

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/file.d.cts CHANGED
@@ -1,7 +1,9 @@
1
- import { ExecSyncOptionsWithStringEncoding } from 'node:child_process';
1
+ import { ExecSyncOptionsWithStringEncoding, SpawnSyncOptionsWithStringEncoding } from 'node:child_process';
2
2
  export declare const existsAsync: (file: string) => Promise<boolean>;
3
3
  /** Wrapper for execSync to execute shell commands */
4
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;
5
7
  export declare function asyncSh(command: string, options?: Partial<ExecSyncOptionsWithStringEncoding>): Promise<string>;
6
8
  export declare function createFileIfNotExists(filePath: string, content: string): Promise<void>;
7
9
  /**
package/dist/file.d.ts CHANGED
@@ -1,7 +1,9 @@
1
- import { ExecSyncOptionsWithStringEncoding } from 'node:child_process';
1
+ import { ExecSyncOptionsWithStringEncoding, SpawnSyncOptionsWithStringEncoding } from 'node:child_process';
2
2
  export declare const existsAsync: (file: string) => Promise<boolean>;
3
3
  /** Wrapper for execSync to execute shell commands */
4
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;
5
7
  export declare function asyncSh(command: string, options?: Partial<ExecSyncOptionsWithStringEncoding>): Promise<string>;
6
8
  export declare function createFileIfNotExists(filePath: string, content: string): Promise<void>;
7
9
  /**
package/dist/index.cjs CHANGED
@@ -43,6 +43,15 @@ function sh(command, options = {}) {
43
43
  throw error;
44
44
  }
45
45
  }
46
+ function sp(command, args, options = {}) {
47
+ try {
48
+ const normalizedOptions = { encoding: "utf8", ...options };
49
+ const result = node_child_process.spawnSync(command, args, normalizedOptions);
50
+ return `${result.stdout ?? ""}${result.stderr ?? ""}`.trim();
51
+ } catch (error) {
52
+ throw error;
53
+ }
54
+ }
46
55
  async function asyncSh(command, options = {}) {
47
56
  const normalizedOptions = { encoding: "utf8", ...options };
48
57
  return await new Promise((resolve2, reject) => {
@@ -241,7 +250,8 @@ function detectPackageManager(cwd = process.cwd()) {
241
250
  function vitePresetPlugin({
242
251
  dtsOptions = {},
243
252
  externalize,
244
- bundleIn
253
+ bundleIn,
254
+ isApplication
245
255
  } = {
246
256
  externalize: [],
247
257
  dtsOptions: {}
@@ -272,12 +282,13 @@ function vitePresetPlugin({
272
282
  },
273
283
  externalizeDependencies({
274
284
  externalize,
275
- bundleIn
285
+ bundleIn,
286
+ isApplication
276
287
  }),
277
288
  // This dependency pulls in many others. Since components-build-utils has a
278
289
  // single entry point, we load a large module tree needlessly. To avoid,
279
290
  // load the plugin on demand.
280
- import("vite-plugin-dts").then(
291
+ dtsOptions === false ? void 0 : import("vite-plugin-dts").then(
281
292
  ({ default: dts }) => dts({
282
293
  logLevel: "warn",
283
294
  // Copies .d.ts files to d.cjs file for CommonJS.
@@ -331,24 +342,33 @@ function shouldSkip(id) {
331
342
  return id.includes("__test") || id.includes(".e2e.") || id.includes(".spec.") || id.includes(".test.") || id.includes(".stories.");
332
343
  }
333
344
  function externalizeDependencies(options) {
334
- const packageJson = retrievePackageJson();
345
+ return externalizeDependenciesImplementation(options, retrievePackageJson());
346
+ }
347
+ function externalizeDependenciesImplementation(options, packageJson) {
335
348
  const externalDependencies = Object.keys({
336
349
  ...packageJson.dependencies,
337
350
  ...packageJson.peerDependencies,
338
351
  ...packageJson.optionalDependencies
339
352
  });
353
+ const isStrictBundling = toPosixPathSeparators(void 0).includes(
354
+ "support-packages/components-build-utils"
355
+ );
340
356
  const bundleIn = options.bundleIn?.map(stringToStartsWithGlob);
357
+ const explicitExternalize = options.externalize?.map(stringToStartsWithGlob) ?? [];
341
358
  const externalize = [
342
- ...options.externalize?.map(stringToStartsWithGlob) ?? [],
359
+ ...explicitExternalize,
360
+ // BUG: we shouldn't silently externalize node in browser packages.
361
+ // Consider erroring instead
343
362
  /^node:/u,
344
363
  new RegExp(
345
- `^(?:${externalDependencies.join("|")}${externalDependencies.length === 0 ? "" : "|"}${node_module.builtinModules.join("|")})(?:/.+)?$`,
364
+ `^(?:${externalDependencies.join("|")}${externalDependencies.length === 0 ? "" : "|"}${node_module.builtinModules.join("|")})(?:/|$)`,
346
365
  "u"
347
366
  )
348
367
  ];
349
368
  const plugin = {
350
- name: "@arcgis/components-build-utils:externalize-dependencies",
369
+ name: pluginName,
351
370
  apply: "build",
371
+ // Externalize before Vite's default resolution runs
352
372
  enforce: "pre",
353
373
  // Rolldown also has "external" option, which can be provided regexes.
354
374
  // Theoretically that would be more efficient due to less communication
@@ -358,18 +378,62 @@ function externalizeDependencies(options) {
358
378
  resolveId: {
359
379
  filter: {
360
380
  id: {
361
- include: externalize,
381
+ include: [
382
+ // In most cases, we want all dependencies in library packages to be
383
+ // externalized. Thus, this regex matches all non-relative imports.
384
+ nonRelativeSpecifierPattern,
385
+ // Also include explicitExternalize because those may target relative
386
+ // paths (e.g. ./draconvert.js in mock-services).
387
+ ...explicitExternalize
388
+ ],
362
389
  exclude: bundleIn
363
390
  }
364
391
  },
365
- handler() {
366
- return false;
392
+ handler(id, importer, resolveOptions) {
393
+ if (matchesAny(id, externalize)) {
394
+ return false;
395
+ }
396
+ if (
397
+ // Entrypoints look like src/components/button/button.tsx, so are
398
+ // matched by the nonRelativeSpecifierPattern
399
+ resolveOptions.isEntry || // Virtual specifiers are handled by plugins
400
+ id.startsWith("\0") || // data: node: virtual:
401
+ id.includes(":") || // ?raw ?url ?worker - resolved by other plugins
402
+ id.includes("?") || // Applications can bundle in anything
403
+ options.isApplication === true
404
+ ) {
405
+ return;
406
+ }
407
+ const error = `[${pluginName}] Vite tried to bundle in "${id}" (imported by ${importer}).
408
+ This is likely undesirable. To externalize it, declare this dependency as a "dependency", "peerDependency" or "optionalDependency" in package.json.
409
+ If this is intentional, add it to the build.dependencies.bundleIn option in useLumina() or bundleIn option in the vitePresetPlugin().
410
+ If this is an application rather than a library, pass isApplication:true in vitePresetPlugin().`;
411
+ if (isStrictBundling) {
412
+ throw Error(error);
413
+ } else {
414
+ console.error(node_util.styleText("red", `${error}
415
+ This will be an error in future version.`));
416
+ return;
417
+ }
367
418
  }
368
419
  }
369
420
  };
370
421
  return plugin;
371
422
  }
372
- const stringToStartsWithGlob = (option) => typeof option === "string" ? new RegExp(`^${option.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&")}(?:/.+)?$`, "u") : option;
423
+ const pluginName = "@arcgis/components-build-utils:externalize-dependencies";
424
+ const stringToStartsWithGlob = (option) => typeof option === "string" ? new RegExp(
425
+ `^${option.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&")}${option.endsWith("/") ? "(?:.+)?" : "(?:/.+)?"}$`,
426
+ "u"
427
+ ) : option;
428
+ const nonRelativeSpecifierPattern = /^[^\.\/]/u;
429
+ function matchesAny(id, patterns) {
430
+ for (let index = 0; index < patterns.length; ++index) {
431
+ if (patterns[index].test(id)) {
432
+ return true;
433
+ }
434
+ }
435
+ return false;
436
+ }
373
437
  exports.asyncFindPath = asyncFindPath;
374
438
  exports.asyncRetrievePackageJson = asyncRetrievePackageJson;
375
439
  exports.asyncSh = asyncSh;
@@ -387,6 +451,7 @@ exports.normalizePath = normalizePath;
387
451
  exports.path = path;
388
452
  exports.retrievePackageJson = retrievePackageJson;
389
453
  exports.sh = sh;
454
+ exports.sp = sp;
390
455
  exports.toPosixPathSeparators = toPosixPathSeparators;
391
456
  exports.toSystemPathSeparators = toSystemPathSeparators;
392
457
  exports.vitePresetPlugin = vitePresetPlugin;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { existsAsync, sh, asyncSh, createFileIfNotExists, findPath, asyncFindPath } from './file.ts';
1
+ export { existsAsync, sh, sp, asyncSh, createFileIfNotExists, findPath, asyncFindPath } from './file.ts';
2
2
  export { gitIgnoreFileToGlobs, gitIgnoreToGlob } from './glob.ts';
3
3
  export { isPosix, toPosixPathSeparators, normalizePath, toSystemPathSeparators, getCwd, path } from './path.ts';
4
4
  export { type PackageJson, retrievePackageJson, asyncRetrievePackageJson, fetchPackageLocation, detectPackageManager, } from './packageJson.ts';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { existsAsync, sh, asyncSh, createFileIfNotExists, findPath, asyncFindPath } from './file.ts';
1
+ export { existsAsync, sh, sp, asyncSh, createFileIfNotExists, findPath, asyncFindPath } from './file.ts';
2
2
  export { gitIgnoreFileToGlobs, gitIgnoreToGlob } from './glob.ts';
3
3
  export { isPosix, toPosixPathSeparators, normalizePath, toSystemPathSeparators, getCwd, path } from './path.ts';
4
4
  export { type PackageJson, retrievePackageJson, asyncRetrievePackageJson, fetchPackageLocation, detectPackageManager, } from './packageJson.ts';
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { access, existsSync, readFileSync } from "node:fs";
2
2
  import { constants, mkdir, writeFile, readFile } from "node:fs/promises";
3
3
  import { dirname, resolve, sep, join, posix, win32 } from "path";
4
4
  import { fileURLToPath } from "node:url";
5
- import { execSync, exec } from "node:child_process";
5
+ import { execSync, spawnSync, exec } from "node:child_process";
6
6
  import { styleText } from "node:util";
7
7
  import { builtinModules } from "node:module";
8
8
  const existsAsync = async (file) => (
@@ -19,6 +19,15 @@ function sh(command, options = {}) {
19
19
  throw error;
20
20
  }
21
21
  }
22
+ function sp(command, args, options = {}) {
23
+ try {
24
+ const normalizedOptions = { encoding: "utf8", ...options };
25
+ const result = spawnSync(command, args, normalizedOptions);
26
+ return `${result.stdout ?? ""}${result.stderr ?? ""}`.trim();
27
+ } catch (error) {
28
+ throw error;
29
+ }
30
+ }
22
31
  async function asyncSh(command, options = {}) {
23
32
  const normalizedOptions = { encoding: "utf8", ...options };
24
33
  return await new Promise((resolve2, reject) => {
@@ -217,7 +226,8 @@ function detectPackageManager(cwd = process.cwd()) {
217
226
  function vitePresetPlugin({
218
227
  dtsOptions = {},
219
228
  externalize,
220
- bundleIn
229
+ bundleIn,
230
+ isApplication
221
231
  } = {
222
232
  externalize: [],
223
233
  dtsOptions: {}
@@ -248,12 +258,13 @@ function vitePresetPlugin({
248
258
  },
249
259
  externalizeDependencies({
250
260
  externalize,
251
- bundleIn
261
+ bundleIn,
262
+ isApplication
252
263
  }),
253
264
  // This dependency pulls in many others. Since components-build-utils has a
254
265
  // single entry point, we load a large module tree needlessly. To avoid,
255
266
  // load the plugin on demand.
256
- import("vite-plugin-dts").then(
267
+ dtsOptions === false ? void 0 : import("vite-plugin-dts").then(
257
268
  ({ default: dts }) => dts({
258
269
  logLevel: "warn",
259
270
  // Copies .d.ts files to d.cjs file for CommonJS.
@@ -307,24 +318,33 @@ function shouldSkip(id) {
307
318
  return id.includes("__test") || id.includes(".e2e.") || id.includes(".spec.") || id.includes(".test.") || id.includes(".stories.");
308
319
  }
309
320
  function externalizeDependencies(options) {
310
- const packageJson = retrievePackageJson();
321
+ return externalizeDependenciesImplementation(options, retrievePackageJson());
322
+ }
323
+ function externalizeDependenciesImplementation(options, packageJson) {
311
324
  const externalDependencies = Object.keys({
312
325
  ...packageJson.dependencies,
313
326
  ...packageJson.peerDependencies,
314
327
  ...packageJson.optionalDependencies
315
328
  });
329
+ const isStrictBundling = toPosixPathSeparators(import.meta.dirname).includes(
330
+ "support-packages/components-build-utils"
331
+ );
316
332
  const bundleIn = options.bundleIn?.map(stringToStartsWithGlob);
333
+ const explicitExternalize = options.externalize?.map(stringToStartsWithGlob) ?? [];
317
334
  const externalize = [
318
- ...options.externalize?.map(stringToStartsWithGlob) ?? [],
335
+ ...explicitExternalize,
336
+ // BUG: we shouldn't silently externalize node in browser packages.
337
+ // Consider erroring instead
319
338
  /^node:/u,
320
339
  new RegExp(
321
- `^(?:${externalDependencies.join("|")}${externalDependencies.length === 0 ? "" : "|"}${builtinModules.join("|")})(?:/.+)?$`,
340
+ `^(?:${externalDependencies.join("|")}${externalDependencies.length === 0 ? "" : "|"}${builtinModules.join("|")})(?:/|$)`,
322
341
  "u"
323
342
  )
324
343
  ];
325
344
  const plugin = {
326
- name: "@arcgis/components-build-utils:externalize-dependencies",
345
+ name: pluginName,
327
346
  apply: "build",
347
+ // Externalize before Vite's default resolution runs
328
348
  enforce: "pre",
329
349
  // Rolldown also has "external" option, which can be provided regexes.
330
350
  // Theoretically that would be more efficient due to less communication
@@ -334,18 +354,62 @@ function externalizeDependencies(options) {
334
354
  resolveId: {
335
355
  filter: {
336
356
  id: {
337
- include: externalize,
357
+ include: [
358
+ // In most cases, we want all dependencies in library packages to be
359
+ // externalized. Thus, this regex matches all non-relative imports.
360
+ nonRelativeSpecifierPattern,
361
+ // Also include explicitExternalize because those may target relative
362
+ // paths (e.g. ./draconvert.js in mock-services).
363
+ ...explicitExternalize
364
+ ],
338
365
  exclude: bundleIn
339
366
  }
340
367
  },
341
- handler() {
342
- return false;
368
+ handler(id, importer, resolveOptions) {
369
+ if (matchesAny(id, externalize)) {
370
+ return false;
371
+ }
372
+ if (
373
+ // Entrypoints look like src/components/button/button.tsx, so are
374
+ // matched by the nonRelativeSpecifierPattern
375
+ resolveOptions.isEntry || // Virtual specifiers are handled by plugins
376
+ id.startsWith("\0") || // data: node: virtual:
377
+ id.includes(":") || // ?raw ?url ?worker - resolved by other plugins
378
+ id.includes("?") || // Applications can bundle in anything
379
+ options.isApplication === true
380
+ ) {
381
+ return;
382
+ }
383
+ const error = `[${pluginName}] Vite tried to bundle in "${id}" (imported by ${importer}).
384
+ This is likely undesirable. To externalize it, declare this dependency as a "dependency", "peerDependency" or "optionalDependency" in package.json.
385
+ If this is intentional, add it to the build.dependencies.bundleIn option in useLumina() or bundleIn option in the vitePresetPlugin().
386
+ If this is an application rather than a library, pass isApplication:true in vitePresetPlugin().`;
387
+ if (isStrictBundling) {
388
+ throw Error(error);
389
+ } else {
390
+ console.error(styleText("red", `${error}
391
+ This will be an error in future version.`));
392
+ return;
393
+ }
343
394
  }
344
395
  }
345
396
  };
346
397
  return plugin;
347
398
  }
348
- const stringToStartsWithGlob = (option) => typeof option === "string" ? new RegExp(`^${option.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&")}(?:/.+)?$`, "u") : option;
399
+ const pluginName = "@arcgis/components-build-utils:externalize-dependencies";
400
+ const stringToStartsWithGlob = (option) => typeof option === "string" ? new RegExp(
401
+ `^${option.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&")}${option.endsWith("/") ? "(?:.+)?" : "(?:/.+)?"}$`,
402
+ "u"
403
+ ) : option;
404
+ const nonRelativeSpecifierPattern = /^[^\.\/]/u;
405
+ function matchesAny(id, patterns) {
406
+ for (let index = 0; index < patterns.length; ++index) {
407
+ if (patterns[index].test(id)) {
408
+ return true;
409
+ }
410
+ }
411
+ return false;
412
+ }
349
413
  export {
350
414
  asyncFindPath,
351
415
  asyncRetrievePackageJson,
@@ -364,6 +428,7 @@ export {
364
428
  path,
365
429
  retrievePackageJson,
366
430
  sh,
431
+ sp,
367
432
  toPosixPathSeparators,
368
433
  toSystemPathSeparators,
369
434
  vitePresetPlugin
@@ -12,12 +12,9 @@ export type PackageJson = {
12
12
  "main"?: string;
13
13
  "module"?: string;
14
14
  "types"?: string;
15
- "publishConfig"?: {
16
- access?: string;
17
- registry?: string;
18
- provenance?: boolean;
19
- };
20
15
  "files"?: string[];
16
+ "bin"?: Record<string, string> | string;
17
+ "man"?: string[] | string;
21
18
  "dependencies"?: Record<string, string>;
22
19
  "devDependencies"?: Record<string, string>;
23
20
  "peerDependencies"?: Record<string, string>;
@@ -32,10 +29,6 @@ export type PackageJson = {
32
29
  "exports"?: Record<string, Record<string, string> | string>;
33
30
  "scripts"?: Record<string, string>;
34
31
  "packageManager"?: string;
35
- "webGISComponents"?: {
36
- deployBuilds?: Record<string, string>;
37
- artifactsDeployPath?: string;
38
- };
39
32
  };
40
33
  export declare function retrievePackageJson(location?: string, cache?: boolean): PackageJson;
41
34
  export declare function asyncRetrievePackageJson(location?: string): Promise<PackageJson>;
@@ -12,12 +12,9 @@ export type PackageJson = {
12
12
  "main"?: string;
13
13
  "module"?: string;
14
14
  "types"?: string;
15
- "publishConfig"?: {
16
- access?: string;
17
- registry?: string;
18
- provenance?: boolean;
19
- };
20
15
  "files"?: string[];
16
+ "bin"?: Record<string, string> | string;
17
+ "man"?: string[] | string;
21
18
  "dependencies"?: Record<string, string>;
22
19
  "devDependencies"?: Record<string, string>;
23
20
  "peerDependencies"?: Record<string, string>;
@@ -32,10 +29,6 @@ export type PackageJson = {
32
29
  "exports"?: Record<string, Record<string, string> | string>;
33
30
  "scripts"?: Record<string, string>;
34
31
  "packageManager"?: string;
35
- "webGISComponents"?: {
36
- deployBuilds?: Record<string, string>;
37
- artifactsDeployPath?: string;
38
- };
39
32
  };
40
33
  export declare function retrievePackageJson(location?: string, cache?: boolean): PackageJson;
41
34
  export declare function asyncRetrievePackageJson(location?: string): Promise<PackageJson>;
package/dist/vite.d.cts CHANGED
@@ -1,14 +1,15 @@
1
1
  import { Plugin } from 'vite';
2
2
  import { default as dts } from 'vite-plugin-dts';
3
+ import { PackageJson } from './packageJson.ts';
3
4
  /**
4
5
  * Vite preset for all our support packages:
5
6
  * - externalizes all non-dev-dependencies
6
7
  * - generates type declarations (using `vite-plugin-dts`)
7
8
  */
8
- export declare function vitePresetPlugin({ dtsOptions, externalize, bundleIn, }?: DependencyManagementOptions & {
9
+ export declare function vitePresetPlugin({ dtsOptions, externalize, bundleIn, isApplication, }?: DependencyManagementOptions & {
9
10
  /** Additional options for `vite-plugin-dts` */
10
- dtsOptions?: Parameters<typeof dts>[0];
11
- }): [Plugin, Plugin, Promise<Plugin>];
11
+ dtsOptions?: Parameters<typeof dts>[0] | false;
12
+ }): [Plugin, Plugin, Promise<Plugin> | undefined];
12
13
  /**
13
14
  * Options for externalizing dependencies.
14
15
  */
@@ -40,6 +41,14 @@ export type DependencyManagementOptions = {
40
41
  * technical reasons.
41
42
  */
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;
43
52
  };
44
53
  /**
45
54
  * By default, Rollup will bundle-in all dependencies.
@@ -69,15 +78,24 @@ export type DependencyManagementOptions = {
69
78
  * be externalized (because all peerDependencies are externalized).
70
79
  */
71
80
  export declare function externalizeDependencies(options: DependencyManagementOptions): Plugin;
72
- /**
73
- * Convert a string value to a RegExp that matches any import specifier that
74
- * starts with the given string.
75
- *
76
- * @example
77
- * "monaco-editor" will create a regex that matches "monaco-editor" and
78
- * "monaco-editor/sub-path", but not "monaco-editor-beta".
79
- */
80
- export declare const stringToStartsWithGlob: (option: RegExp | string) => RegExp;
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;
81
96
  export declare const exportsForTests: {
82
97
  stringToStartsWithGlob: (option: RegExp | string) => RegExp;
98
+ externalizeDependenciesImplementation: typeof externalizeDependenciesImplementation;
99
+ matchesAny: typeof matchesAny;
83
100
  };
101
+ export {};
package/dist/vite.d.ts CHANGED
@@ -1,14 +1,15 @@
1
1
  import { Plugin } from 'vite';
2
2
  import { default as dts } from 'vite-plugin-dts';
3
+ import { PackageJson } from './packageJson.ts';
3
4
  /**
4
5
  * Vite preset for all our support packages:
5
6
  * - externalizes all non-dev-dependencies
6
7
  * - generates type declarations (using `vite-plugin-dts`)
7
8
  */
8
- export declare function vitePresetPlugin({ dtsOptions, externalize, bundleIn, }?: DependencyManagementOptions & {
9
+ export declare function vitePresetPlugin({ dtsOptions, externalize, bundleIn, isApplication, }?: DependencyManagementOptions & {
9
10
  /** Additional options for `vite-plugin-dts` */
10
- dtsOptions?: Parameters<typeof dts>[0];
11
- }): [Plugin, Plugin, Promise<Plugin>];
11
+ dtsOptions?: Parameters<typeof dts>[0] | false;
12
+ }): [Plugin, Plugin, Promise<Plugin> | undefined];
12
13
  /**
13
14
  * Options for externalizing dependencies.
14
15
  */
@@ -40,6 +41,14 @@ export type DependencyManagementOptions = {
40
41
  * technical reasons.
41
42
  */
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;
43
52
  };
44
53
  /**
45
54
  * By default, Rollup will bundle-in all dependencies.
@@ -69,15 +78,24 @@ export type DependencyManagementOptions = {
69
78
  * be externalized (because all peerDependencies are externalized).
70
79
  */
71
80
  export declare function externalizeDependencies(options: DependencyManagementOptions): Plugin;
72
- /**
73
- * Convert a string value to a RegExp that matches any import specifier that
74
- * starts with the given string.
75
- *
76
- * @example
77
- * "monaco-editor" will create a regex that matches "monaco-editor" and
78
- * "monaco-editor/sub-path", but not "monaco-editor-beta".
79
- */
80
- export declare const stringToStartsWithGlob: (option: RegExp | string) => RegExp;
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;
81
96
  export declare const exportsForTests: {
82
97
  stringToStartsWithGlob: (option: RegExp | string) => RegExp;
98
+ externalizeDependenciesImplementation: typeof externalizeDependenciesImplementation;
99
+ matchesAny: typeof matchesAny;
83
100
  };
101
+ export {};
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@arcgis/components-build-utils",
3
- "version": "5.1.0-next.11",
3
+ "version": "5.1.0-next.111",
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.cjs",
8
- "module": "dist/index.js",
9
- "types": "dist/index.d.ts",
7
+ "main": "./dist/index.cjs",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
10
  "exports": {
11
11
  ".": {
12
12
  "types": "./dist/index.d.ts",
@@ -20,8 +20,9 @@
20
20
  ],
21
21
  "license": "SEE LICENSE IN LICENSE.md",
22
22
  "dependencies": {
23
+ "@types/node": "^24.10.0",
23
24
  "tslib": "^2.8.1",
24
- "vite": "^7.2.2",
25
+ "vite": "^7.3.2",
25
26
  "vite-plugin-dts": "^4.5.4"
26
27
  }
27
28
  }