@arcgis/components-build-utils 5.0.0-next.6 → 5.0.0-next.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,13 +1,32 @@
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
+ ));
2
24
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
25
  const node_fs = require("node:fs");
4
26
  const promises = require("node:fs/promises");
5
27
  const node_child_process = require("node:child_process");
6
28
  const path$1 = require("path");
7
29
  const node_url = require("node:url");
8
- const posix = require("path/posix");
9
- const win32 = require("path/win32");
10
- const dts = require("vite-plugin-dts");
11
30
  const node_module = require("node:module");
12
31
  const existsAsync = async (file) => (
13
32
  // Using un-promisified version because promises version creates exceptions
@@ -76,37 +95,37 @@ function fixMatchFilesSyntax(pattern) {
76
95
  }
77
96
  return pattern.endsWith("/*") ? `${pattern}*` : pattern.endsWith("/") ? `${pattern}**` : `${pattern}/**`;
78
97
  }
79
- const isPosix = path$1.sep === posix.sep;
80
- const toPosixPathSeparators = (relativePath) => relativePath.includes(win32.sep) ? relativePath.replaceAll(win32.sep, posix.sep) : relativePath;
98
+ const isPosix = path$1.sep === path$1.posix.sep;
99
+ const toPosixPathSeparators = (relativePath) => relativePath.includes(path$1.win32.sep) ? relativePath.replaceAll(path$1.win32.sep, path$1.posix.sep) : relativePath;
81
100
  const normalizePath = isPosix ? (path2) => path2 : toPosixPathSeparators;
82
- const toWin32PathSeparators = (relativePath) => relativePath.includes(posix.sep) ? relativePath.replaceAll(posix.sep, win32.sep) : relativePath;
101
+ const toWin32PathSeparators = (relativePath) => relativePath.includes(path$1.posix.sep) ? relativePath.replaceAll(path$1.posix.sep, path$1.win32.sep) : relativePath;
83
102
  const toSystemPathSeparators = isPosix ? (path2) => path2 : toWin32PathSeparators;
84
103
  const getCwd = isPosix ? process.cwd : () => toPosixPathSeparators(process.cwd());
