@arcgis/components-build-utils 4.34.0-next.8 → 4.34.0-next.81

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.
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare const registerCommand: (command: Command) => undefined;
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
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: (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;
@@ -0,0 +1,12 @@
1
+ import { Command } from '@commander-js/extra-typings';
2
+ export declare const registerCommand: (command: Command) => undefined;
3
+ export type Builddate = {
4
+ "builddate": string;
5
+ "commit": string;
6
+ "branch": string;
7
+ "version": string;
8
+ "@arcgis/core": string;
9
+ "@esri/calcite-components": string;
10
+ "@esri/arcgis-html-sanitizer": string;
11
+ };
12
+ export declare function generateBuilddate(): Builddate;
@@ -0,0 +1,12 @@
1
+ import { Command } from '@commander-js/extra-typings';
2
+ export declare const registerCommand: (command: Command) => undefined;
3
+ export type Builddate = {
4
+ "builddate": string;
5
+ "commit": string;
6
+ "branch": string;
7
+ "version": string;
8
+ "@arcgis/core": string;
9
+ "@esri/calcite-components": string;
10
+ "@esri/arcgis-html-sanitizer": string;
11
+ };
12
+ export declare function generateBuilddate(): Builddate;
@@ -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,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;
@@ -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 +1,35 @@
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;
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 exit(...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
+ export {};
@@ -1 +1,35 @@
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;
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 exit(...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
+ export {};
package/dist/index.cjs CHANGED
@@ -1,26 +1,4 @@
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");
@@ -30,6 +8,7 @@ const node_url = require("node:url");
30
8
  const posix = require("node:path/posix");
31
9
  const win32 = require("node: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
@@ -192,8 +171,9 @@ function detectPackageManager(cwd = process.cwd()) {
192
171
  return packageManager;
193
172
  }
194
173
  function vitePresetPlugin({
195
- externalize = [],
196
- dtsOptions = {}
174
+ dtsOptions = {},
175
+ externalize,
176
+ bundleIn
197
177
  } = {
198
178
  externalize: [],
199
179
  dtsOptions: {}
@@ -222,22 +202,10 @@ function vitePresetPlugin({
222
202
  userConfig = config;
223
203
  }
224
204
  },
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
- ),
205
+ externalizeDependencies({
206
+ externalize,
207
+ bundleIn
208
+ }),
241
209
  dts({
242
210
  logLevel: "warn",
243
211
  // Copies .d.ts files to d.cjs file for CommonJS.
@@ -252,6 +220,7 @@ function vitePresetPlugin({
252
220
  })
253
221
  );
254
222
  }
223
+ await dtsOptions?.afterBuild?.(emitted);
255
224
  },
256
225
  ...dtsOptions,
257
226
  compilerOptions: {
@@ -290,13 +259,53 @@ function vitePresetPlugin({
290
259
  function shouldSkip(id) {
291
260
  return id.includes("__test") || id.includes(".e2e.") || id.includes(".spec.") || id.includes(".test.") || id.includes(".stories.");
292
261
  }
293
- 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
+ ...externalDependencies.length > 0 ? [new RegExp(`^(?:${externalDependencies.join("|")})(?:/.+)?$`, "u")] : []
273
+ ];
274
+ const isExternalized = (id) => externalize.some((regex) => regex.test(id));
275
+ const isBundledIn = (id) => bundleIn.some((regex) => regex.test(id));
276
+ const plugin = {
277
+ name: "@arcgis/components-build-utils:externalize-dependencies",
278
+ apply: "build",
279
+ 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
+ };
295
+ }
296
+ return isExternalized(specifier) && !isBundledIn(specifier) ? false : null;
297
+ }
298
+ };
299
+ return plugin;
300
+ }
301
+ const stringToStartsWithGlob = (option) => typeof option === "string" ? new RegExp(`^${option.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&")}(?:/.+)?$`, "u") : option;
294
302
  exports.asyncFindPath = asyncFindPath;
295
303
  exports.asyncRetrievePackageJson = asyncRetrievePackageJson;
296
304
  exports.createFileIfNotExists = createFileIfNotExists;
297
305
  exports.detectPackageManager = detectPackageManager;
298
306
  exports.existsAsync = existsAsync;
299
307
  exports.exportsForTests = exportsForTests;
308
+ exports.externalizeDependencies = externalizeDependencies;
300
309
  exports.fetchPackageLocation = fetchPackageLocation;
301
310
  exports.findPath = findPath;
302
311
  exports.getCwd = getCwd;
package/dist/index.js CHANGED
@@ -6,6 +6,7 @@ import { fileURLToPath } from "node:url";
6
6
  import posix from "node:path/posix";
7
7
  import win32 from "node:path/win32";
8
8
  import dts from "vite-plugin-dts";
9
+ import { isBuiltin } 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
@@ -168,8 +169,9 @@ function detectPackageManager(cwd = process.cwd()) {
168
169
  return packageManager;
169
170
  }
170
171
  function vitePresetPlugin({
171
- externalize = [],
172
- dtsOptions = {}
172
+ dtsOptions = {},
173
+ externalize,
174
+ bundleIn
173
175
  } = {
174
176
  externalize: [],
175
177
  dtsOptions: {}
@@ -198,22 +200,10 @@ function vitePresetPlugin({
198
200
  userConfig = config;
199
201
  }
200
202
  },
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
- ),
203
+ externalizeDependencies({
204
+ externalize,
205
+ bundleIn
206
+ }),
217
207
  dts({
218
208
  logLevel: "warn",
219
209
  // Copies .d.ts files to d.cjs file for CommonJS.
@@ -228,6 +218,7 @@ function vitePresetPlugin({
228
218
  })
229
219
  );
230
220
  }
221
+ await dtsOptions?.afterBuild?.(emitted);
231
222
  },
232
223
  ...dtsOptions,
233
224
  compilerOptions: {
@@ -266,7 +257,46 @@ function vitePresetPlugin({
266
257
  function shouldSkip(id) {
267
258
  return id.includes("__test") || id.includes(".e2e.") || id.includes(".spec.") || id.includes(".test.") || id.includes(".stories.");
268
259
  }
269
- const stringToStartsWithGlob = (option) => option ? typeof option === "string" ? new RegExp(`^${option.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&")}`, "u") : option : void 0;
260
+ function externalizeDependencies(options) {
261
+ const packageJson = retrievePackageJson();
262
+ const externalDependencies = Object.keys({
263
+ ...packageJson.dependencies,
264
+ ...packageJson.peerDependencies,
265
+ ...packageJson.optionalDependencies
266
+ });
267
+ const bundleIn = options.bundleIn?.map(stringToStartsWithGlob) ?? [];
268
+ const externalize = [
269
+ ...options.externalize?.map(stringToStartsWithGlob) ?? [],
270
+ ...externalDependencies.length > 0 ? [new RegExp(`^(?:${externalDependencies.join("|")})(?:/.+)?$`, "u")] : []
271
+ ];
272
+ const isExternalized = (id) => externalize.some((regex) => regex.test(id));
273
+ const isBundledIn = (id) => bundleIn.some((regex) => regex.test(id));
274
+ const plugin = {
275
+ name: "@arcgis/components-build-utils:externalize-dependencies",
276
+ apply: "build",
277
+ 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
+ };
293
+ }
294
+ return isExternalized(specifier) && !isBundledIn(specifier) ? false : null;
295
+ }
296
+ };
297
+ return plugin;
298
+ }
299
+ const stringToStartsWithGlob = (option) => typeof option === "string" ? new RegExp(`^${option.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&")}(?:/.+)?$`, "u") : option;
270
300
  export {
271
301
  asyncFindPath,
272
302
  asyncRetrievePackageJson,
@@ -274,6 +304,7 @@ export {
274
304
  detectPackageManager,
275
305
  existsAsync,
276
306
  exportsForTests,
307
+ externalizeDependencies,
277
308
  fetchPackageLocation,
278
309
  findPath,
279
310
  getCwd,
@@ -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,6 +21,7 @@ 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[];
@@ -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,6 +21,7 @@ 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[];
package/dist/vite.d.cts CHANGED
@@ -2,23 +2,79 @@ 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;
package/dist/vite.d.ts CHANGED
@@ -2,23 +2,79 @@ 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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/components-build-utils",
3
- "version": "4.34.0-next.8",
3
+ "version": "4.34.0-next.81",
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,15 @@
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-xml-parser": "^5.2.5",
29
+ "glob": "^11.0.3",
30
+ "semver": "^7.7.2",
30
31
  "split2": "^4.2.0",
31
32
  "tslib": "^2.8.1",
32
- "vite": "^6.3.4",
33
- "vite-plugin-dts": "^4.5.3"
33
+ "vite": "^7.0.0",
34
+ "vite-plugin-dts": "^4.5.4"
34
35
  }
35
36
  }
@@ -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");