@utoo/pack 1.1.25-alpha.1 → 1.1.25-alpha.2

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.
@@ -13,6 +13,7 @@ const common_1 = require("../utils/common");
13
13
  const findRoot_1 = require("../utils/findRoot");
14
14
  const getInitialAssets_1 = require("../utils/getInitialAssets");
15
15
  const htmlEntry_1 = require("../utils/htmlEntry");
16
+ const validateEntry_1 = require("../utils/validateEntry");
16
17
  const xcodeProfile_1 = require("../utils/xcodeProfile");
17
18
  function build(options, projectPath, rootPath) {
18
19
  const bundleOptions = (0, webpackCompat_1.resolveBundleOptions)(options, projectPath, rootPath);
@@ -28,7 +29,9 @@ async function buildInternal(bundleOptions, projectPath, rootPath) {
28
29
  if (process.env.XCODE_PROFILE) {
29
30
  await (0, xcodeProfile_1.xcodeProfilingReady)();
30
31
  }
31
- (0, htmlEntry_1.processHtmlEntry)(bundleOptions.config, projectPath || process.cwd());
32
+ const resolvedProjectPath = projectPath || process.cwd();
33
+ (0, htmlEntry_1.processHtmlEntry)(bundleOptions.config, resolvedProjectPath);
34
+ (0, validateEntry_1.validateEntryPaths)(bundleOptions.config, resolvedProjectPath);
32
35
  const createProject = (0, project_1.projectFactory)();
33
36
  const project = await createProject({
34
37
  processEnv: (_a = bundleOptions.processEnv) !== null && _a !== void 0 ? _a : {},
package/cjs/core/hmr.js CHANGED
@@ -12,13 +12,16 @@ const HtmlPlugin_1 = require("../plugins/HtmlPlugin");
12
12
  const common_1 = require("../utils/common");
13
13
  const getInitialAssets_1 = require("../utils/getInitialAssets");
14
14
  const htmlEntry_1 = require("../utils/htmlEntry");
15
+ const validateEntry_1 = require("../utils/validateEntry");
15
16
  const project_1 = require("./project");
16
17
  const wsServer = new ws_1.default.Server({ noServer: true });
17
18
  const sessionId = Math.floor(Number.MAX_SAFE_INTEGER * Math.random());
18
19
  exports.FAST_REFRESH_RUNTIME_RELOAD = "Fast Refresh had to perform a full reload due to a runtime error.";
19
20
  async function createHotReloader(bundleOptions, projectPath, rootPath) {
20
21
  var _a;
21
- (0, htmlEntry_1.processHtmlEntry)(bundleOptions.config, projectPath || process.cwd());
22
+ const resolvedProjectPath = projectPath || process.cwd();
23
+ (0, htmlEntry_1.processHtmlEntry)(bundleOptions.config, resolvedProjectPath);
24
+ (0, validateEntry_1.validateEntryPaths)(bundleOptions.config, resolvedProjectPath);
22
25
  const createProject = (0, project_1.projectFactory)();
23
26
  const project = await createProject({
24
27
  processEnv: (_a = bundleOptions.processEnv) !== null && _a !== void 0 ? _a : {},
@@ -0,0 +1,10 @@
1
+ import { ConfigComplete } from "../config/types";
2
+ /**
3
+ * Validates that all entry.import paths exist in the filesystem.
4
+ * Throws an error if any entry path doesn't exist.
5
+ *
6
+ * @param config - The complete config containing entry points
7
+ * @param projectPath - The project root path to resolve relative entry paths
8
+ * @throws {Error} If any entry.import path doesn't exist
9
+ */
10
+ export declare function validateEntryPaths(config: ConfigComplete, projectPath: string): void;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.validateEntryPaths = validateEntryPaths;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ /**
10
+ * Validates that all entry.import paths exist in the filesystem.
11
+ * Throws an error if any entry path doesn't exist.
12
+ *
13
+ * @param config - The complete config containing entry points
14
+ * @param projectPath - The project root path to resolve relative entry paths
15
+ * @throws {Error} If any entry.import path doesn't exist
16
+ */
17
+ function validateEntryPaths(config, projectPath) {
18
+ if (!config.entry || config.entry.length === 0) {
19
+ return;
20
+ }
21
+ const errors = [];
22
+ for (const entry of config.entry) {
23
+ if (!entry.import) {
24
+ errors.push(`Entry is missing 'import' property`);
25
+ continue;
26
+ }
27
+ // Resolve the entry path relative to projectPath
28
+ const entryPath = path_1.default.isAbsolute(entry.import)
29
+ ? entry.import
30
+ : path_1.default.resolve(projectPath, entry.import);
31
+ // Check if the file exists
32
+ if (!fs_1.default.existsSync(entryPath)) {
33
+ const entryName = entry.name ? ` (name: "${entry.name}")` : "";
34
+ errors.push(`Entry import path does not exist: "${entry.import}"${entryName}\n` +
35
+ ` Resolved path: ${entryPath}`);
36
+ }
37
+ }
38
+ if (errors.length > 0) {
39
+ throw new Error(`Invalid entry configuration:\n${errors.map((e) => ` - ${e}`).join("\n")}`);
40
+ }
41
+ }
@@ -10,6 +10,7 @@ import { blockStdout, createDefineEnv, getPackPath } from "../utils/common";
10
10
  import { findRootDir } from "../utils/findRoot";
11
11
  import { getInitialAssetsFromStats } from "../utils/getInitialAssets";
12
12
  import { processHtmlEntry } from "../utils/htmlEntry";
13
+ import { validateEntryPaths } from "../utils/validateEntry";
13
14
  import { xcodeProfilingReady } from "../utils/xcodeProfile";
14
15
  export function build(options, projectPath, rootPath) {
15
16
  const bundleOptions = resolveBundleOptions(options, projectPath, rootPath);
@@ -25,7 +26,9 @@ async function buildInternal(bundleOptions, projectPath, rootPath) {
25
26
  if (process.env.XCODE_PROFILE) {
26
27
  await xcodeProfilingReady();
27
28
  }
28
- processHtmlEntry(bundleOptions.config, projectPath || process.cwd());
29
+ const resolvedProjectPath = projectPath || process.cwd();
30
+ processHtmlEntry(bundleOptions.config, resolvedProjectPath);
31
+ validateEntryPaths(bundleOptions.config, resolvedProjectPath);
29
32
  const createProject = projectFactory();
30
33
  const project = await createProject({
31
34
  processEnv: (_a = bundleOptions.processEnv) !== null && _a !== void 0 ? _a : {},
package/esm/core/hmr.js CHANGED
@@ -5,13 +5,16 @@ import { HtmlPlugin } from "../plugins/HtmlPlugin";
5
5
  import { createDefineEnv, debounce, getPackPath, processIssues, } from "../utils/common";
6
6
  import { getInitialAssetsFromStats } from "../utils/getInitialAssets";
7
7
  import { processHtmlEntry } from "../utils/htmlEntry";
8
+ import { validateEntryPaths } from "../utils/validateEntry";
8
9
  import { projectFactory } from "./project";
9
10
  const wsServer = new ws.Server({ noServer: true });
10
11
  const sessionId = Math.floor(Number.MAX_SAFE_INTEGER * Math.random());
11
12
  export const FAST_REFRESH_RUNTIME_RELOAD = "Fast Refresh had to perform a full reload due to a runtime error.";
12
13
  export async function createHotReloader(bundleOptions, projectPath, rootPath) {
13
14
  var _a;
14
- processHtmlEntry(bundleOptions.config, projectPath || process.cwd());
15
+ const resolvedProjectPath = projectPath || process.cwd();
16
+ processHtmlEntry(bundleOptions.config, resolvedProjectPath);
17
+ validateEntryPaths(bundleOptions.config, resolvedProjectPath);
15
18
  const createProject = projectFactory();
16
19
  const project = await createProject({
17
20
  processEnv: (_a = bundleOptions.processEnv) !== null && _a !== void 0 ? _a : {},
@@ -0,0 +1,10 @@
1
+ import { ConfigComplete } from "../config/types";
2
+ /**
3
+ * Validates that all entry.import paths exist in the filesystem.
4
+ * Throws an error if any entry path doesn't exist.
5
+ *
6
+ * @param config - The complete config containing entry points
7
+ * @param projectPath - The project root path to resolve relative entry paths
8
+ * @throws {Error} If any entry.import path doesn't exist
9
+ */
10
+ export declare function validateEntryPaths(config: ConfigComplete, projectPath: string): void;
@@ -0,0 +1,35 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ /**
4
+ * Validates that all entry.import paths exist in the filesystem.
5
+ * Throws an error if any entry path doesn't exist.
6
+ *
7
+ * @param config - The complete config containing entry points
8
+ * @param projectPath - The project root path to resolve relative entry paths
9
+ * @throws {Error} If any entry.import path doesn't exist
10
+ */
11
+ export function validateEntryPaths(config, projectPath) {
12
+ if (!config.entry || config.entry.length === 0) {
13
+ return;
14
+ }
15
+ const errors = [];
16
+ for (const entry of config.entry) {
17
+ if (!entry.import) {
18
+ errors.push(`Entry is missing 'import' property`);
19
+ continue;
20
+ }
21
+ // Resolve the entry path relative to projectPath
22
+ const entryPath = path.isAbsolute(entry.import)
23
+ ? entry.import
24
+ : path.resolve(projectPath, entry.import);
25
+ // Check if the file exists
26
+ if (!fs.existsSync(entryPath)) {
27
+ const entryName = entry.name ? ` (name: "${entry.name}")` : "";
28
+ errors.push(`Entry import path does not exist: "${entry.import}"${entryName}\n` +
29
+ ` Resolved path: ${entryPath}`);
30
+ }
31
+ }
32
+ if (errors.length > 0) {
33
+ throw new Error(`Invalid entry configuration:\n${errors.map((e) => ` - ${e}`).join("\n")}`);
34
+ }
35
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@utoo/pack",
3
- "version": "1.1.25-alpha.1",
3
+ "version": "1.1.25-alpha.2",
4
4
  "main": "cjs/index.js",
5
5
  "module": "esm/index.js",
6
6
  "types": "esm/index.d.ts",
@@ -39,7 +39,7 @@
39
39
  "dependencies": {
40
40
  "@babel/code-frame": "7.22.5",
41
41
  "@swc/helpers": "0.5.15",
42
- "@utoo/pack-shared": "1.1.25-alpha.1",
42
+ "@utoo/pack-shared": "1.1.25-alpha.2",
43
43
  "@utoo/style-loader": "^1.0.0",
44
44
  "domparser-rs": "^0.0.5",
45
45
  "find-up": "4.1.0",
@@ -86,12 +86,12 @@
86
86
  },
87
87
  "repository": "git@github.com:utooland/utoo.git",
88
88
  "optionalDependencies": {
89
- "@utoo/pack-darwin-arm64": "1.1.25-alpha.1",
90
- "@utoo/pack-darwin-x64": "1.1.25-alpha.1",
91
- "@utoo/pack-linux-arm64-gnu": "1.1.25-alpha.1",
92
- "@utoo/pack-linux-arm64-musl": "1.1.25-alpha.1",
93
- "@utoo/pack-linux-x64-gnu": "1.1.25-alpha.1",
94
- "@utoo/pack-linux-x64-musl": "1.1.25-alpha.1",
95
- "@utoo/pack-win32-x64-msvc": "1.1.25-alpha.1"
89
+ "@utoo/pack-darwin-arm64": "1.1.25-alpha.2",
90
+ "@utoo/pack-darwin-x64": "1.1.25-alpha.2",
91
+ "@utoo/pack-linux-arm64-gnu": "1.1.25-alpha.2",
92
+ "@utoo/pack-linux-arm64-musl": "1.1.25-alpha.2",
93
+ "@utoo/pack-linux-x64-gnu": "1.1.25-alpha.2",
94
+ "@utoo/pack-linux-x64-musl": "1.1.25-alpha.2",
95
+ "@utoo/pack-win32-x64-msvc": "1.1.25-alpha.2"
96
96
  }
97
97
  }