85
- const path = isPosix ? posix : {
86
- ...win32,
87
- sep: posix.sep,
104
+ const path = isPosix ? path$1.posix : {
105
+ ...path$1.win32,
106
+ sep: path$1.posix.sep,
88
107
  join(...paths) {
89
- const result = win32.join(...paths);
108
+ const result = path$1.win32.join(...paths);
90
109
  return toPosixPathSeparators(result);
91
110
  },
92
111
  normalize(path2) {
93
- const result = win32.normalize(path2);
112
+ const result = path$1.win32.normalize(path2);
94
113
  return toPosixPathSeparators(result);
95
114
  },
96
115
  relative(from, to) {
97
- const result = win32.relative(from, to);
116
+ const result = path$1.win32.relative(from, to);
98
117
  return toPosixPathSeparators(result);
99
118
  },
100
119
  dirname(path2) {
101
- const result = win32.dirname(path2);
120
+ const result = path$1.win32.dirname(path2);
102
121
  return toPosixPathSeparators(result);
103
122
  },
104
123
  resolve(...paths) {
105
- const result = win32.resolve(...paths);
124
+ const result = path$1.win32.resolve(...paths);
106
125
  return toPosixPathSeparators(result);
107
126
  },
108
127
  toNamespacedPath(path2) {
109
- const result = win32.toNamespacedPath(path2);
128
+ const result = path$1.win32.toNamespacedPath(path2);
110
129
  return toPosixPathSeparators(result);
111
130
  }
112
131
  };
@@ -208,54 +227,59 @@ function vitePresetPlugin({
208
227
  externalize,
209
228
  bundleIn
210
229
  }),
211
- dts({
212
- logLevel: "warn",
213
- // Copies .d.ts files to d.cjs file for CommonJS.
214
- // Adds a performance hit as it occurs after the build
215
- async afterBuild(emitted) {
216
- if (userConfig?.build?.lib && userConfig.build.lib.formats?.includes("cjs")) {
217
- await Promise.all(
218
- emitted.entries().map(async ([filePath, content]) => {
219
- if (filePath.endsWith(".d.ts")) {
220
- await promises.writeFile(filePath.replace(".d.ts", ".d.cts"), content);
221
- }
222
- })
223
- );
224
- }
225
- await dtsOptions?.afterBuild?.(emitted);
226
- },
227
- ...dtsOptions,
228
- compilerOptions: {
229
- // For details, see comment above excludeOutsideFiles in
230
- // https://devtopia.esri.com/WebGIS/arcgis-web-components/blob/main/packages/support-packages/lit-compiler/src/types/textTransformers.ts
231
- rootDir: ".",
232
- ...dtsOptions.compilerOptions
233
- },
234
- /**
235
- * Do not emit any .d.ts files for files outside the dist directory
236
- * (i.e vite.config.ts, storybook stories and etc)
237
- * This also applies for references to node_modules/.../components.d.ts files in
238
- * tsconfig.json - these must be included in TypeScript program to provide
239
- * types, but should not be re-emitted during build.
240
- */
241
- beforeWriteFile: async (filePath, content) => {
242
- if (filePath.startsWith(distSrc) && !shouldSkip(filePath)) {
243
- const baseBeforeWriteFile = dtsOptions?.beforeWriteFile ?? ((filePath2, content2) => ({ filePath: filePath2, content: content2 }));
244
- return await baseBeforeWriteFile(`${dist}${filePath.slice(distSrc.length)}`, content);
245
- } else {
246
- return false;
230
+ // This dependency pulls in many others. Since components-build-utils has a
231
+ // single entry point, we load a large module tree needlessly. To avoid,
232
+ // load the plugin on demand.
233
+ import("vite-plugin-dts").then(
234
+ ({ default: dts }) => dts({
235
+ logLevel: "warn",
236
+ // Copies .d.ts files to d.cjs file for CommonJS.
237
+ // Adds a performance hit as it occurs after the build
238
+ async afterBuild(emitted) {
239
+ if (userConfig?.build?.lib && userConfig.build.lib.formats?.includes("cjs")) {
240
+ await Promise.all(
241
+ emitted.entries().map(async ([filePath, content]) => {
242
+ if (filePath.endsWith(".d.ts")) {
243
+ await promises.writeFile(filePath.replace(".d.ts", ".d.cts"), content);
244
+ }
245
+ })
246
+ );
247
+ }
248
+ await dtsOptions?.afterBuild?.(emitted);
249
+ },
250
+ ...dtsOptions,
251
+ compilerOptions: {
252
+ // For details, see comment above excludeOutsideFiles in
253
+ // https://devtopia.esri.com/WebGIS/arcgis-web-components/blob/main/packages/support-packages/lit-compiler/src/types/textTransformers.ts
254
+ rootDir: ".",
255
+ ...dtsOptions.compilerOptions
256
+ },
257
+ /**
258
+ * Do not emit any .d.ts files for files outside the dist directory
259
+ * (i.e vite.config.ts, storybook stories and etc)
260
+ * This also applies for references to node_modules/.../components.d.ts files in
261
+ * tsconfig.json - these must be included in TypeScript program to provide
262
+ * types, but should not be re-emitted during build.
263
+ */
264
+ beforeWriteFile: async (filePath, content) => {
265
+ if (filePath.startsWith(distSrc) && !shouldSkip(filePath)) {
266
+ const baseBeforeWriteFile = dtsOptions?.beforeWriteFile ?? ((filePath2, content2) => ({ filePath: filePath2, content: content2 }));
267
+ return await baseBeforeWriteFile(`${dist}${filePath.slice(distSrc.length)}`, content);
268
+ } else {
269
+ return false;
270
+ }
271
+ },
272
+ afterDiagnostic(diagnostics) {
273
+ const hasErrors = diagnostics.length > 0;
274
+ const isBuilding = command === "build";
275
+ const stopBuild = hasErrors && isBuilding;
276
+ if (stopBuild) {
277
+ throw new Error("TypeScript errors reported. See error messages above");
278
+ }
279
+ return dtsOptions?.afterDiagnostic?.(diagnostics);
247
280
  }
248
- },
249
- afterDiagnostic(diagnostics) {
250
- const hasErrors = diagnostics.length > 0;
251
- const isBuilding = command === "build";
252
- const stopBuild = hasErrors && isBuilding;
253
- if (stopBuild) {
254
- throw new Error("TypeScript errors reported. See error messages above");
255
- }
256
- return dtsOptions?.afterDiagnostic?.(diagnostics);
257
- }
258
- })
281
+ })
282
+ )
259
283
  ];
260
284
  }
