@utoo/pack 1.0.4 → 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 +1 -2
- package/cjs/build.js +2 -2
- package/cjs/dev.d.ts +1 -2
- package/cjs/dev.js +2 -2
- package/cjs/webpackCompat.d.ts +4 -3
- package/cjs/webpackCompat.js +30 -3
- package/esm/build.d.ts +1 -2
- package/esm/build.js +2 -2
- package/esm/dev.d.ts +1 -2
- package/esm/dev.js +2 -2
- package/esm/webpackCompat.d.ts +4 -3
- package/esm/webpackCompat.js +26 -3
- package/package.json +8 -8
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(
|
|
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.
|
|
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(
|
|
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.
|
|
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
|
package/cjs/webpackCompat.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type webpack from "webpack";
|
|
2
2
|
import { BundleOptions } from "./types";
|
|
3
|
-
export
|
|
4
|
-
|
|
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;
|
package/cjs/webpackCompat.js
CHANGED
|
@@ -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
|
-
|
|
5
|
-
|
|
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),
|
|
@@ -100,7 +114,20 @@ function compatFromWebpackPlugin(webpackPlugins, picker) {
|
|
|
100
114
|
}
|
|
101
115
|
compatDefine.pluginName = "DefinePlugin";
|
|
102
116
|
function compatDefine(maybeWebpackPluginInstance) {
|
|
103
|
-
|
|
117
|
+
const definitions = maybeWebpackPluginInstance === null || maybeWebpackPluginInstance === void 0 ? void 0 : maybeWebpackPluginInstance.definitions;
|
|
118
|
+
if (!definitions || typeof definitions !== "object") {
|
|
119
|
+
return definitions;
|
|
120
|
+
}
|
|
121
|
+
const processedDefinitions = {};
|
|
122
|
+
for (const [key, value] of Object.entries(definitions)) {
|
|
123
|
+
if (typeof value === "object" && value !== null) {
|
|
124
|
+
processedDefinitions[key] = JSON.stringify(value);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
processedDefinitions[key] = value;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return processedDefinitions;
|
|
104
131
|
}
|
|
105
132
|
function compatExternals(webpackExternals) {
|
|
106
133
|
if (!webpackExternals) {
|
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(
|
|
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.
|
|
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(
|
|
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.
|
|
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
|
package/esm/webpackCompat.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type webpack from "webpack";
|
|
2
2
|
import { BundleOptions } from "./types";
|
|
3
|
-
export
|
|
4
|
-
|
|
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;
|
package/esm/webpackCompat.js
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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),
|
|
@@ -97,7 +107,20 @@ function compatFromWebpackPlugin(webpackPlugins, picker) {
|
|
|
97
107
|
}
|
|
98
108
|
compatDefine.pluginName = "DefinePlugin";
|
|
99
109
|
function compatDefine(maybeWebpackPluginInstance) {
|
|
100
|
-
|
|
110
|
+
const definitions = maybeWebpackPluginInstance === null || maybeWebpackPluginInstance === void 0 ? void 0 : maybeWebpackPluginInstance.definitions;
|
|
111
|
+
if (!definitions || typeof definitions !== "object") {
|
|
112
|
+
return definitions;
|
|
113
|
+
}
|
|
114
|
+
const processedDefinitions = {};
|
|
115
|
+
for (const [key, value] of Object.entries(definitions)) {
|
|
116
|
+
if (typeof value === "object" && value !== null) {
|
|
117
|
+
processedDefinitions[key] = JSON.stringify(value);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
processedDefinitions[key] = value;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return processedDefinitions;
|
|
101
124
|
}
|
|
102
125
|
function compatExternals(webpackExternals) {
|
|
103
126
|
if (!webpackExternals) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@utoo/pack",
|
|
3
|
-
"version": "1.0.
|
|
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.
|
|
89
|
-
"@utoo/pack-darwin-x64": "1.0.
|
|
90
|
-
"@utoo/pack-linux-arm64-gnu": "1.0.
|
|
91
|
-
"@utoo/pack-linux-arm64-musl": "1.0.
|
|
92
|
-
"@utoo/pack-linux-x64-gnu": "1.0.
|
|
93
|
-
"@utoo/pack-linux-x64-musl": "1.0.
|
|
94
|
-
"@utoo/pack-win32-x64-msvc": "1.0.
|
|
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
|
}
|