@arcgis/components-build-utils 4.34.0-next.15 → 4.34.0-next.150

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.
Files changed (42) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +2 -10
  3. package/dist/commands/affected-packages.d.cts +2 -0
  4. package/dist/commands/affected-packages.d.ts +2 -0
  5. package/dist/commands/assign-zehub-release.d.cts +2 -0
  6. package/dist/commands/assign-zehub-release.d.ts +2 -0
  7. package/dist/commands/compare-rss.d.cts +10 -0
  8. package/dist/commands/compare-rss.d.ts +10 -0
  9. package/dist/commands/deprecate.d.cts +2 -0
  10. package/dist/commands/deprecate.d.ts +2 -0
  11. package/dist/commands/ensure-working-tree-clean.d.cts +1 -0
  12. package/dist/commands/ensure-working-tree-clean.d.ts +1 -0
  13. package/dist/commands/generate-builddate.d.cts +1 -1
  14. package/dist/commands/generate-builddate.d.ts +1 -1
  15. package/dist/commands/git-copy/getFileNames.d.cts +1 -1
  16. package/dist/commands/git-copy/getFileNames.d.ts +1 -1
  17. package/dist/commands/git-copy/index.d.cts +2 -1
  18. package/dist/commands/git-copy/index.d.ts +2 -1
  19. package/dist/commands/git-copy/utils.d.cts +0 -1
  20. package/dist/commands/git-copy/utils.d.ts +0 -1
  21. package/dist/commands/migrate-repo-issues/zentopia.d.cts +10 -1
  22. package/dist/commands/migrate-repo-issues/zentopia.d.ts +10 -1
  23. package/dist/commands/npm-utils.d.cts +29 -0
  24. package/dist/commands/npm-utils.d.ts +29 -0
  25. package/dist/commands/update-version.d.cts +2 -0
  26. package/dist/commands/update-version.d.ts +2 -0
  27. package/dist/commands/utils.d.cts +65 -1
  28. package/dist/commands/utils.d.ts +65 -1
  29. package/dist/glob.d.cts +23 -0
  30. package/dist/glob.d.ts +23 -0
  31. package/dist/index.cjs +67 -57
  32. package/dist/index.d.cts +5 -5
  33. package/dist/index.d.ts +5 -5
  34. package/dist/index.js +57 -25
  35. package/dist/packageJson.d.cts +3 -0
  36. package/dist/packageJson.d.ts +3 -0
  37. package/dist/path.d.cts +8 -0
  38. package/dist/path.d.ts +8 -0
  39. package/dist/vite.d.cts +71 -12
  40. package/dist/vite.d.ts +71 -12
  41. package/package.json +12 -8
  42. package/src/commands/run-wrapper.js +5 -15
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Licensing
2
2
 
3
- COPYRIGHT © 2025 Esri
3
+ COPYRIGHT © Esri
4
4
 
5
5
  All rights reserved under the copyright laws of the United States and applicable international laws, treaties, and conventions.
6
6
 
package/README.md CHANGED
@@ -8,14 +8,6 @@ It is not intended to be used directly, but rather used as a dependency by other
8
8
 
9
9
  ## License
10
10
 
11
- COPYRIGHT © 2025 Esri
11
+ COPYRIGHT © Esri
12
12
 
13
- All rights reserved under the copyright laws of the United States and applicable international laws, treaties, and conventions.
14
-
15
- This material is licensed for use under the Esri Master License Agreement (MLA), and is bound by the terms of that agreement. You may redistribute and use this code without modification, provided you adhere to the terms of the MLA and include this copyright notice.
16
-
17
- See use restrictions at <http://www.esri.com/legal/pdfs/mla_e204_e300/english>
18
-
19
- For additional information, contact: Environmental Systems Research Institute, Inc. Attn: Contracts and Legal Services Department 380 New York Street Redlands, California, USA 92373 USA
20
-
21
- email: contracts@esri.com
13
+ This package is licensed under the terms described in the `LICENSE.md` file, located in the root of the package.
@@ -0,0 +1,2 @@
1
+ import { Command } from '@commander-js/extra-typings';
2
+ export declare const registerCommand: (program: Command) => undefined;
@@ -0,0 +1,2 @@
1
+ import { Command } from '@commander-js/extra-typings';
2
+ export declare const registerCommand: (program: Command) => undefined;
@@ -0,0 +1,2 @@
1
+ import { Command } from '@commander-js/extra-typings';
2
+ export declare const registerCommand: (command: Command) => undefined;
@@ -0,0 +1,2 @@
1
+ import { Command } from '@commander-js/extra-typings';
2
+ export declare const registerCommand: (command: Command) => undefined;
@@ -0,0 +1,10 @@
1
+ import { Command } from 'commander';
2
+ /**
3
+ * !important
4
+ * The class makes a TLS request to qawebgis
5
+ * You need to make sure node trusts the certificate authority that signed the certificate used by qawebgis.esri.com
6
+ *
7
+ * Include your certificate authority in the NODE_EXTRA_CA_CERTS environment variable
8
+ * Reference: https://qawebgis.esri.com/components/devops/troubleshoot/troubleshoot#certificate-verification-failure
9
+ */
10
+ export declare const registerCommand: (command: Command) => undefined;
@@ -0,0 +1,10 @@
1
+ import { Command } from 'commander';
2
+ /**
3
+ * !important
4
+ * The class makes a TLS request to qawebgis
5
+ * You need to make sure node trusts the certificate authority that signed the certificate used by qawebgis.esri.com
6
+ *
7
+ * Include your certificate authority in the NODE_EXTRA_CA_CERTS environment variable
8
+ * Reference: https://qawebgis.esri.com/components/devops/troubleshoot/troubleshoot#certificate-verification-failure
9
+ */
10
+ export declare const registerCommand: (command: Command) => undefined;
@@ -0,0 +1,2 @@
1
+ import { Command } from '@commander-js/extra-typings';
2
+ export declare const registerCommand: (program: Command) => Command;
@@ -0,0 +1,2 @@
1
+ import { Command } from '@commander-js/extra-typings';
2
+ export declare const registerCommand: (program: Command) => Command;
@@ -3,3 +3,4 @@ export declare const registerCommand: (command: Command) => undefined;
3
3
  export declare function ensureWorkingTreeClean({ cwd }?: {
4
4
  cwd?: string;
5
5
  }): void;