261
285
  function shouldSkip(id) {
package/dist/index.js CHANGED
@@ -1,11 +1,8 @@
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 "path";
4
+ import { dirname, resolve, sep, join, posix, win32 } from "path";
5
5
  import { fileURLToPath } from "node:url";
6
- import posix from "path/posix";
7
- import win32 from "path/win32";
8
- import dts from "vite-plugin-dts";
9
6
  import { builtinModules } from "node:module";
10
7
  const existsAsync = async (file) => (
11
8
  // Using un-promisified version because promises version creates exceptions
@@ -206,54 +203,59 @@ function vitePresetPlugin({
206
203
  externalize,
207
204
  bundleIn
208
205
  }),
209
- dts({
210
- logLevel: "warn",
211
- // Copies .d.ts files to d.cjs file for CommonJS.
212
- // Adds a performance hit as it occurs after the build
213
- async afterBuild(emitted) {
214
- if (userConfig?.build?.lib && userConfig.build.lib.formats?.includes("cjs")) {
215
- await Promise.all(
216
- emitted.entries().map(async ([filePath, content]) => {
217
- if (filePath.endsWith(".d.ts")) {
218
- await writeFile(filePath.replace(".d.ts", ".d.cts"), content);
219
- }
220
- })
221
- );
206
+ // This dependency pulls in many others. Since components-build-utils has a
207
+ // single entry point, we load a large module tree needlessly. To avoid,
208
+ // load the plugin on demand.
209
+ import("vite-plugin-dts").then(
210
+ ({ default: dts }) => dts({
211
+ logLevel: "warn",
212
+ // Copies .d.ts files to d.cjs file for CommonJS.
213
+ // Adds a performance hit as it occurs after the build
214
+ async afterBuild(emitted) {
215
+ if (userConfig?.build?.lib && userConfig.build.lib.formats?.includes("cjs")) {
216
+ await Promise.all(
217
+ emitted.entries().map(async ([filePath, content]) => {
218
+ if (filePath.endsWith(".d.ts")) {
219
+ await writeFile(filePath.replace(".d.ts", ".d.cts"), content);
220
+ }
221
+ })
222
+ );
223
+ }
224
+ await dtsOptions?.afterBuild?.(emitted);
225
+ },
226
+ ...dtsOptions,
227
+ compilerOptions: {
228
+ // For details, see comment above excludeOutsideFiles in
229
+ // https://devtopia.esri.com/WebGIS/arcgis-web-components/blob/main/packages/support-packages/lit-compiler/src/types/textTransformers.ts
230
+ rootDir: ".",
231
+ ...dtsOptions.compilerOptions
232
+ },
233
+ /**
234
+ * Do not emit any .d.ts files for files outside the dist directory
235
+ * (i.e vite.config.ts, storybook stories and etc)
236
+ * This also applies for references to node_modules/.../components.d.ts files in
237
+ * tsconfig.json - these must be included in TypeScript program to provide
238
+ * types, but should not be re-emitted during build.
239
+ */
240
+ beforeWriteFile: async (filePath, content) => {
241
+ if (filePath.startsWith(distSrc) && !shouldSkip(filePath)) {
242
+ const baseBeforeWriteFile = dtsOptions?.beforeWriteFile ?? ((filePath2, content2) => ({ filePath: filePath2, content: content2 }));
243
+ return await baseBeforeWriteFile(`${dist}${filePath.slice(distSrc.length)}`, content);
244
+ } else {
245
+ return false;
246
+ }
247
+ },
248
+ afterDiagnostic(diagnostics) {
249
+ const hasErrors = diagnostics.length > 0;
250
+ const isBuilding = command === "build";
251
+ const stopBuild = hasErrors && isBuilding;
252
+ if (stopBuild) {
253
+ throw new Error("TypeScript errors reported. See error messages above");
254
+ }
255
+ return dtsOptions?.afterDiagnostic?.(diagnostics);
222
256
  }
223
- await dtsOptions?.afterBuild?.(emitted);
224
- },
225
- ...dtsOptions,
226
- compilerOptions: {
227
- // For details, see comment above excludeOutsideFiles in
228
- // https://devtopia.esri.com/WebGIS/arcgis-web-components/blob/main/packages/support-packages/lit-compiler/src/types/textTransformers.ts
229
- rootDir: ".",
230
- ...dtsOptions.compilerOptions
231
- },
232
- /**
233
- * Do not emit any .d.ts files for files outside the dist directory
234
- * (i.e vite.config.ts, storybook stories and etc)
235
- * This also applies for references to node_modules/.../components.d.ts files in
236
- * tsconfig.json - these must be included in TypeScript program to provide
237
- * types, but should not be re-emitted during build.
238
- */
239
- beforeWriteFile: async (filePath, content) => {
240
- if (filePath.startsWith(distSrc) && !shouldSkip(filePath)) {
241
- const baseBeforeWriteFile = dtsOptions?.beforeWriteFile ?? ((filePath2, content2) => ({ filePath: filePath2, content: content2 }));
242
- return await baseBeforeWriteFile(`${dist}${filePath.slice(distSrc.length)}`, content);
243
- } else {
244
- return false;
245
- }
246
- },
247
- afterDiagnostic(diagnostics) {
248
- const hasErrors = diagnostics.length > 0;
249
- const isBuilding = command === "build";
250
- const stopBuild = hasErrors && isBuilding;
251
- if (stopBuild) {
252
- throw new Error("TypeScript errors reported. See error messages above");
253
- }
254
- return dtsOptions?.afterDiagnostic?.(diagnostics);
255
- }
256
- })
257
+ })
258
+ )
257
259
  ];
258
260
  }
259
261
  function shouldSkip(id) {
package/dist/path.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { default as posix } from 'path/posix';
1
+ import { posix } from 'path';
2
2
  /**
3
3
  * This is called "isPosix" rather than "isNotWindows" because even if we are
4
4
  * on Windows, we could be running in a POSIX environment (e.g. WSL2)
package/dist/path.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { default as posix } from 'path/posix';
1
+ import { posix } from 'path';
2
2
  /**
3
3
  * This is called "isPosix" rather than "isNotWindows" because even if we are
4
4
  * on Windows, we could be running in a POSIX environment (e.g. WSL2)
package/dist/vite.d.cts CHANGED
@@ -8,7 +8,7 @@ import { default as dts } from 'vite-plugin-dts';
8
8
  export declare function vitePresetPlugin({ dtsOptions, externalize, bundleIn, }?: DependencyManagementOptions & {
9
9
  /** Additional options for `vite-plugin-dts` */
10
10
  dtsOptions?: Parameters<typeof dts>[0];
11
- }): [Plugin, Plugin, Plugin];
11
+ }): [Plugin, Plugin, Promise<Plugin>];
12
12
  /**
13
13
  * Options for externalizing dependencies.
14
14
  */
package/dist/vite.d.ts CHANGED
@@ -8,7 +8,7 @@ import { default as dts } from 'vite-plugin-dts';
8
8
  export declare function vitePresetPlugin({ dtsOptions, externalize, bundleIn, }?: DependencyManagementOptions & {
9
9
  /** Additional options for `vite-plugin-dts` */
10
10
  dtsOptions?: Parameters<typeof dts>[0];
11
- }): [Plugin, Plugin, Plugin];
11
+ }): [Plugin, Plugin, Promise<Plugin>];
12
12
  /**
13
13
  * Options for externalizing dependencies.
14
14
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/components-build-utils",
3
- "version": "5.0.0-next.6",
3
+ "version": "5.0.0-next.8",
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",