@utoo/pack 0.0.1-alpha.40 → 0.0.1-alpha.46
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/dev.js +6 -1
- package/cjs/find-root.js +2 -2
- package/cjs/types.d.ts +3 -0
- package/cjs/webpackCompat.js +2 -3
- package/config_schema.json +73 -1
- package/esm/dev.js +6 -1
- package/esm/find-root.js +2 -2
- package/esm/types.d.ts +3 -0
- package/esm/webpackCompat.js +2 -3
- package/package.json +10 -10
package/cjs/dev.js
CHANGED
|
@@ -19,6 +19,7 @@ const net_1 = require("net");
|
|
|
19
19
|
const path_1 = __importDefault(require("path"));
|
|
20
20
|
const send_1 = __importDefault(require("send"));
|
|
21
21
|
const url_1 = __importDefault(require("url"));
|
|
22
|
+
const find_root_1 = require("./find-root");
|
|
22
23
|
const hmr_1 = require("./hmr");
|
|
23
24
|
const mkcert_1 = require("./mkcert");
|
|
24
25
|
const util_1 = require("./util");
|
|
@@ -28,6 +29,10 @@ function serve(options, projectPath, rootPath, serverOptions) {
|
|
|
28
29
|
const bundleOptions = options.compatMode
|
|
29
30
|
? (0, webpackCompat_1.compatOptionsFromWebpack)(options)
|
|
30
31
|
: options;
|
|
32
|
+
if (!rootPath) {
|
|
33
|
+
// help user to find the rootDir automatically
|
|
34
|
+
rootPath = (0, find_root_1.findRootDir)(projectPath || process.cwd());
|
|
35
|
+
}
|
|
31
36
|
return serveInternal(bundleOptions, projectPath, rootPath, serverOptions);
|
|
32
37
|
}
|
|
33
38
|
async function serveInternal(options, projectPath, rootPath, serverOptions) {
|
|
@@ -35,7 +40,7 @@ async function serveInternal(options, projectPath, rootPath, serverOptions) {
|
|
|
35
40
|
if (process.env.XCODE_PROFILE) {
|
|
36
41
|
await (0, xcodeProfile_1.xcodeProfilingReady)();
|
|
37
42
|
}
|
|
38
|
-
startServer({
|
|
43
|
+
await startServer({
|
|
39
44
|
hostname: (serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.hostname) || "localhost",
|
|
40
45
|
port: (serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.port) || 3000,
|
|
41
46
|
https: serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.https,
|
package/cjs/find-root.js
CHANGED
|
@@ -21,7 +21,7 @@ function findRootLockFile(cwd) {
|
|
|
21
21
|
cwd,
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
//
|
|
24
|
+
// compatible with tnpm
|
|
25
25
|
function findPackageJson(cwd) {
|
|
26
26
|
return find_up_1.default.sync(["package.json"], {
|
|
27
27
|
cwd,
|
|
@@ -32,7 +32,7 @@ function isWorkspaceRoot(pkgPath) {
|
|
|
32
32
|
const pkgJsonContent = JSON.parse(pkgJson);
|
|
33
33
|
return Boolean(pkgJsonContent.workspaces);
|
|
34
34
|
}
|
|
35
|
-
// refer from: https://github.com/umijs/mako/blob/next/crates/
|
|
35
|
+
// refer from: https://github.com/umijs/mako/blob/next/crates/pm/src/helper/workspace.rs#L153
|
|
36
36
|
// TODO: 这块逻辑后续跟 utoo-pkg 使用一套方法
|
|
37
37
|
function findWorkspacesRoot(cwd) {
|
|
38
38
|
const pkgJson = findPackageJson(cwd);
|
package/cjs/types.d.ts
CHANGED
|
@@ -132,6 +132,9 @@ export interface ConfigComplete {
|
|
|
132
132
|
transform: string | Record<string, string>;
|
|
133
133
|
preventFullImport?: boolean;
|
|
134
134
|
skipDefaultConversion?: boolean;
|
|
135
|
+
handleDefaultImport?: boolean;
|
|
136
|
+
handleNamespaceImport?: boolean;
|
|
137
|
+
style?: string;
|
|
135
138
|
}>;
|
|
136
139
|
packageImports?: string[];
|
|
137
140
|
transpilePackages?: string[];
|
package/cjs/webpackCompat.js
CHANGED
|
@@ -332,9 +332,7 @@ function compatOptimization(webpackOptimization) {
|
|
|
332
332
|
if (!webpackOptimization) {
|
|
333
333
|
return;
|
|
334
334
|
}
|
|
335
|
-
const { moduleIds, minimize,
|
|
336
|
-
// TODO: concatenateModules to be supported, need to upgrade to next.js@15.4
|
|
337
|
-
} = webpackOptimization;
|
|
335
|
+
const { moduleIds, minimize, concatenateModules } = webpackOptimization;
|
|
338
336
|
return {
|
|
339
337
|
moduleIds: moduleIds === "named"
|
|
340
338
|
? "named"
|
|
@@ -342,6 +340,7 @@ function compatOptimization(webpackOptimization) {
|
|
|
342
340
|
? "deterministic"
|
|
343
341
|
: undefined,
|
|
344
342
|
minify: minimize,
|
|
343
|
+
concatenateModules,
|
|
345
344
|
};
|
|
346
345
|
}
|
|
347
346
|
function compatStats(webpackStats) {
|
package/config_schema.json
CHANGED
|
@@ -553,6 +553,50 @@
|
|
|
553
553
|
}
|
|
554
554
|
}
|
|
555
555
|
},
|
|
556
|
+
"SchemaModularizeImportPackageConfig": {
|
|
557
|
+
"description": "Modularize import package configuration",
|
|
558
|
+
"type": "object",
|
|
559
|
+
"required": [
|
|
560
|
+
"transform"
|
|
561
|
+
],
|
|
562
|
+
"properties": {
|
|
563
|
+
"handleDefaultImport": {
|
|
564
|
+
"description": "Handle default import",
|
|
565
|
+
"default": false,
|
|
566
|
+
"type": "boolean"
|
|
567
|
+
},
|
|
568
|
+
"handleNamespaceImport": {
|
|
569
|
+
"description": "Handle namespace import",
|
|
570
|
+
"default": false,
|
|
571
|
+
"type": "boolean"
|
|
572
|
+
},
|
|
573
|
+
"preventFullImport": {
|
|
574
|
+
"description": "Prevent full import of the package",
|
|
575
|
+
"default": false,
|
|
576
|
+
"type": "boolean"
|
|
577
|
+
},
|
|
578
|
+
"skipDefaultConversion": {
|
|
579
|
+
"description": "Skip default conversion",
|
|
580
|
+
"default": false,
|
|
581
|
+
"type": "boolean"
|
|
582
|
+
},
|
|
583
|
+
"style": {
|
|
584
|
+
"description": "Style import configuration",
|
|
585
|
+
"type": [
|
|
586
|
+
"string",
|
|
587
|
+
"null"
|
|
588
|
+
]
|
|
589
|
+
},
|
|
590
|
+
"transform": {
|
|
591
|
+
"description": "Transform configuration",
|
|
592
|
+
"allOf": [
|
|
593
|
+
{
|
|
594
|
+
"$ref": "#/definitions/SchemaTransform"
|
|
595
|
+
}
|
|
596
|
+
]
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
},
|
|
556
600
|
"SchemaModuleConfig": {
|
|
557
601
|
"description": "Module configuration",
|
|
558
602
|
"type": "object",
|
|
@@ -609,7 +653,9 @@
|
|
|
609
653
|
"object",
|
|
610
654
|
"null"
|
|
611
655
|
],
|
|
612
|
-
"additionalProperties":
|
|
656
|
+
"additionalProperties": {
|
|
657
|
+
"$ref": "#/definitions/SchemaModularizeImportPackageConfig"
|
|
658
|
+
}
|
|
613
659
|
},
|
|
614
660
|
"moduleIds": {
|
|
615
661
|
"description": "Module ID generation strategy",
|
|
@@ -856,6 +902,32 @@
|
|
|
856
902
|
"description": "Styled components configuration"
|
|
857
903
|
}
|
|
858
904
|
}
|
|
905
|
+
},
|
|
906
|
+
"SchemaTransform": {
|
|
907
|
+
"description": "Transform configuration for modularize imports",
|
|
908
|
+
"anyOf": [
|
|
909
|
+
{
|
|
910
|
+
"description": "String transform template",
|
|
911
|
+
"type": "string"
|
|
912
|
+
},
|
|
913
|
+
{
|
|
914
|
+
"description": "Vector of transformation pairs",
|
|
915
|
+
"type": "array",
|
|
916
|
+
"items": {
|
|
917
|
+
"type": "array",
|
|
918
|
+
"items": [
|
|
919
|
+
{
|
|
920
|
+
"type": "string"
|
|
921
|
+
},
|
|
922
|
+
{
|
|
923
|
+
"type": "string"
|
|
924
|
+
}
|
|
925
|
+
],
|
|
926
|
+
"maxItems": 2,
|
|
927
|
+
"minItems": 2
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
]
|
|
859
931
|
}
|
|
860
932
|
}
|
|
861
933
|
}
|
package/esm/dev.js
CHANGED
|
@@ -5,6 +5,7 @@ import { isIPv6 } from "net";
|
|
|
5
5
|
import path from "path";
|
|
6
6
|
import send from "send";
|
|
7
7
|
import url from "url";
|
|
8
|
+
import { findRootDir } from "./find-root";
|
|
8
9
|
import { createHotReloader } from "./hmr";
|
|
9
10
|
import { createSelfSignedCertificate } from "./mkcert";
|
|
10
11
|
import { blockStdout } from "./util";
|
|
@@ -14,6 +15,10 @@ export function serve(options, projectPath, rootPath, serverOptions) {
|
|
|
14
15
|
const bundleOptions = options.compatMode
|
|
15
16
|
? compatOptionsFromWebpack(options)
|
|
16
17
|
: options;
|
|
18
|
+
if (!rootPath) {
|
|
19
|
+
// help user to find the rootDir automatically
|
|
20
|
+
rootPath = findRootDir(projectPath || process.cwd());
|
|
21
|
+
}
|
|
17
22
|
return serveInternal(bundleOptions, projectPath, rootPath, serverOptions);
|
|
18
23
|
}
|
|
19
24
|
async function serveInternal(options, projectPath, rootPath, serverOptions) {
|
|
@@ -21,7 +26,7 @@ async function serveInternal(options, projectPath, rootPath, serverOptions) {
|
|
|
21
26
|
if (process.env.XCODE_PROFILE) {
|
|
22
27
|
await xcodeProfilingReady();
|
|
23
28
|
}
|
|
24
|
-
startServer({
|
|
29
|
+
await startServer({
|
|
25
30
|
hostname: (serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.hostname) || "localhost",
|
|
26
31
|
port: (serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.port) || 3000,
|
|
27
32
|
https: serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.https,
|
package/esm/find-root.js
CHANGED
|
@@ -12,7 +12,7 @@ export function findRootLockFile(cwd) {
|
|
|
12
12
|
cwd,
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
|
-
//
|
|
15
|
+
// compatible with tnpm
|
|
16
16
|
export function findPackageJson(cwd) {
|
|
17
17
|
return findUp.sync(["package.json"], {
|
|
18
18
|
cwd,
|
|
@@ -23,7 +23,7 @@ function isWorkspaceRoot(pkgPath) {
|
|
|
23
23
|
const pkgJsonContent = JSON.parse(pkgJson);
|
|
24
24
|
return Boolean(pkgJsonContent.workspaces);
|
|
25
25
|
}
|
|
26
|
-
// refer from: https://github.com/umijs/mako/blob/next/crates/
|
|
26
|
+
// refer from: https://github.com/umijs/mako/blob/next/crates/pm/src/helper/workspace.rs#L153
|
|
27
27
|
// TODO: 这块逻辑后续跟 utoo-pkg 使用一套方法
|
|
28
28
|
export function findWorkspacesRoot(cwd) {
|
|
29
29
|
const pkgJson = findPackageJson(cwd);
|
package/esm/types.d.ts
CHANGED
|
@@ -132,6 +132,9 @@ export interface ConfigComplete {
|
|
|
132
132
|
transform: string | Record<string, string>;
|
|
133
133
|
preventFullImport?: boolean;
|
|
134
134
|
skipDefaultConversion?: boolean;
|
|
135
|
+
handleDefaultImport?: boolean;
|
|
136
|
+
handleNamespaceImport?: boolean;
|
|
137
|
+
style?: string;
|
|
135
138
|
}>;
|
|
136
139
|
packageImports?: string[];
|
|
137
140
|
transpilePackages?: string[];
|
package/esm/webpackCompat.js
CHANGED
|
@@ -329,9 +329,7 @@ function compatOptimization(webpackOptimization) {
|
|
|
329
329
|
if (!webpackOptimization) {
|
|
330
330
|
return;
|
|
331
331
|
}
|
|
332
|
-
const { moduleIds, minimize,
|
|
333
|
-
// TODO: concatenateModules to be supported, need to upgrade to next.js@15.4
|
|
334
|
-
} = webpackOptimization;
|
|
332
|
+
const { moduleIds, minimize, concatenateModules } = webpackOptimization;
|
|
335
333
|
return {
|
|
336
334
|
moduleIds: moduleIds === "named"
|
|
337
335
|
? "named"
|
|
@@ -339,6 +337,7 @@ function compatOptimization(webpackOptimization) {
|
|
|
339
337
|
? "deterministic"
|
|
340
338
|
: undefined,
|
|
341
339
|
minify: minimize,
|
|
340
|
+
concatenateModules,
|
|
342
341
|
};
|
|
343
342
|
}
|
|
344
343
|
function compatStats(webpackStats) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@utoo/pack",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.46",
|
|
4
4
|
"main": "cjs/index.js",
|
|
5
5
|
"module": "esm/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"@types/webpack": "^5.28.5"
|
|
71
71
|
},
|
|
72
72
|
"engines": {
|
|
73
|
-
"node": ">=
|
|
73
|
+
"node": ">= 20"
|
|
74
74
|
},
|
|
75
75
|
"scripts": {
|
|
76
76
|
"build:cjs": "rm -rf cjs && tsc -p ./tsconfig.json --module commonjs --outDir cjs && cp src/*.d.ts cjs/",
|
|
@@ -83,14 +83,14 @@
|
|
|
83
83
|
"version": "napi version",
|
|
84
84
|
"generate-features-list": "node ./scripts/generate-feature-list.js"
|
|
85
85
|
},
|
|
86
|
-
"repository": "git@github.com:
|
|
86
|
+
"repository": "git@github.com:utooland/utoo.git",
|
|
87
87
|
"optionalDependencies": {
|
|
88
|
-
"@utoo/pack-darwin-arm64": "0.0.1-alpha.
|
|
89
|
-
"@utoo/pack-darwin-x64": "0.0.1-alpha.
|
|
90
|
-
"@utoo/pack-linux-arm64-gnu": "0.0.1-alpha.
|
|
91
|
-
"@utoo/pack-linux-arm64-musl": "0.0.1-alpha.
|
|
92
|
-
"@utoo/pack-linux-x64-gnu": "0.0.1-alpha.
|
|
93
|
-
"@utoo/pack-linux-x64-musl": "0.0.1-alpha.
|
|
94
|
-
"@utoo/pack-win32-x64-msvc": "0.0.1-alpha.
|
|
88
|
+
"@utoo/pack-darwin-arm64": "0.0.1-alpha.46",
|
|
89
|
+
"@utoo/pack-darwin-x64": "0.0.1-alpha.46",
|
|
90
|
+
"@utoo/pack-linux-arm64-gnu": "0.0.1-alpha.46",
|
|
91
|
+
"@utoo/pack-linux-arm64-musl": "0.0.1-alpha.46",
|
|
92
|
+
"@utoo/pack-linux-x64-gnu": "0.0.1-alpha.46",
|
|
93
|
+
"@utoo/pack-linux-x64-musl": "0.0.1-alpha.46",
|
|
94
|
+
"@utoo/pack-win32-x64-msvc": "0.0.1-alpha.46"
|
|
95
95
|
}
|
|
96
96
|
}
|