6
+ export declare const readWorkingTree: (cwd?: string) => string | undefined;
@@ -3,3 +3,4 @@ export declare const registerCommand: (command: Command) => undefined;
3
3
  export declare function ensureWorkingTreeClean({ cwd }?: {
4
4
  cwd?: string;
5
5
  }): void;
6
+ export declare const readWorkingTree: (cwd?: string) => string | undefined;
@@ -9,4 +9,4 @@ export type Builddate = {
9
9
  "@esri/calcite-components": string;
10
10
  "@esri/arcgis-html-sanitizer": string;
11
11
  };
12
- export declare function generateBuilddate(): Builddate;
12
+ export declare function generateBuilddate(): Promise<Builddate>;
@@ -9,4 +9,4 @@ export type Builddate = {
9
9
  "@esri/calcite-components": string;
10
10
  "@esri/arcgis-html-sanitizer": string;
11
11
  };
12
- export declare function generateBuilddate(): Builddate;
12
+ export declare function generateBuilddate(): Promise<Builddate>;
@@ -1,4 +1,4 @@
1
- export declare function getFileNames(sourceRelative: string, sourceRoot: string, endsWithIgnore: string[], ignore?: string[]): {
1
+ export declare function getFileNames(sourceRelative: string, sourceRoot: string, endsWithIgnore: string[], containsIgnore: string[], ignore?: string[]): {
2
2
  filteredFiles: string[];
3
3
  rootFiles: Set<string>;
4
4
  };
@@ -1,4 +1,4 @@
1
- export declare function getFileNames(sourceRelative: string, sourceRoot: string, endsWithIgnore: string[], ignore?: string[]): {
1
+ export declare function getFileNames(sourceRelative: string, sourceRoot: string, endsWithIgnore: string[], containsIgnore: string[], ignore?: string[]): {
2
2
  filteredFiles: string[];
3
3
  rootFiles: Set<string>;
4
4
  };
@@ -1,4 +1,4 @@
1
- export declare function copyFolderWithHistory(rawSource: string, rawDestination: string, { yes, emitPatchFiles, dryRun, dirtyCheck, addBackLinks, ignoreAlreadyExists, remote, ignore, endsWithIgnore, rename: rawRenames, dumpSizes, dumpFileSizes, updateMergeCommitTitlesFrom, }: {
1
+ export declare function copyFolderWithHistory(rawSource: string, rawDestination: string, { yes, emitPatchFiles, dryRun, dirtyCheck, addBackLinks, ignoreAlreadyExists, remote, ignore, endsWithIgnore, containsIgnore, rename: rawRenames, dumpSizes, dumpFileSizes, updateMergeCommitTitlesFrom, }: {
2
2
  readonly yes: boolean;
3
3
  readonly emitPatchFiles: boolean;
4
4
  readonly dryRun: boolean;
@@ -8,6 +8,7 @@ export declare function copyFolderWithHistory(rawSource: string, rawDestination:
8
8
  readonly remote: string;
9
9
  readonly ignore?: string[];
10
10
  readonly endsWithIgnore?: string[];
11
+ readonly containsIgnore?: string[];
11
12
  readonly rename?: string[];
12
13
  readonly dumpSizes: boolean;
13
14
  readonly dumpFileSizes: boolean;
@@ -1,4 +1,4 @@
1
- export declare function copyFolderWithHistory(rawSource: string, rawDestination: string, { yes, emitPatchFiles, dryRun, dirtyCheck, addBackLinks, ignoreAlreadyExists, remote, ignore, endsWithIgnore, rename: rawRenames, dumpSizes, dumpFileSizes, updateMergeCommitTitlesFrom, }: {
1
+ export declare function copyFolderWithHistory(rawSource: string, rawDestination: string, { yes, emitPatchFiles, dryRun, dirtyCheck, addBackLinks, ignoreAlreadyExists, remote, ignore, endsWithIgnore, containsIgnore, rename: rawRenames, dumpSizes, dumpFileSizes, updateMergeCommitTitlesFrom, }: {
2
2
  readonly yes: boolean;
3
3
  readonly emitPatchFiles: boolean;
4
4
  readonly dryRun: boolean;
@@ -8,6 +8,7 @@ export declare function copyFolderWithHistory(rawSource: string, rawDestination:
8
8
  readonly remote: string;
9
9
  readonly ignore?: string[];
10
10
  readonly endsWithIgnore?: string[];
11
+ readonly containsIgnore?: string[];
11
12
  readonly rename?: string[];
12
13
  readonly dumpSizes: boolean;
13
14
  readonly dumpFileSizes: boolean;
@@ -5,5 +5,4 @@ export declare const gb: number;
5
5
  * Setting this decreased total run time from 1m40s to 1m05s
6
6
  */
7
7
  export declare const highWaterMark: number;
8
- export declare function exit(command: string): never;
9
8
  export declare const reOriginalSha: RegExp;
@@ -5,5 +5,4 @@ export declare const gb: number;
5
5
  * Setting this decreased total run time from 1m40s to 1m05s
6
6
  */
7
7
  export declare const highWaterMark: number;
8
- export declare function exit(command: string): never;
9
8
  export declare const reOriginalSha: RegExp;
@@ -24,14 +24,23 @@ export type IssueWithZenhub = {
24
24
  name: string;
25
25
  };
26
26
  };
27
+ /**
28
+ * !important
29
+ * The class makes a TLS request to Zenhub's GraphQL endpoint, 'https://zentopia.esri.com/public/graphql'
30
+ * You need to make sure node trusts the certificate authority that signed the certificate used by zentopia.esri.com
31
+ *
32
+ * Include your certificate authority in the NODE_EXTRA_CA_CERTS environment variable
33
+ * Reference: https://qawebgis.esri.com/components/devops/troubleshoot/troubleshoot#certificate-verification-failure
34
+ */
27
35
  declare class Zentopia {
28
36
  readonly repoId: number;
29
37
  readonly workspaceId: string;
38
+ readonly token?: string | undefined;
30
39
  private _issueIdCache;
31
40
  private _pipelinesCache?;
32
41
  private _sprintsCache?;
33
42
  private _releasesCache?;
34
- constructor(repoId: number, workspaceId: string);
43
+ constructor(repoId: number, workspaceId: string, token?: string | undefined);
35
44
  /**
36
45
  * Requests to graphql server
37
46
  */
@@ -24,14 +24,23 @@ export type IssueWithZenhub = {
24
24
  name: string;
25
25
  };
26
26
  };
27
+ /**
28
+ * !important
29
+ * The class makes a TLS request to Zenhub's GraphQL endpoint, 'https://zentopia.esri.com/public/graphql'
30
+ * You need to make sure node trusts the certificate authority that signed the certificate used by zentopia.esri.com
31
+ *
32
+ * Include your certificate authority in the NODE_EXTRA_CA_CERTS environment variable
33
+ * Reference: https://qawebgis.esri.com/components/devops/troubleshoot/troubleshoot#certificate-verification-failure
34
+ */
27
35
  declare class Zentopia {
28
36
  readonly repoId: number;
29
37
  readonly workspaceId: string;
38
+ readonly token?: string | undefined;
30
39
  private _issueIdCache;
31
40
  private _pipelinesCache?;
32
41
  private _sprintsCache?;
33
42
  private _releasesCache?;
34
- constructor(repoId: number, workspaceId: string);
43
+ constructor(repoId: number, workspaceId: string, token?: string | undefined);
35
44
  /**
36
45
  * Requests to graphql server
37
46
  */
@@ -0,0 +1,29 @@
1
+ export declare const npmRegistry = "https://registry.npmjs.org/";
2
+ /**
3
+ * Fetch all published versions for a package.
4
+ */
5
+ export declare function fetchVersions(pkgName: string, options: {
6
+ verbose: boolean;
7
+ }): Promise<{
8
+ versions: string[];
9
+ error?: unknown;
10
+ }>;
11
+ /**
12
+ * Check if a given version for a package is already deprecated.
13
+ * npm view is not able to provide the deprecated version information directly.
14
+ * We have to first fetch all the versions and then one by one check if they are deprecated.
15
+ */
16
+ export declare function isVersionDeprecated(pkgName: string, version: string, options: {
17
+ verbose: boolean;
18
+ }): Promise<boolean>;
19
+ /**
20
+ * Request npm deprecation for the `package@range` specification
21
+ */
22
+ export declare function deprecate(pkgSpec: string, options: {
23
+ authToken?: string;
24
+ message: string;
25
+ verbose: boolean;
26
+ }): Promise<{
27
+ stdout?: string;
28
+ error?: unknown;
29
+ }>;
@@ -0,0 +1,29 @@
1
+ export declare const npmRegistry = "https://registry.npmjs.org/";
2
+ /**
3
+ * Fetch all published versions for a package.
4
+ */
5
+ export declare function fetchVersions(pkgName: string, options: {
6
+ verbose: boolean;
7
+ }): Promise<{
8
+ versions: string[];
9
+ error?: unknown;
10
+ }>;
11
+ /**
12
+ * Check if a given version for a package is already deprecated.
13
+ * npm view is not able to provide the deprecated version information directly.
14
+ * We have to first fetch all the versions and then one by one check if they are deprecated.
15
+ */
16
+ export declare function isVersionDeprecated(pkgName: string, version: string, options: {
17
+ verbose: boolean;
18
+ }): Promise<boolean>;
19
+ /**
20
+ * Request npm deprecation for the `package@range` specification
21
+ */
22
+ export declare function deprecate(pkgSpec: string, options: {
23
+ authToken?: string;
24
+ message: string;
25
+ verbose: boolean;
26
+ }): Promise<{
27
+ stdout?: string;
28
+ error?: unknown;
29
+ }>;
@@ -0,0 +1,2 @@
1
+ import { Command } from '@commander-js/extra-typings';
2
+ export declare const registerCommand: (command: Command) => undefined;
@@ -0,0 +1,2 @@
1
+ import { Command } from '@commander-js/extra-typings';
2
+ export declare const registerCommand: (command: Command) => undefined;
@@ -1,2 +1,66 @@
1
+ import { ExecSyncOptionsWithStringEncoding } from 'node:child_process';
2
+ import { MiniPackageJson } from '../packageJson';
3
+ /**
4
+ * Sets the exit code to 1 and prints the error message to stderr.
5
+ * This is used to indicate an error condition in the script.
6
+ */
1
7
  export declare function error(...messages: unknown[]): void;
2
- export declare function sh(command: string, cwd?: string): string;
8
+ /**
9
+ * Console error the messages and exits the process with code 1.
10
+ * This is used to indicate a fatal error that cannot be recovered from.
11
+ */
12
+ export declare function errorAndExit(...messages: unknown[]): never;
13
+ export declare function sh(command: string, options?: Partial<ExecSyncOptionsWithStringEncoding>): string;
14
+ export declare function findRepositoryRoot(): string;
15
+ export declare function isURL(source: string): boolean;
16
+ /**
17
+ * Returns a list of all package.json paths in the workspace,
18
+ * as resolved from workspaces in root package.json
19
+ */
20
+ export declare function getWorkspacesPackagePaths(includeRootPackage?: boolean): Promise<string[]>;
21
+ type PackageWalkerItem = {
22
+ path: string;
23
+ content: MiniPackageJson;
24
+ };
25
+ type PackageWalkerResult<T> = {
26
+ path: string;
27
+ content: T;
28
+ };
29
+ /**
30
+ * Walks through all workspace packages, calling the callback for each.
31
+ * If the callback returns a non-null value, it is included in the results.
32
+ * If the callback returns null or undefined, that package is not included in the results.
33
+ */
34
+ export declare function workspacesPackageWalker<T = void>(callback: (item: PackageWalkerItem) => Promise<T | undefined> | T | undefined, includeRootPackage?: boolean): Promise<PackageWalkerResult<T>[]>;
35
+ interface AffectedPackage {
36
+ path: string;
37
+ packageJson: MiniPackageJson;
38
+ files: string[];
39
+ }
40
+ /**
41
+ * Computes the list of workspace packages affected by a given set of changed files.
42
+ *
43
+ * This function must always be run from the repository root so that workspace
44
+ * discovery and relative path matching behave correctly.
45
+ *
46
+ * The function first collects all workspace packages (with their paths and package.json).
47
+ * It then checks which of the changed files fall under each package's path and marks
48
+ * those packages as initially affected.
49
+ *
50
+ * Note: Only internal workspace packages are considered in the dependency graph;
51
+ * external dependencies are ignored.
52
+ *
53
+ * @param changed - Iterable list of file paths that were modified.
54
+ * @param options - Additional options:
55
+ * - dfs: Whether to include transitive dependents by traversing the dependency graph.
56
+ *
57
+ * @returns Promise resolving to an array of affected workspace `Package` objects.
58
+ */
59
+ export declare function getAffectedPackages(changed: Iterable<string>, options?: {
60
+ dfs?: boolean;
61
+ }): Promise<AffectedPackage[]>;
62
+ /**
63
+ * Helper to check if an error is a SIGINT (interrupt) error.
64
+ */
65
+ export declare function isSigint(err: unknown): boolean;
66
+ export {};
@@ -1,2 +1,66 @@
1
+ import { ExecSyncOptionsWithStringEncoding } from 'node:child_process';
2
+ import { MiniPackageJson } from '../packageJson';
3
+ /**
4
+ * Sets the exit code to 1 and prints the error message to stderr.
5
+ * This is used to indicate an error condition in the script.
6
+ */
1
7
  export declare function error(...messages: unknown[]): void;
2
- export declare function sh(command: string, cwd?: string): string;
8
+ /**
9
+ * Console error the messages and exits the process with code 1.
10
+ * This is used to indicate a fatal error that cannot be recovered from.
11
+ */
12
+ export declare function errorAndExit(...messages: unknown[]): never;
13
+ export declare function sh(command: string, options?: Partial<ExecSyncOptionsWithStringEncoding>): string;
14
+ export declare function findRepositoryRoot(): string;
15
+ export declare function isURL(source: string): boolean;
16
+ /**
17
+ * Returns a list of all package.json paths in the workspace,
18
+ * as resolved from workspaces in root package.json
19
+ */
20
+ export declare function getWorkspacesPackagePaths(includeRootPackage?: boolean): Promise<string[]>;
21
+ type PackageWalkerItem = {
22
+ path: string;
23
+ content: MiniPackageJson;
24
+ };
25
+ type PackageWalkerResult<T> = {
26
+ path: string;
27
+ content: T;
28
+ };
29
+ /**
30
+ * Walks through all workspace packages, calling the callback for each.
31
+ * If the callback returns a non-null value, it is included in the results.
32
+ * If the callback returns null or undefined, that package is not included in the results.
33
+ */
34
+ export declare function workspacesPackageWalker<T = void>(callback: (item: PackageWalkerItem) => Promise<T | undefined> | T | undefined, includeRootPackage?: boolean): Promise<PackageWalkerResult<T>[]>;
35
+ interface AffectedPackage {
36
+ path: string;
37
+ packageJson: MiniPackageJson;
38
+ files: string[];
39
+ }
40
+ /**
41
+ * Computes the list of workspace packages affected by a given set of changed files.
42
+ *
43
+ * This function must always be run from the repository root so that workspace
44
+ * discovery and relative path matching behave correctly.
45
+ *
46
+ * The function first collects all workspace packages (with their paths and package.json).
47
+ * It then checks which of the changed files fall under each package's path and marks
48
+ * those packages as initially affected.
49
+ *
50
+ * Note: Only internal workspace packages are considered in the dependency graph;
51
+ * external dependencies are ignored.
52
+ *
53
+ * @param changed - Iterable list of file paths that were modified.
54
+ * @param options - Additional options:
55
+ * - dfs: Whether to include transitive dependents by traversing the dependency graph.
56
+ *
57
+ * @returns Promise resolving to an array of affected workspace `Package` objects.
58
+ */
59
+ export declare function getAffectedPackages(changed: Iterable<string>, options?: {
60
+ dfs?: boolean;
61
+ }): Promise<AffectedPackage[]>;
62
+ /**
63
+ * Helper to check if an error is a SIGINT (interrupt) error.
64
+ */
65
+ export declare function isSigint(err: unknown): boolean;
66
+ export {};
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
@@ -1,35 +1,14 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (let key of __getOwnPropNames(from))
11
- if (!__hasOwnProp.call(to, key) && key !== except)
12
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- }
14
- return to;
15
- };
16
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
- // If the importer is in node compatibility mode or this is not an ESM
18
- // file that has been converted to a CommonJS file using a Babel-
19
- // compatible transform (i.e. "__esModule" has not been set), then set
20
- // "default" to the CommonJS "module.exports" for node compatibility.
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
25
3
  const node_fs = require("node:fs");
26
4
  const promises = require("node:fs/promises");
27
5
  const node_child_process = require("node:child_process");
28
- const node_path = require("node:path");
6
+ const path$1 = require("path");
29
7
  const node_url = require("node:url");
30
- const posix = require("node:path/posix");
31
- const win32 = require("node:path/win32");
8
+ const posix = require("path/posix");
9
+ const win32 = require("path/win32");
32
10
  const dts = require("vite-plugin-dts");
11
+ const node_module = require("node:module");
33
12
  const existsAsync = async (file) => (
34
13
  // Using un-promisified version because promises version creates exceptions
35
14
  // which interferes with debugging when "Pause on caught exceptions" is enabled
@@ -37,17 +16,17 @@ const existsAsync = async (file) => (
37
16
  );
38
17
  const sh = (command, cwd) => node_child_process.execSync(command.trim(), { encoding: "utf8", cwd }).trim();
39
18
  async function createFileIfNotExists(filePath, content) {
40
- await promises.mkdir(node_path.dirname(filePath), { recursive: true });
19
+ await promises.mkdir(path$1.dirname(filePath), { recursive: true });
41
20
  if (!await existsAsync(filePath)) {
42
21
  await promises.writeFile(filePath, content, { encoding: "utf8" });
43
22
  }
44
23
  }
45
24
  function findPath(target, startDirectory = process.cwd()) {
46
- const resolvedStartDirectory = startDirectory.startsWith("file:///") ? node_path.dirname(node_url.fileURLToPath(startDirectory)) : node_path.resolve(startDirectory);
47
- 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);
48
27
  while (parentPath.length > 2) {
49
- const fullPath = node_path.join(
50
- ...node_path.sep === "/" ? ["/"] : [],
28
+ const fullPath = path$1.join(
29
+ ...path$1.sep === "/" ? ["/"] : [],
51
30
  ...parentPath,
52
31
  target
53
32
  );
@@ -59,11 +38,11 @@ function findPath(target, startDirectory = process.cwd()) {
59
38
  return void 0;
60
39
  }
61
40
  async function asyncFindPath(target, startDirectory = process.cwd()) {
62
- const resolvedStartDirectory = startDirectory.startsWith("file:///") ? node_path.dirname(node_url.fileURLToPath(startDirectory)) : node_path.resolve(startDirectory);
63
- 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);
64
43
  while (parentPath.length > 2) {
65
- const fullPath = node_path.join(
66
- ...node_path.sep === "/" ? ["/"] : [],
44
+ const fullPath = path$1.join(
45
+ ...path$1.sep === "/" ? ["/"] : [],
67
46
  ...parentPath,
68
47
  target
69
48
  );
@@ -74,6 +53,9 @@ async function asyncFindPath(target, startDirectory = process.cwd()) {
74
53
  }
75
54
  return void 0;
76
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
+ }
77
59
  const gitIgnoreToGlob = (pattern) => fixAbsoluteSyntax(fixMatchFilesSyntax(pattern));
78
60
  function fixAbsoluteSyntax(pattern) {
79
61
  if (pattern.startsWith("/")) {
@@ -94,7 +76,7 @@ function fixMatchFilesSyntax(pattern) {
94
76
  }
95
77
  return pattern.endsWith("/*") ? `${pattern}*` : pattern.endsWith("/") ? `${pattern}**` : `${pattern}/**`;
96
78
  }
97
- const isPosix = node_path.sep === posix.sep;
79
+ const isPosix = path$1.sep === posix.sep;
98
80
  const toPosixPathSeparators = (relativePath) => relativePath.includes(win32.sep) ? relativePath.replaceAll(win32.sep, posix.sep) : relativePath;
99
81
  const normalizePath = isPosix ? (path2) => path2 : toPosixPathSeparators;
100
82
  const toWin32PathSeparators = (relativePath) => relativePath.includes(posix.sep) ? relativePath.replaceAll(posix.sep, win32.sep) : relativePath;
@@ -128,7 +110,6 @@ const path = isPosix ? posix : {
128
110
  return toPosixPathSeparators(result);
129
111
  }
130
112
  };
131
- const exportsForTests = { toWin32PathSeparators };
132
113
  const cachedPackageJson = {};
133
114
  const cachedPackageJsonPromises = {};
134
115
  let rootPackageJsonLocation;
@@ -192,8 +173,9 @@ function detectPackageManager(cwd = process.cwd()) {
192
173
  return packageManager;
193
174
  }
194
175
  function vitePresetPlugin({
195
- externalize = [],
196
- dtsOptions = {}
176
+ dtsOptions = {},
177
+ externalize,
178
+ bundleIn
197
179
  } = {
198
180
  externalize: [],
199
181
  dtsOptions: {}
@@ -222,22 +204,10 @@ function vitePresetPlugin({
222
204
  userConfig = config;
223
205
  }
224
206
  },
225
- /**
226
- * We use a dynamic import here because of how Rollup processes and transforms imports.
227
- * This dependency (rollup-plugin-node-externals) will not be bundled into the output,
228
- * as specified in vite.config.ts.
229
- *
230
- * rollup-plugin-node-externals is an ES module, and Stencil throws an error when it encounters
231
- * a require() statement for an ES module.
232
- *
233
- * If we used a static import, Rollup's cjs build would transform it into a require() statement,
234
- * causing Stencil to throw an error. Using a dynamic import prevents this issue.
235
- */
236
- import("rollup-plugin-node-externals").then(
237
- ({ nodeExternals }) => nodeExternals({
238
- include: externalize.map(stringToStartsWithGlob)
239
- })
240
- ),
207
+ externalizeDependencies({
208
+ externalize,
209
+ bundleIn
210
+ }),
241
211
  dts({
242
212
  logLevel: "warn",
243
213
  // Copies .d.ts files to d.cjs file for CommonJS.
@@ -252,6 +222,7 @@ function vitePresetPlugin({
252
222
  })
253
223
  );
254
224
  }
225
+ await dtsOptions?.afterBuild?.(emitted);
255
226
  },
256
227
  ...dtsOptions,
257
228
  compilerOptions: {
@@ -290,23 +261,62 @@ function vitePresetPlugin({
290
261
  function shouldSkip(id) {
291
262
  return id.includes("__test") || id.includes(".e2e.") || id.includes(".spec.") || id.includes(".test.") || id.includes(".stories.");
292
263
  }
293
- const stringToStartsWithGlob = (option) => option ? typeof option === "string" ? new RegExp(`^${option.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&")}`, "u") : option : void 0;
264
+ function externalizeDependencies(options) {
265
+ const packageJson = retrievePackageJson();
266
+ const externalDependencies = Object.keys({
267
+ ...packageJson.dependencies,
268
+ ...packageJson.peerDependencies,
269
+ ...packageJson.optionalDependencies
270
+ });
271
+ const bundleIn = options.bundleIn?.map(stringToStartsWithGlob);
272
+ const externalize = [
273
+ ...options.externalize?.map(stringToStartsWithGlob) ?? [],
274
+ /^node:/u,
275
+ new RegExp(
276
+ `^(?:${externalDependencies.join("|")}${externalDependencies.length === 0 ? "" : "|"}${node_module.builtinModules.join("|")})(?:/.+)?$`,
277
+ "u"
278
+ )
279
+ ];
280
+ const plugin = {
281
+ name: "@arcgis/components-build-utils:externalize-dependencies",
282
+ apply: "build",
283
+ enforce: "pre",
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;
298
+ }
299
+ }
300
+ };
301
+ return plugin;
302
+ }
303
+ const stringToStartsWithGlob = (option) => typeof option === "string" ? new RegExp(`^${option.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&")}(?:/.+)?$`, "u") : option;
294
304
  exports.asyncFindPath = asyncFindPath;
295
305
  exports.asyncRetrievePackageJson = asyncRetrievePackageJson;
296
306
  exports.createFileIfNotExists = createFileIfNotExists;
297
307
  exports.detectPackageManager = detectPackageManager;
298
308
  exports.existsAsync = existsAsync;
299
- exports.exportsForTests = exportsForTests;
309
+ exports.externalizeDependencies = externalizeDependencies;
300
310
  exports.fetchPackageLocation = fetchPackageLocation;
301
311
  exports.findPath = findPath;
302
312
  exports.getCwd = getCwd;
313
+ exports.gitIgnoreFileToGlobs = gitIgnoreFileToGlobs;
303
314
  exports.gitIgnoreToGlob = gitIgnoreToGlob;
304
315
  exports.isPosix = isPosix;
305
316
  exports.normalizePath = normalizePath;
306
317
  exports.path = path;
307
318
  exports.retrievePackageJson = retrievePackageJson;
308
319
  exports.sh = sh;
309
- exports.stringToStartsWithGlob = stringToStartsWithGlob;
310
320
  exports.toPosixPathSeparators = toPosixPathSeparators;
311
321
  exports.toSystemPathSeparators = toSystemPathSeparators;
312
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,11 +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 { builtinModules } from "node:module";
9
10
  const existsAsync = async (file) => (
10
11
  // Using un-promisified version because promises version creates exceptions
11
12
  // which interferes with debugging when "Pause on caught exceptions" is enabled
@@ -50,6 +51,9 @@ async function asyncFindPath(target, startDirectory = process.cwd()) {
50
51
  }
51
52
  return void 0;
52
53
  }
54
+ function gitIgnoreFileToGlobs(filePath) {
55
+ return readFileSync(filePath, "utf8").split("\n").filter((line) => line.trim().length > 0 && !line.trim().startsWith("#")).map(gitIgnoreToGlob);
56
+ }
53
57
  const gitIgnoreToGlob = (pattern) => fixAbsoluteSyntax(fixMatchFilesSyntax(pattern));
54
58
  function fixAbsoluteSyntax(pattern) {
55
59
  if (pattern.startsWith("/")) {
@@ -104,7 +108,6 @@ const path = isPosix ? posix : {
104
108
  return toPosixPathSeparators(result);
105
109
  }
106
110
  };
107
- const exportsForTests = { toWin32PathSeparators };
108
111
  const cachedPackageJson = {};
109
112
  const cachedPackageJsonPromises = {};
110
113
  let rootPackageJsonLocation;
@@ -168,8 +171,9 @@ function detectPackageManager(cwd = process.cwd()) {
168
171
  return packageManager;
169
172
  }
170
173
  function vitePresetPlugin({
171
- externalize = [],
172
- dtsOptions = {}
174
+ dtsOptions = {},
175
+ externalize,
176
+ bundleIn
173
177
  } = {
174
178
  externalize: [],
175
179
  dtsOptions: {}
@@ -198,22 +202,10 @@ function vitePresetPlugin({
198
202
  userConfig = config;
199
203
  }
200
204
  },
201
- /**
202
- * We use a dynamic import here because of how Rollup processes and transforms imports.
203
- * This dependency (rollup-plugin-node-externals) will not be bundled into the output,
204
- * as specified in vite.config.ts.
205
- *
206
- * rollup-plugin-node-externals is an ES module, and Stencil throws an error when it encounters
207
- * a require() statement for an ES module.
208
- *
209
- * If we used a static import, Rollup's cjs build would transform it into a require() statement,
210
- * causing Stencil to throw an error. Using a dynamic import prevents this issue.
211
- */
212
- import("rollup-plugin-node-externals").then(
213
- ({ nodeExternals }) => nodeExternals({
214
- include: externalize.map(stringToStartsWithGlob)
215
- })
216
- ),
205
+ externalizeDependencies({
206
+ externalize,
207
+ bundleIn
208
+ }),
217
209
  dts({
218
210
  logLevel: "warn",
219
211
  // Copies .d.ts files to d.cjs file for CommonJS.
@@ -228,6 +220,7 @@ function vitePresetPlugin({
228
220
  })
229
221
  );
230
222
  }
223
+ await dtsOptions?.afterBuild?.(emitted);
231
224
  },
232
225
  ...dtsOptions,
233
226
  compilerOptions: {
@@ -266,24 +259,63 @@ function vitePresetPlugin({
266
259
  function shouldSkip(id) {
267
260
  return id.includes("__test") || id.includes(".e2e.") || id.includes(".spec.") || id.includes(".test.") || id.includes(".stories.");
268
261
  }
269
- const stringToStartsWithGlob = (option) => option ? typeof option === "string" ? new RegExp(`^${option.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&")}`, "u") : option : void 0;
262
+ function externalizeDependencies(options) {
263
+ const packageJson = retrievePackageJson();
264
+ const externalDependencies = Object.keys({
265
+ ...packageJson.dependencies,
266
+ ...packageJson.peerDependencies,
267
+ ...packageJson.optionalDependencies
268
+ });
269
+ const bundleIn = options.bundleIn?.map(stringToStartsWithGlob);
270
+ const externalize = [
271
+ ...options.externalize?.map(stringToStartsWithGlob) ?? [],
272
+ /^node:/u,
273
+ new RegExp(
274
+ `^(?:${externalDependencies.join("|")}${externalDependencies.length === 0 ? "" : "|"}${builtinModules.join("|")})(?:/.+)?$`,
275
+ "u"
276
+ )
277
+ ];
278
+ const plugin = {
279
+ name: "@arcgis/components-build-utils:externalize-dependencies",
280
+ apply: "build",
281
+ enforce: "pre",
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;
296
+ }
297
+ }
298
+ };
299
+ return plugin;
300
+ }
301
+ const stringToStartsWithGlob = (option) => typeof option === "string" ? new RegExp(`^${option.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&")}(?:/.+)?$`, "u") : option;
270
302
  export {
271
303
  asyncFindPath,
272
304
  asyncRetrievePackageJson,
273
305
  createFileIfNotExists,
274
306
  detectPackageManager,
275
307
  existsAsync,
276
- exportsForTests,
308
+ externalizeDependencies,
277
309
  fetchPackageLocation,
278
310
  findPath,
279
311
  getCwd,
312
+ gitIgnoreFileToGlobs,
280
313
  gitIgnoreToGlob,
281
314
  isPosix,
282
315
  normalizePath,
283
316
  path,
284
317
  retrievePackageJson,
285
318
  sh,
286
- stringToStartsWithGlob,
287
319
  toPosixPathSeparators,
288
320
  toSystemPathSeparators,
289
321
  vitePresetPlugin
@@ -9,6 +9,7 @@ export type MiniPackageJson = {
9
9
  "version": string;
10
10
  "private"?: boolean;
11
11
  "type"?: "commonjs" | "module";
12
+ "workspaces"?: string[];
12
13
  "publishConfig"?: {
13
14
  access?: string;
14
15
  registry?: string;
@@ -20,11 +21,13 @@ export type MiniPackageJson = {
20
21
  "peerDependenciesMeta"?: Record<string, {
21
22
  optional?: boolean;
22
23
  }>;
24
+ "optionalDependencies"?: Record<string, string | undefined>;
23
25
  "css.customData"?: string[];
24
26
  "customElements"?: string;
25
27
  "html.customData"?: string[];
26
28
  "web-types"?: string;
27
29
  "exports"?: Record<string, Record<string, string> | string>;
30
+ "scripts"?: Record<string, string>;
28
31
  };
29
32
  export declare function retrievePackageJson(location?: string): MiniPackageJson;
30
33
  export declare function asyncRetrievePackageJson(location?: string): Promise<MiniPackageJson>;
@@ -9,6 +9,7 @@ export type MiniPackageJson = {
9
9
  "version": string;
10
10
  "private"?: boolean;
11
11
  "type"?: "commonjs" | "module";
12
+ "workspaces"?: string[];
12
13
  "publishConfig"?: {
13
14
  access?: string;
14
15
  registry?: string;
@@ -20,11 +21,13 @@ export type MiniPackageJson = {
20
21
  "peerDependenciesMeta"?: Record<string, {
21
22
  optional?: boolean;
22
23
  }>;
24
+ "optionalDependencies"?: Record<string, string | undefined>;
23
25
  "css.customData"?: string[];
24
26
  "customElements"?: string;
25
27
  "html.customData"?: string[];
26
28
  "web-types"?: string;
27
29
  "exports"?: Record<string, Record<string, string> | string>;
30
+ "scripts"?: Record<string, string>;
28
31
  };
29
32
  export declare function retrievePackageJson(location?: string): MiniPackageJson;
30
33
  export declare function asyncRetrievePackageJson(location?: string): Promise<MiniPackageJson>;
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
@@ -2,23 +2,82 @@ import { Plugin } from 'vite';
2
2
  import { default as dts } from 'vite-plugin-dts';
3
3
  /**
4
4
  * Vite preset for all our support packages:
5
- * - externalizes all devDependencies (using `rollup-plugin-node-externals`)
5
+ * - externalizes all non-dev-dependencies
6
6
  * - generates type declarations (using `vite-plugin-dts`)
7
7
  */
8
- export declare function vitePresetPlugin({ externalize, dtsOptions, }?: {
9
- /** The list of dependencies to externalize besides devDependencies */
10
- externalize?: string[];
8
+ export declare function vitePresetPlugin({ dtsOptions, externalize, bundleIn, }?: DependencyManagementOptions & {
11
9
  /** Additional options for `vite-plugin-dts` */
12
10
  dtsOptions?: Parameters<typeof dts>[0];
13
- }): [Plugin, Promise<Plugin>, Plugin];
11
+ }): [Plugin, Plugin, Plugin];
14
12
  /**
15
- * By default this plugin converts string values to RegExp that only matches if
16
- * path is "equal" not "starts with", which is not intuitive.
13
+ * Options for externalizing dependencies.
14
+ */
15
+ export type DependencyManagementOptions = {
16
+ /**
17
+ * Force bundle in these dependencies even if they are declared as
18
+ * dependencies or peerDependencies.
19
+ *
20
+ * @example
21
+ * This is desirable if you wish to control the version of a dependency or
22
+ * need to post-process the dependency in some way. Usually, you will declare
23
+ * such as a devDependency, but there is a use case for declaring it as a
24
+ * dependency instead:
25
+ *
26
+ * - If TypeScript types from the bundled in dependencies are referenced in
27
+ * the `.d.ts` files of your library, you will need to declare the package
28
+ * as a `dependency`, so that it is still installed on the consumer's
29
+ * computer so that TypeScript can correctly resolve the types of that
30
+ * library.
31
+ */
32
+ readonly bundleIn?: (RegExp | string)[];
33
+ /**
34
+ * Force externalize these dependencies, even if they are declared as
35
+ * devDependencies.
36
+ *
37
+ * @example
38
+ * This is desirable if you are sure the end user will have these dependencies
39
+ * available, yet do not wish to declare these as devDependencies for some
40
+ * technical reasons.
41
+ */
42
+ readonly externalize?: (RegExp | string)[];
43
+ };
44
+ /**
45
+ * By default, Rollup will bundle-in all dependencies.
46
+ *
47
+ * We change it as follows:
48
+ * Externalize all packages that are defined as
49
+ * "dependency" or "peerDependency" in the package.json.
50
+ * If you wish to bundle-in some package, define it as a "devDependency".
51
+ *
52
+ * Bundling-in packages is not recommended because:
53
+ * - it makes our build take longer
54
+ * - it pushes larger packages to NPM
55
+ * - user of our library is locked into the version of the package we bundled in
56
+ * - if user has two packages using the same library, there will be two copies
57
+ * served on the page
58
+ * - It may break some libraries/prevent them from optimizing correctly
59
+ * depending on the production/development mode, or prevent them from loading
60
+ * correct code depending on browser/node.js environment.
17
61
  *
18
- * I.e, this would only exclude "monaco-editor", not any
19
- * "monaco-editor/sub-path" by default:
20
- * "bundleIn": ["monaco-editor"]
62
+ * For example, see this statement from Lit:
63
+ * https://lit.dev/docs/ssr/authoring/#:~:text=Don%27t%20bundle%20Lit,based%20on%20environment.
64
+ *
65
+ * @see {@link ./buildCdn.ts} for CDN dependency bundling details
66
+ *
67
+ * @remarks
68
+ * If a dependency is both a peerDependency and a devDependency, it will still
69
+ * be externalized (because all peerDependencies are externalized).
70
+ */
71
+ 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.
21
75
  *
22
- * We fix it to match using "starts with" instead
76
+ * @example
77
+ * "monaco-editor" will create a regex that matches "monaco-editor" and
78
+ * "monaco-editor/sub-path", but not "monaco-editor-beta".
23
79
  */
24
- export declare const stringToStartsWithGlob: (option: RegExp | string | false | null | undefined) => RegExp | undefined;
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
@@ -2,23 +2,82 @@ import { Plugin } from 'vite';
2
2
  import { default as dts } from 'vite-plugin-dts';
3
3
  /**
4
4
  * Vite preset for all our support packages:
5
- * - externalizes all devDependencies (using `rollup-plugin-node-externals`)
5
+ * - externalizes all non-dev-dependencies
6
6
  * - generates type declarations (using `vite-plugin-dts`)
7
7
  */
8
- export declare function vitePresetPlugin({ externalize, dtsOptions, }?: {
9
- /** The list of dependencies to externalize besides devDependencies */
10
- externalize?: string[];
8
+ export declare function vitePresetPlugin({ dtsOptions, externalize, bundleIn, }?: DependencyManagementOptions & {
11
9
  /** Additional options for `vite-plugin-dts` */
12
10
  dtsOptions?: Parameters<typeof dts>[0];
13
- }): [Plugin, Promise<Plugin>, Plugin];
11
+ }): [Plugin, Plugin, Plugin];
14
12
  /**
15
- * By default this plugin converts string values to RegExp that only matches if
16
- * path is "equal" not "starts with", which is not intuitive.
13
+ * Options for externalizing dependencies.
14
+ */
15
+ export type DependencyManagementOptions = {
16
+ /**
17
+ * Force bundle in these dependencies even if they are declared as
18
+ * dependencies or peerDependencies.
19
+ *
20
+ * @example
21
+ * This is desirable if you wish to control the version of a dependency or
22
+ * need to post-process the dependency in some way. Usually, you will declare
23
+ * such as a devDependency, but there is a use case for declaring it as a
24
+ * dependency instead:
25
+ *
26
+ * - If TypeScript types from the bundled in dependencies are referenced in
27
+ * the `.d.ts` files of your library, you will need to declare the package
28
+ * as a `dependency`, so that it is still installed on the consumer's
29
+ * computer so that TypeScript can correctly resolve the types of that
30
+ * library.
31
+ */
32
+ readonly bundleIn?: (RegExp | string)[];
33
+ /**
34
+ * Force externalize these dependencies, even if they are declared as
35
+ * devDependencies.
36
+ *
37
+ * @example
38
+ * This is desirable if you are sure the end user will have these dependencies
39
+ * available, yet do not wish to declare these as devDependencies for some
40
+ * technical reasons.
41
+ */
42
+ readonly externalize?: (RegExp | string)[];
43
+ };
44
+ /**
45
+ * By default, Rollup will bundle-in all dependencies.
46
+ *
47
+ * We change it as follows:
48
+ * Externalize all packages that are defined as
49
+ * "dependency" or "peerDependency" in the package.json.
50
+ * If you wish to bundle-in some package, define it as a "devDependency".
51
+ *
52
+ * Bundling-in packages is not recommended because:
53
+ * - it makes our build take longer
54
+ * - it pushes larger packages to NPM
55
+ * - user of our library is locked into the version of the package we bundled in
56
+ * - if user has two packages using the same library, there will be two copies
57
+ * served on the page
58
+ * - It may break some libraries/prevent them from optimizing correctly
59
+ * depending on the production/development mode, or prevent them from loading
60
+ * correct code depending on browser/node.js environment.
17
61
  *
18
- * I.e, this would only exclude "monaco-editor", not any
19
- * "monaco-editor/sub-path" by default:
20
- * "bundleIn": ["monaco-editor"]
62
+ * For example, see this statement from Lit:
63
+ * https://lit.dev/docs/ssr/authoring/#:~:text=Don%27t%20bundle%20Lit,based%20on%20environment.
64
+ *
65
+ * @see {@link ./buildCdn.ts} for CDN dependency bundling details
66
+ *
67
+ * @remarks
68
+ * If a dependency is both a peerDependency and a devDependency, it will still
69
+ * be externalized (because all peerDependencies are externalized).
70
+ */
71
+ 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.
21
75
  *
22
- * We fix it to match using "starts with" instead
76
+ * @example
77
+ * "monaco-editor" will create a regex that matches "monaco-editor" and
78
+ * "monaco-editor/sub-path", but not "monaco-editor-beta".
23
79
  */
24
- export declare const stringToStartsWithGlob: (option: RegExp | string | false | null | undefined) => RegExp | undefined;
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.15",
3
+ "version": "4.34.0-next.150",
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",
@@ -22,14 +22,18 @@
22
22
  },
23
23
  "license": "SEE LICENSE IN LICENSE.md",
24
24
  "dependencies": {
25
- "@commander-js/extra-typings": "^11.1.0",
26
- "chalk": "^5.3.0",
27
- "commander": "^11.1.0",
28
- "glob": "^11.0.0",
29
- "rollup-plugin-node-externals": "^8.0.0",
25
+ "@commander-js/extra-typings": "^14.0.0",
26
+ "chalk": "^5.4.1",
27
+ "commander": "^14.0.0",
28
+ "fast-glob": "^3.3.3",
29
+ "fast-xml-parser": "^5.2.5",
30
+ "glob": "^11.0.3",
31
+ "ora": "^8.2.0",
32
+ "p-limit": "^7.1.1",
33
+ "semver": "^7.7.2",
30
34
  "split2": "^4.2.0",
31
35
  "tslib": "^2.8.1",
32
- "vite": "^6.3.4",
33
- "vite-plugin-dts": "^4.5.3"
36
+ "vite": "^7.0.0",
37
+ "vite-plugin-dts": "^4.5.4"
34
38
  }
35
39
  }
@@ -1,16 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { spawn } from "node:child_process";
3
- import { join } from "node:path";
4
-
5
- const scriptPath = join(import.meta.dirname, "run.ts");
6
- const commandArguments = process.argv.slice(2);
7
-
8
- const child = spawn("npx", ["tsx", scriptPath, ...commandArguments], {
9
- stdio: "inherit",
10
- shell: true,
11
- });
12
-
13
- // Forward the exit code
14
- child.on("exit", function (code) {
15
- process.exit(code);
16
- });
2
+ // Register tsx's TypeScript loader that will do on the fly transpilation of any
3
+ // imported .ts file
4
+ import "tsx";
5
+ // This still has to be async import until native TS support in Node 24
6
+ await import("./run.ts");