@utoo/pack 1.0.5 → 1.0.6

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/cjs/build.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  import { BundleOptions } from "./types";
2
2
  import { WebpackConfig } from "./webpackCompat";
3
- export declare function build(bundleOptions: BundleOptions, projectPath?: string, rootPath?: string): Promise<void>;
4
- export declare function build(webpackConfig: WebpackConfig, projectPath?: string, rootPath?: string): Promise<void>;
3
+ export declare function build(options: BundleOptions | WebpackConfig, projectPath?: string, rootPath?: string): Promise<void>;
package/cjs/build.js CHANGED
@@ -12,8 +12,8 @@ const util_1 = require("./util");
12
12
  const webpackCompat_1 = require("./webpackCompat");
13
13
  const xcodeProfile_1 = require("./xcodeProfile");
14
14
  function build(options, projectPath, rootPath) {
15
- const bundleOptions = options.compatMode
16
- ? (0, webpackCompat_1.compatOptionsFromWebpack)(options)
15
+ const bundleOptions = options.webpackMode
16
+ ? (0, webpackCompat_1.compatOptionsFromWebpack)(options, projectPath, rootPath)
17
17
  : options;
18
18
  if (!rootPath) {
19
19
  // help user to find the rootDir automatically.
package/cjs/dev.d.ts CHANGED
@@ -3,8 +3,7 @@ import send from "send";
3
3
  import { Duplex, Writable } from "stream";
4
4
  import { BundleOptions } from "./types";
5
5
  import { WebpackConfig } from "./webpackCompat";
6
- export declare function serve(bundleOptions: BundleOptions, projectPath?: string, rootPath?: string, serverOptions?: StartServerOptions): Promise<void>;
7
- export declare function serve(webpackConfig: WebpackConfig, projectPath?: string, rootPath?: string, serverOptions?: StartServerOptions): Promise<void>;
6
+ export declare function serve(options: BundleOptions | WebpackConfig, projectPath?: string, rootPath?: string, serverOptions?: StartServerOptions): Promise<void>;
8
7
  export interface SelfSignedCertificate {
9
8
  key: string;
10
9
  cert: string;
package/cjs/dev.js CHANGED
@@ -26,8 +26,8 @@ const util_1 = require("./util");
26
26
  const webpackCompat_1 = require("./webpackCompat");
27
27
  const xcodeProfile_1 = require("./xcodeProfile");
28
28
  function serve(options, projectPath, rootPath, serverOptions) {
29
- const bundleOptions = options.compatMode
30
- ? (0, webpackCompat_1.compatOptionsFromWebpack)(options)
29
+ const bundleOptions = options.webpackMode
30
+ ? (0, webpackCompat_1.compatOptionsFromWebpack)(options, projectPath, rootPath)
31
31
  : options;
32
32
  if (!rootPath) {
33
33
  // help user to find the rootDir automatically
@@ -1,6 +1,7 @@
1
1
  import type webpack from "webpack";
2
2
  import { BundleOptions } from "./types";
3
- export type WebpackConfig = Pick<webpack.Configuration, "name" | "entry" | "mode" | "module" | "resolve" | "externals" | "output" | "target" | "devtool" | "optimization" | "plugins" | "stats"> & {
4
- compatMode: true;
3
+ export declare function readWebpackConfig(projectPath?: string, rootPath?: string): any;
4
+ export type WebpackConfig = Partial<Pick<webpack.Configuration, "name" | "entry" | "mode" | "module" | "resolve" | "externals" | "output" | "target" | "devtool" | "optimization" | "plugins" | "stats">> & {
5
+ webpackMode: true;
5
6
  };
6
- export declare function compatOptionsFromWebpack(webpackConfig: WebpackConfig): BundleOptions;
7
+ export declare function compatOptionsFromWebpack(webpackConfig: WebpackConfig, projectPath?: string, rootPath?: string): BundleOptions;
@@ -1,8 +1,22 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.readWebpackConfig = readWebpackConfig;
3
7
  exports.compatOptionsFromWebpack = compatOptionsFromWebpack;
4
- function compatOptionsFromWebpack(webpackConfig) {
5
- const { entry, mode, module, resolve, externals, output, target, devtool, optimization, plugins, stats, } = webpackConfig;
8
+ const path_1 = __importDefault(require("path"));
9
+ function readWebpackConfig(projectPath, rootPath) {
10
+ const projectPathOutOfRoot = projectPath === undefined
11
+ ? process.cwd()
12
+ : path_1.default.join(rootPath !== null && rootPath !== void 0 ? rootPath : "", projectPath);
13
+ const configPath = path_1.default.join(projectPathOutOfRoot, "webpack.config.js");
14
+ return require(configPath);
15
+ }
16
+ function compatOptionsFromWebpack(webpackConfig, projectPath, rootPath) {
17
+ const { entry, mode, module, resolve, externals, output, target, devtool, optimization, plugins, stats, } = webpackConfig.entry
18
+ ? webpackConfig
19
+ : readWebpackConfig(projectPath, rootPath);
6
20
  return {
7
21
  config: {
8
22
  entry: compatEntry(entry),
package/esm/build.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  import { BundleOptions } from "./types";
2
2
  import { WebpackConfig } from "./webpackCompat";
3
- export declare function build(bundleOptions: BundleOptions, projectPath?: string, rootPath?: string): Promise<void>;
4
- export declare function build(webpackConfig: WebpackConfig, projectPath?: string, rootPath?: string): Promise<void>;
3
+ export declare function build(options: BundleOptions | WebpackConfig, projectPath?: string, rootPath?: string): Promise<void>;
package/esm/build.js CHANGED
@@ -9,8 +9,8 @@ import { blockStdout, createDefineEnv, getPackPath } from "./util";
9
9
  import { compatOptionsFromWebpack } from "./webpackCompat";
10
10
  import { xcodeProfilingReady } from "./xcodeProfile";
11
11
  export function build(options, projectPath, rootPath) {
12
- const bundleOptions = options.compatMode
13
- ? compatOptionsFromWebpack(options)
12
+ const bundleOptions = options.webpackMode
13
+ ? compatOptionsFromWebpack(options, projectPath, rootPath)
14
14
  : options;
15
15
  if (!rootPath) {
16
16
  // help user to find the rootDir automatically.
package/esm/dev.d.ts CHANGED
@@ -3,8 +3,7 @@ import send from "send";
3
3
  import { Duplex, Writable } from "stream";
4
4
  import { BundleOptions } from "./types";
5
5
  import { WebpackConfig } from "./webpackCompat";
6
- export declare function serve(bundleOptions: BundleOptions, projectPath?: string, rootPath?: string, serverOptions?: StartServerOptions): Promise<void>;
7
- export declare function serve(webpackConfig: WebpackConfig, projectPath?: string, rootPath?: string, serverOptions?: StartServerOptions): Promise<void>;
6
+ export declare function serve(options: BundleOptions | WebpackConfig, projectPath?: string, rootPath?: string, serverOptions?: StartServerOptions): Promise<void>;
8
7
  export interface SelfSignedCertificate {
9
8
  key: string;
10
9
  cert: string;
package/esm/dev.js CHANGED
@@ -12,8 +12,8 @@ import { blockStdout, getPackPath } from "./util";
12
12
  import { compatOptionsFromWebpack } from "./webpackCompat";
13
13
  import { xcodeProfilingReady } from "./xcodeProfile";
14
14
  export function serve(options, projectPath, rootPath, serverOptions) {
15
- const bundleOptions = options.compatMode
16
- ? compatOptionsFromWebpack(options)
15
+ const bundleOptions = options.webpackMode
16
+ ? compatOptionsFromWebpack(options, projectPath, rootPath)
17
17
  : options;
18
18
  if (!rootPath) {
19
19
  // help user to find the rootDir automatically
@@ -1,6 +1,7 @@
1
1
  import type webpack from "webpack";
2
2
  import { BundleOptions } from "./types";
3
- export type WebpackConfig = Pick<webpack.Configuration, "name" | "entry" | "mode" | "module" | "resolve" | "externals" | "output" | "target" | "devtool" | "optimization" | "plugins" | "stats"> & {
4
- compatMode: true;
3
+ export declare function readWebpackConfig(projectPath?: string, rootPath?: string): any;
4
+ export type WebpackConfig = Partial<Pick<webpack.Configuration, "name" | "entry" | "mode" | "module" | "resolve" | "externals" | "output" | "target" | "devtool" | "optimization" | "plugins" | "stats">> & {
5
+ webpackMode: true;
5
6
  };
6
- export declare function compatOptionsFromWebpack(webpackConfig: WebpackConfig): BundleOptions;
7
+ export declare function compatOptionsFromWebpack(webpackConfig: WebpackConfig, projectPath?: string, rootPath?: string): BundleOptions;
@@ -1,5 +1,15 @@
1
- export function compatOptionsFromWebpack(webpackConfig) {
2
- const { entry, mode, module, resolve, externals, output, target, devtool, optimization, plugins, stats, } = webpackConfig;
1
+ import path from "path";
2
+ export function readWebpackConfig(projectPath, rootPath) {
3
+ const projectPathOutOfRoot = projectPath === undefined
4
+ ? process.cwd()
5
+ : path.join(rootPath !== null && rootPath !== void 0 ? rootPath : "", projectPath);
6
+ const configPath = path.join(projectPathOutOfRoot, "webpack.config.js");
7
+ return require(configPath);
8
+ }
9
+ export function compatOptionsFromWebpack(webpackConfig, projectPath, rootPath) {
10
+ const { entry, mode, module, resolve, externals, output, target, devtool, optimization, plugins, stats, } = webpackConfig.entry
11
+ ? webpackConfig
12
+ : readWebpackConfig(projectPath, rootPath);
3
13
  return {
4
14
  config: {
5
15
  entry: compatEntry(entry),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@utoo/pack",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "main": "cjs/index.js",
5
5
  "module": "esm/index.js",
6
6
  "exports": {
@@ -85,12 +85,12 @@
85
85
  },
86
86
  "repository": "git@github.com:utooland/utoo.git",
87
87
  "optionalDependencies": {
88
- "@utoo/pack-darwin-arm64": "1.0.5",
89
- "@utoo/pack-darwin-x64": "1.0.5",
90
- "@utoo/pack-linux-arm64-gnu": "1.0.5",
91
- "@utoo/pack-linux-arm64-musl": "1.0.5",
92
- "@utoo/pack-linux-x64-gnu": "1.0.5",
93
- "@utoo/pack-linux-x64-musl": "1.0.5",
94
- "@utoo/pack-win32-x64-msvc": "1.0.5"
88
+ "@utoo/pack-darwin-arm64": "1.0.6",
89
+ "@utoo/pack-darwin-x64": "1.0.6",
90
+ "@utoo/pack-linux-arm64-gnu": "1.0.6",
91
+ "@utoo/pack-linux-arm64-musl": "1.0.6",
92
+ "@utoo/pack-linux-x64-gnu": "1.0.6",
93
+ "@utoo/pack-linux-x64-musl": "1.0.6",
94
+ "@utoo/pack-win32-x64-msvc": "1.0.6"
95
95
  }
96
96
  }