@utoo/pack-shared 1.2.13 → 1.3.0-alpha.1
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/config.d.ts +18 -13
- package/cjs/utils.d.ts +1 -7
- package/cjs/utils.js +0 -31
- package/cjs/webpackCompat.js +4 -3
- package/esm/config.d.ts +18 -13
- package/esm/utils.d.ts +1 -7
- package/esm/utils.js +0 -30
- package/esm/webpackCompat.js +4 -3
- package/package.json +1 -1
package/cjs/config.d.ts
CHANGED
|
@@ -14,11 +14,6 @@ export interface LibraryOptions {
|
|
|
14
14
|
name?: string;
|
|
15
15
|
export?: Array<string>;
|
|
16
16
|
}
|
|
17
|
-
export interface DefineEnv {
|
|
18
|
-
client: RustifiedEnv;
|
|
19
|
-
edge: RustifiedEnv;
|
|
20
|
-
nodejs: RustifiedEnv;
|
|
21
|
-
}
|
|
22
17
|
export type RustifiedEnv = {
|
|
23
18
|
name: string;
|
|
24
19
|
value: string;
|
|
@@ -100,6 +95,20 @@ export type ExternalConfig = string | ExternalAdvanced;
|
|
|
100
95
|
* ```
|
|
101
96
|
*/
|
|
102
97
|
export type ProviderConfig = Record<string, string | [string, string]>;
|
|
98
|
+
/**
|
|
99
|
+
* Development server options (port, host, HTTPS, HMR).
|
|
100
|
+
* Used by the dev server and by config resolution for startup options.
|
|
101
|
+
*/
|
|
102
|
+
export interface DevServerConfig {
|
|
103
|
+
/** Enable Hot Module Replacement. */
|
|
104
|
+
hot?: boolean;
|
|
105
|
+
/** Port to listen on. */
|
|
106
|
+
port?: number;
|
|
107
|
+
/** Host to bind (e.g. localhost, 0.0.0.0). */
|
|
108
|
+
host?: string;
|
|
109
|
+
/** Use HTTPS; when true without a certificate, a self-signed cert may be generated. */
|
|
110
|
+
https?: boolean;
|
|
111
|
+
}
|
|
103
112
|
export interface ConfigComplete {
|
|
104
113
|
entry: EntryOptions[];
|
|
105
114
|
mode?: "production" | "development";
|
|
@@ -157,6 +166,8 @@ export interface ConfigComplete {
|
|
|
157
166
|
wasmAsAsset?: boolean;
|
|
158
167
|
};
|
|
159
168
|
styles?: {
|
|
169
|
+
autoCssModules?: boolean;
|
|
170
|
+
emotion?: boolean;
|
|
160
171
|
less?: {
|
|
161
172
|
implementation?: string;
|
|
162
173
|
[key: string]: any;
|
|
@@ -185,12 +196,7 @@ export interface ConfigComplete {
|
|
|
185
196
|
pluginRuntimeStrategy?: "workerThreads" | "childProcesses";
|
|
186
197
|
persistentCaching?: boolean;
|
|
187
198
|
nodePolyfill?: boolean;
|
|
188
|
-
devServer?:
|
|
189
|
-
hot?: boolean;
|
|
190
|
-
port?: number;
|
|
191
|
-
host?: string;
|
|
192
|
-
https?: boolean;
|
|
193
|
-
};
|
|
199
|
+
devServer?: DevServerConfig;
|
|
194
200
|
cacheHandler?: string;
|
|
195
201
|
experimental?: ExperimentalConfig;
|
|
196
202
|
}
|
|
@@ -233,7 +239,6 @@ export interface BundleOptions {
|
|
|
233
239
|
* A map of environment variables to use when compiling code.
|
|
234
240
|
*/
|
|
235
241
|
processEnv?: Record<string, string>;
|
|
236
|
-
defineEnv?: DefineEnv;
|
|
237
242
|
/**
|
|
238
243
|
* Whether to watch the filesystem for file changes.
|
|
239
244
|
*/
|
|
@@ -259,7 +264,7 @@ export interface BundleOptions {
|
|
|
259
264
|
* Bundler options (entry, output, define, ...) at top level,
|
|
260
265
|
* plus optional CLI/runtime options (processEnv, watch, dev, ...).
|
|
261
266
|
*/
|
|
262
|
-
export type UserConfig = ConfigComplete & Partial<Pick<BundleOptions, "processEnv" | "
|
|
267
|
+
export type UserConfig = ConfigComplete & Partial<Pick<BundleOptions, "processEnv" | "watch" | "dev" | "buildId" | "packPath">> & {
|
|
263
268
|
rootPath?: string;
|
|
264
269
|
projectPath?: string;
|
|
265
270
|
};
|
package/cjs/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RustifiedEnv } from "./config";
|
|
2
2
|
import { Issue } from "./issue";
|
|
3
3
|
export declare class ModuleBuildError extends Error {
|
|
4
4
|
name: string;
|
|
@@ -9,12 +9,6 @@ export interface ResultWithIssues {
|
|
|
9
9
|
export declare function processIssues(result: ResultWithIssues, throwIssue: boolean, logErrors: boolean): void;
|
|
10
10
|
export declare function isWellKnownError(issue: Issue): boolean;
|
|
11
11
|
export declare function rustifyEnv(env: Record<string, string>): RustifiedEnv;
|
|
12
|
-
interface DefineEnvOptions {
|
|
13
|
-
config: ConfigComplete;
|
|
14
|
-
dev: boolean;
|
|
15
|
-
optionDefineEnv?: DefineEnv;
|
|
16
|
-
}
|
|
17
|
-
export declare function createDefineEnv(options: DefineEnvOptions): DefineEnv;
|
|
18
12
|
type AnyFunc<T> = (this: T, ...args: any) => any;
|
|
19
13
|
export declare function debounce<T, F extends AnyFunc<T>>(fn: F, ms: number, maxWait?: number): (this: T, ...passedArgs: Parameters<F>) => void;
|
|
20
14
|
export {};
|
package/cjs/utils.js
CHANGED
|
@@ -4,7 +4,6 @@ exports.ModuleBuildError = void 0;
|
|
|
4
4
|
exports.processIssues = processIssues;
|
|
5
5
|
exports.isWellKnownError = isWellKnownError;
|
|
6
6
|
exports.rustifyEnv = rustifyEnv;
|
|
7
|
-
exports.createDefineEnv = createDefineEnv;
|
|
8
7
|
exports.debounce = debounce;
|
|
9
8
|
const issue_1 = require("./issue");
|
|
10
9
|
const styledString_1 = require("./styledString");
|
|
@@ -56,36 +55,6 @@ function rustifyEnv(env) {
|
|
|
56
55
|
value,
|
|
57
56
|
}));
|
|
58
57
|
}
|
|
59
|
-
function createDefineEnv(options) {
|
|
60
|
-
var _a;
|
|
61
|
-
let defineEnv = (_a = options.optionDefineEnv) !== null && _a !== void 0 ? _a : {
|
|
62
|
-
client: [],
|
|
63
|
-
edge: [],
|
|
64
|
-
nodejs: [],
|
|
65
|
-
};
|
|
66
|
-
function getDefineEnv() {
|
|
67
|
-
var _a;
|
|
68
|
-
const envs = {
|
|
69
|
-
"process.env.NODE_ENV": options.dev ? "development" : "production",
|
|
70
|
-
};
|
|
71
|
-
const userDefines = (_a = options.config.define) !== null && _a !== void 0 ? _a : {};
|
|
72
|
-
for (const key in userDefines) {
|
|
73
|
-
envs[key] = userDefines[key];
|
|
74
|
-
}
|
|
75
|
-
// serialize
|
|
76
|
-
const defineEnvStringified = {};
|
|
77
|
-
for (const key in defineEnv) {
|
|
78
|
-
const value = envs[key];
|
|
79
|
-
defineEnvStringified[key] = JSON.stringify(value);
|
|
80
|
-
}
|
|
81
|
-
return defineEnvStringified;
|
|
82
|
-
}
|
|
83
|
-
// TODO: future define envs need to extends for more compiler like server or edge.
|
|
84
|
-
for (const variant of Object.keys(defineEnv)) {
|
|
85
|
-
defineEnv[variant] = rustifyEnv(getDefineEnv());
|
|
86
|
-
}
|
|
87
|
-
return defineEnv;
|
|
88
|
-
}
|
|
89
58
|
function debounce(fn, ms, maxWait = Infinity) {
|
|
90
59
|
let timeoutId;
|
|
91
60
|
// The time the debouncing function was first called during this debounce queue.
|
package/cjs/webpackCompat.js
CHANGED
|
@@ -469,6 +469,7 @@ function compatOptimization(webpackOptimization) {
|
|
|
469
469
|
return;
|
|
470
470
|
}
|
|
471
471
|
const { moduleIds, minimize, concatenateModules, usedExports } = webpackOptimization;
|
|
472
|
+
const enableWebpackUsedExports = usedExports !== false;
|
|
472
473
|
return {
|
|
473
474
|
moduleIds: moduleIds === "named"
|
|
474
475
|
? "named"
|
|
@@ -478,9 +479,9 @@ function compatOptimization(webpackOptimization) {
|
|
|
478
479
|
noMangling: webpackOptimization.mangleExports === false,
|
|
479
480
|
minify: minimize,
|
|
480
481
|
concatenateModules,
|
|
481
|
-
treeShaking:
|
|
482
|
-
removeUnusedExports:
|
|
483
|
-
removeUnusedImports:
|
|
482
|
+
treeShaking: false,
|
|
483
|
+
removeUnusedExports: enableWebpackUsedExports,
|
|
484
|
+
removeUnusedImports: enableWebpackUsedExports,
|
|
484
485
|
};
|
|
485
486
|
}
|
|
486
487
|
function compatStats(webpackStats) {
|
package/esm/config.d.ts
CHANGED
|
@@ -14,11 +14,6 @@ export interface LibraryOptions {
|
|
|
14
14
|
name?: string;
|
|
15
15
|
export?: Array<string>;
|
|
16
16
|
}
|
|
17
|
-
export interface DefineEnv {
|
|
18
|
-
client: RustifiedEnv;
|
|
19
|
-
edge: RustifiedEnv;
|
|
20
|
-
nodejs: RustifiedEnv;
|
|
21
|
-
}
|
|
22
17
|
export type RustifiedEnv = {
|
|
23
18
|
name: string;
|
|
24
19
|
value: string;
|
|
@@ -100,6 +95,20 @@ export type ExternalConfig = string | ExternalAdvanced;
|
|
|
100
95
|
* ```
|
|
101
96
|
*/
|
|
102
97
|
export type ProviderConfig = Record<string, string | [string, string]>;
|
|
98
|
+
/**
|
|
99
|
+
* Development server options (port, host, HTTPS, HMR).
|
|
100
|
+
* Used by the dev server and by config resolution for startup options.
|
|
101
|
+
*/
|
|
102
|
+
export interface DevServerConfig {
|
|
103
|
+
/** Enable Hot Module Replacement. */
|
|
104
|
+
hot?: boolean;
|
|
105
|
+
/** Port to listen on. */
|
|
106
|
+
port?: number;
|
|
107
|
+
/** Host to bind (e.g. localhost, 0.0.0.0). */
|
|
108
|
+
host?: string;
|
|
109
|
+
/** Use HTTPS; when true without a certificate, a self-signed cert may be generated. */
|
|
110
|
+
https?: boolean;
|
|
111
|
+
}
|
|
103
112
|
export interface ConfigComplete {
|
|
104
113
|
entry: EntryOptions[];
|
|
105
114
|
mode?: "production" | "development";
|
|
@@ -157,6 +166,8 @@ export interface ConfigComplete {
|
|
|
157
166
|
wasmAsAsset?: boolean;
|
|
158
167
|
};
|
|
159
168
|
styles?: {
|
|
169
|
+
autoCssModules?: boolean;
|
|
170
|
+
emotion?: boolean;
|
|
160
171
|
less?: {
|
|
161
172
|
implementation?: string;
|
|
162
173
|
[key: string]: any;
|
|
@@ -185,12 +196,7 @@ export interface ConfigComplete {
|
|
|
185
196
|
pluginRuntimeStrategy?: "workerThreads" | "childProcesses";
|
|
186
197
|
persistentCaching?: boolean;
|
|
187
198
|
nodePolyfill?: boolean;
|
|
188
|
-
devServer?:
|
|
189
|
-
hot?: boolean;
|
|
190
|
-
port?: number;
|
|
191
|
-
host?: string;
|
|
192
|
-
https?: boolean;
|
|
193
|
-
};
|
|
199
|
+
devServer?: DevServerConfig;
|
|
194
200
|
cacheHandler?: string;
|
|
195
201
|
experimental?: ExperimentalConfig;
|
|
196
202
|
}
|
|
@@ -233,7 +239,6 @@ export interface BundleOptions {
|
|
|
233
239
|
* A map of environment variables to use when compiling code.
|
|
234
240
|
*/
|
|
235
241
|
processEnv?: Record<string, string>;
|
|
236
|
-
defineEnv?: DefineEnv;
|
|
237
242
|
/**
|
|
238
243
|
* Whether to watch the filesystem for file changes.
|
|
239
244
|
*/
|
|
@@ -259,7 +264,7 @@ export interface BundleOptions {
|
|
|
259
264
|
* Bundler options (entry, output, define, ...) at top level,
|
|
260
265
|
* plus optional CLI/runtime options (processEnv, watch, dev, ...).
|
|
261
266
|
*/
|
|
262
|
-
export type UserConfig = ConfigComplete & Partial<Pick<BundleOptions, "processEnv" | "
|
|
267
|
+
export type UserConfig = ConfigComplete & Partial<Pick<BundleOptions, "processEnv" | "watch" | "dev" | "buildId" | "packPath">> & {
|
|
263
268
|
rootPath?: string;
|
|
264
269
|
projectPath?: string;
|
|
265
270
|
};
|
package/esm/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RustifiedEnv } from "./config";
|
|
2
2
|
import { Issue } from "./issue";
|
|
3
3
|
export declare class ModuleBuildError extends Error {
|
|
4
4
|
name: string;
|
|
@@ -9,12 +9,6 @@ export interface ResultWithIssues {
|
|
|
9
9
|
export declare function processIssues(result: ResultWithIssues, throwIssue: boolean, logErrors: boolean): void;
|
|
10
10
|
export declare function isWellKnownError(issue: Issue): boolean;
|
|
11
11
|
export declare function rustifyEnv(env: Record<string, string>): RustifiedEnv;
|
|
12
|
-
interface DefineEnvOptions {
|
|
13
|
-
config: ConfigComplete;
|
|
14
|
-
dev: boolean;
|
|
15
|
-
optionDefineEnv?: DefineEnv;
|
|
16
|
-
}
|
|
17
|
-
export declare function createDefineEnv(options: DefineEnvOptions): DefineEnv;
|
|
18
12
|
type AnyFunc<T> = (this: T, ...args: any) => any;
|
|
19
13
|
export declare function debounce<T, F extends AnyFunc<T>>(fn: F, ms: number, maxWait?: number): (this: T, ...passedArgs: Parameters<F>) => void;
|
|
20
14
|
export {};
|
package/esm/utils.js
CHANGED
|
@@ -47,36 +47,6 @@ export function rustifyEnv(env) {
|
|
|
47
47
|
value,
|
|
48
48
|
}));
|
|
49
49
|
}
|
|
50
|
-
export function createDefineEnv(options) {
|
|
51
|
-
var _a;
|
|
52
|
-
let defineEnv = (_a = options.optionDefineEnv) !== null && _a !== void 0 ? _a : {
|
|
53
|
-
client: [],
|
|
54
|
-
edge: [],
|
|
55
|
-
nodejs: [],
|
|
56
|
-
};
|
|
57
|
-
function getDefineEnv() {
|
|
58
|
-
var _a;
|
|
59
|
-
const envs = {
|
|
60
|
-
"process.env.NODE_ENV": options.dev ? "development" : "production",
|
|
61
|
-
};
|
|
62
|
-
const userDefines = (_a = options.config.define) !== null && _a !== void 0 ? _a : {};
|
|
63
|
-
for (const key in userDefines) {
|
|
64
|
-
envs[key] = userDefines[key];
|
|
65
|
-
}
|
|
66
|
-
// serialize
|
|
67
|
-
const defineEnvStringified = {};
|
|
68
|
-
for (const key in defineEnv) {
|
|
69
|
-
const value = envs[key];
|
|
70
|
-
defineEnvStringified[key] = JSON.stringify(value);
|
|
71
|
-
}
|
|
72
|
-
return defineEnvStringified;
|
|
73
|
-
}
|
|
74
|
-
// TODO: future define envs need to extends for more compiler like server or edge.
|
|
75
|
-
for (const variant of Object.keys(defineEnv)) {
|
|
76
|
-
defineEnv[variant] = rustifyEnv(getDefineEnv());
|
|
77
|
-
}
|
|
78
|
-
return defineEnv;
|
|
79
|
-
}
|
|
80
50
|
export function debounce(fn, ms, maxWait = Infinity) {
|
|
81
51
|
let timeoutId;
|
|
82
52
|
// The time the debouncing function was first called during this debounce queue.
|
package/esm/webpackCompat.js
CHANGED
|
@@ -466,6 +466,7 @@ function compatOptimization(webpackOptimization) {
|
|
|
466
466
|
return;
|
|
467
467
|
}
|
|
468
468
|
const { moduleIds, minimize, concatenateModules, usedExports } = webpackOptimization;
|
|
469
|
+
const enableWebpackUsedExports = usedExports !== false;
|
|
469
470
|
return {
|
|
470
471
|
moduleIds: moduleIds === "named"
|
|
471
472
|
? "named"
|
|
@@ -475,9 +476,9 @@ function compatOptimization(webpackOptimization) {
|
|
|
475
476
|
noMangling: webpackOptimization.mangleExports === false,
|
|
476
477
|
minify: minimize,
|
|
477
478
|
concatenateModules,
|
|
478
|
-
treeShaking:
|
|
479
|
-
removeUnusedExports:
|
|
480
|
-
removeUnusedImports:
|
|
479
|
+
treeShaking: false,
|
|
480
|
+
removeUnusedExports: enableWebpackUsedExports,
|
|
481
|
+
removeUnusedImports: enableWebpackUsedExports,
|
|
481
482
|
};
|
|
482
483
|
}
|
|
483
484
|
function compatStats(webpackStats) {
|