@utoo/pack 1.2.8-alpha.0 → 1.2.8-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.
- package/README.md +32 -30
- package/cjs/commands/build.js +5 -5
- package/cjs/core/hmr.js +2 -2
- package/cjs/plugins/HtmlPlugin.js +2 -1
- package/cjs/utils/htmlEntry.js +2 -0
- package/esm/commands/build.js +5 -5
- package/esm/core/hmr.js +2 -2
- package/esm/plugins/HtmlPlugin.js +2 -1
- package/esm/utils/htmlEntry.js +2 -0
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -46,44 +46,46 @@ const { build, dev } = require('@utoo/pack');
|
|
|
46
46
|
// Production build
|
|
47
47
|
async function runBuild() {
|
|
48
48
|
await build({
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
config: {
|
|
50
|
+
entry: [
|
|
51
|
+
{
|
|
52
|
+
import: "./src/index.ts",
|
|
53
|
+
html: {
|
|
54
|
+
template: "./index.html"
|
|
55
|
+
}
|
|
55
56
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
],
|
|
58
|
+
output: {
|
|
59
|
+
path: "./dist",
|
|
60
|
+
filename: "[name].[contenthash:8].js",
|
|
61
|
+
chunkFilename: "[name].[contenthash:8].js",
|
|
62
|
+
clean: true
|
|
63
|
+
},
|
|
64
|
+
sourceMaps: true
|
|
65
|
+
}
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
// Development mode with HMR
|
|
69
70
|
async function startDev() {
|
|
70
71
|
const server = await dev({
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
config: {
|
|
73
|
+
entry: [
|
|
74
|
+
{
|
|
75
|
+
import: "./src/index.ts",
|
|
76
|
+
html: {
|
|
77
|
+
template: "./index.html"
|
|
78
|
+
}
|
|
77
79
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
80
|
+
],
|
|
81
|
+
output: {
|
|
82
|
+
path: "./dist",
|
|
83
|
+
filename: "[name].[contenthash:8].js",
|
|
84
|
+
chunkFilename: "[name].[contenthash:8].js",
|
|
85
|
+
clean: true
|
|
86
|
+
},
|
|
87
|
+
sourceMaps: true
|
|
88
|
+
}
|
|
87
89
|
});
|
|
88
90
|
}
|
|
89
91
|
```
|
package/cjs/commands/build.js
CHANGED
|
@@ -27,7 +27,7 @@ function build(options, projectPath, rootPath) {
|
|
|
27
27
|
return buildInternal(bundleOptions, projectPath, rootPath);
|
|
28
28
|
}
|
|
29
29
|
async function buildInternal(bundleOptions, projectPath, rootPath) {
|
|
30
|
-
var _a, _b, _c, _d, _e, _f;
|
|
30
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
31
31
|
(0, common_1.blockStdout)();
|
|
32
32
|
if (process.env.XCODE_PROFILE) {
|
|
33
33
|
await (0, xcodeProfile_1.xcodeProfilingReady)();
|
|
@@ -58,7 +58,7 @@ async function buildInternal(bundleOptions, projectPath, rootPath) {
|
|
|
58
58
|
rootPath: rootPath || projectPath || process.cwd(),
|
|
59
59
|
packPath: (0, common_1.getPackPath)(),
|
|
60
60
|
}, {
|
|
61
|
-
persistentCaching: false,
|
|
61
|
+
persistentCaching: (_d = bundleOptions.config.persistentCaching) !== null && _d !== void 0 ? _d : false,
|
|
62
62
|
});
|
|
63
63
|
const entrypoints = await project.writeAllEntrypointsToDisk();
|
|
64
64
|
(0, pack_shared_1.handleIssues)(entrypoints.issues);
|
|
@@ -74,20 +74,20 @@ async function buildInternal(bundleOptions, projectPath, rootPath) {
|
|
|
74
74
|
];
|
|
75
75
|
if (htmlConfigs.length > 0) {
|
|
76
76
|
const assets = { js: [], css: [] };
|
|
77
|
-
const outputDir = ((
|
|
77
|
+
const outputDir = ((_e = bundleOptions.config.output) === null || _e === void 0 ? void 0 : _e.path) || path_1.default.join(process.cwd(), "dist");
|
|
78
78
|
if (assets.js.length === 0 && assets.css.length === 0) {
|
|
79
79
|
const discovered = (0, getInitialAssets_1.getInitialAssetsFromStats)(outputDir);
|
|
80
80
|
assets.js.push(...discovered.js);
|
|
81
81
|
assets.css.push(...discovered.css);
|
|
82
82
|
}
|
|
83
|
-
const publicPath = (
|
|
83
|
+
const publicPath = (_f = bundleOptions.config.output) === null || _f === void 0 ? void 0 : _f.publicPath;
|
|
84
84
|
for (const config of htmlConfigs) {
|
|
85
85
|
const plugin = new HtmlPlugin_1.HtmlPlugin(config);
|
|
86
86
|
await plugin.generate(outputDir, assets, publicPath);
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
if (process.env.ANALYZE) {
|
|
90
|
-
await analyzeBundle(((
|
|
90
|
+
await analyzeBundle(((_g = bundleOptions.config.output) === null || _g === void 0 ? void 0 : _g.path) || "dist");
|
|
91
91
|
}
|
|
92
92
|
await project.shutdown();
|
|
93
93
|
// TODO: Maybe run tasks in worker is a better way, see
|
package/cjs/core/hmr.js
CHANGED
|
@@ -22,7 +22,7 @@ var pack_shared_2 = require("@utoo/pack-shared");
|
|
|
22
22
|
Object.defineProperty(exports, "HMR_ACTIONS_SENT_TO_BROWSER", { enumerable: true, get: function () { return pack_shared_2.HMR_ACTIONS_SENT_TO_BROWSER; } });
|
|
23
23
|
exports.FAST_REFRESH_RUNTIME_RELOAD = "Fast Refresh had to perform a full reload due to a runtime error.";
|
|
24
24
|
async function createHotReloader(bundleOptions, projectPath, rootPath) {
|
|
25
|
-
var _a;
|
|
25
|
+
var _a, _b;
|
|
26
26
|
const resolvedProjectPath = projectPath || process.cwd();
|
|
27
27
|
(0, htmlEntry_1.processHtmlEntry)(bundleOptions.config, resolvedProjectPath);
|
|
28
28
|
(0, validateEntry_1.validateEntryPaths)(bundleOptions.config, resolvedProjectPath);
|
|
@@ -55,7 +55,7 @@ async function createHotReloader(bundleOptions, projectPath, rootPath) {
|
|
|
55
55
|
rootPath: rootPath || projectPath || process.cwd(),
|
|
56
56
|
packPath: (0, common_1.getPackPath)(),
|
|
57
57
|
}, {
|
|
58
|
-
persistentCaching:
|
|
58
|
+
persistentCaching: (_b = bundleOptions.config.persistentCaching) !== null && _b !== void 0 ? _b : false,
|
|
59
59
|
});
|
|
60
60
|
const entrypointsSubscription = project.entrypointsSubscribe();
|
|
61
61
|
let currentEntriesHandlingResolve;
|
|
@@ -12,6 +12,7 @@ class HtmlPlugin {
|
|
|
12
12
|
this.config = config;
|
|
13
13
|
}
|
|
14
14
|
async generate(outputDir, assets, globalPublicPath) {
|
|
15
|
+
var _a, _b;
|
|
15
16
|
const templatePath = this.config.template
|
|
16
17
|
? path_1.default.resolve(process.cwd(), this.config.template)
|
|
17
18
|
: undefined;
|
|
@@ -110,7 +111,7 @@ class HtmlPlugin {
|
|
|
110
111
|
});
|
|
111
112
|
const finalHtml = doc.outerHTML;
|
|
112
113
|
const filename = this.config.filename || "index.html";
|
|
113
|
-
fs_1.default.writeFileSync(path_1.default.join(outputDir, filename), finalHtml);
|
|
114
|
+
fs_1.default.writeFileSync(path_1.default.join((_b = (_a = this.config.output) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : outputDir, filename), finalHtml);
|
|
114
115
|
}
|
|
115
116
|
}
|
|
116
117
|
exports.HtmlPlugin = HtmlPlugin;
|
package/cjs/utils/htmlEntry.js
CHANGED
|
@@ -32,8 +32,10 @@ function processHtmlEntry(config, projectPath) {
|
|
|
32
32
|
script.parentNode.removeChild(script);
|
|
33
33
|
}
|
|
34
34
|
newEntries.push({
|
|
35
|
+
...entry,
|
|
35
36
|
import: scriptPath,
|
|
36
37
|
html: {
|
|
38
|
+
...entry.html,
|
|
37
39
|
template: entry.import,
|
|
38
40
|
templateContent: doc.outerHTML,
|
|
39
41
|
filename: path_1.default.basename(entry.import),
|
package/esm/commands/build.js
CHANGED
|
@@ -21,7 +21,7 @@ export function build(options, projectPath, rootPath) {
|
|
|
21
21
|
return buildInternal(bundleOptions, projectPath, rootPath);
|
|
22
22
|
}
|
|
23
23
|
async function buildInternal(bundleOptions, projectPath, rootPath) {
|
|
24
|
-
var _a, _b, _c, _d, _e, _f;
|
|
24
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
25
25
|
blockStdout();
|
|
26
26
|
if (process.env.XCODE_PROFILE) {
|
|
27
27
|
await xcodeProfilingReady();
|
|
@@ -52,7 +52,7 @@ async function buildInternal(bundleOptions, projectPath, rootPath) {
|
|
|
52
52
|
rootPath: rootPath || projectPath || process.cwd(),
|
|
53
53
|
packPath: getPackPath(),
|
|
54
54
|
}, {
|
|
55
|
-
persistentCaching: false,
|
|
55
|
+
persistentCaching: (_d = bundleOptions.config.persistentCaching) !== null && _d !== void 0 ? _d : false,
|
|
56
56
|
});
|
|
57
57
|
const entrypoints = await project.writeAllEntrypointsToDisk();
|
|
58
58
|
handleIssues(entrypoints.issues);
|
|
@@ -68,20 +68,20 @@ async function buildInternal(bundleOptions, projectPath, rootPath) {
|
|
|
68
68
|
];
|
|
69
69
|
if (htmlConfigs.length > 0) {
|
|
70
70
|
const assets = { js: [], css: [] };
|
|
71
|
-
const outputDir = ((
|
|
71
|
+
const outputDir = ((_e = bundleOptions.config.output) === null || _e === void 0 ? void 0 : _e.path) || path.join(process.cwd(), "dist");
|
|
72
72
|
if (assets.js.length === 0 && assets.css.length === 0) {
|
|
73
73
|
const discovered = getInitialAssetsFromStats(outputDir);
|
|
74
74
|
assets.js.push(...discovered.js);
|
|
75
75
|
assets.css.push(...discovered.css);
|
|
76
76
|
}
|
|
77
|
-
const publicPath = (
|
|
77
|
+
const publicPath = (_f = bundleOptions.config.output) === null || _f === void 0 ? void 0 : _f.publicPath;
|
|
78
78
|
for (const config of htmlConfigs) {
|
|
79
79
|
const plugin = new HtmlPlugin(config);
|
|
80
80
|
await plugin.generate(outputDir, assets, publicPath);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
if (process.env.ANALYZE) {
|
|
84
|
-
await analyzeBundle(((
|
|
84
|
+
await analyzeBundle(((_g = bundleOptions.config.output) === null || _g === void 0 ? void 0 : _g.path) || "dist");
|
|
85
85
|
}
|
|
86
86
|
await project.shutdown();
|
|
87
87
|
// TODO: Maybe run tasks in worker is a better way, see
|
package/esm/core/hmr.js
CHANGED
|
@@ -14,7 +14,7 @@ const sessionId = Math.floor(Number.MAX_SAFE_INTEGER * Math.random());
|
|
|
14
14
|
export { HMR_ACTIONS_SENT_TO_BROWSER, } from "@utoo/pack-shared";
|
|
15
15
|
export const FAST_REFRESH_RUNTIME_RELOAD = "Fast Refresh had to perform a full reload due to a runtime error.";
|
|
16
16
|
export async function createHotReloader(bundleOptions, projectPath, rootPath) {
|
|
17
|
-
var _a;
|
|
17
|
+
var _a, _b;
|
|
18
18
|
const resolvedProjectPath = projectPath || process.cwd();
|
|
19
19
|
processHtmlEntry(bundleOptions.config, resolvedProjectPath);
|
|
20
20
|
validateEntryPaths(bundleOptions.config, resolvedProjectPath);
|
|
@@ -47,7 +47,7 @@ export async function createHotReloader(bundleOptions, projectPath, rootPath) {
|
|
|
47
47
|
rootPath: rootPath || projectPath || process.cwd(),
|
|
48
48
|
packPath: getPackPath(),
|
|
49
49
|
}, {
|
|
50
|
-
persistentCaching:
|
|
50
|
+
persistentCaching: (_b = bundleOptions.config.persistentCaching) !== null && _b !== void 0 ? _b : false,
|
|
51
51
|
});
|
|
52
52
|
const entrypointsSubscription = project.entrypointsSubscribe();
|
|
53
53
|
let currentEntriesHandlingResolve;
|
|
@@ -6,6 +6,7 @@ export class HtmlPlugin {
|
|
|
6
6
|
this.config = config;
|
|
7
7
|
}
|
|
8
8
|
async generate(outputDir, assets, globalPublicPath) {
|
|
9
|
+
var _a, _b;
|
|
9
10
|
const templatePath = this.config.template
|
|
10
11
|
? path.resolve(process.cwd(), this.config.template)
|
|
11
12
|
: undefined;
|
|
@@ -104,6 +105,6 @@ export class HtmlPlugin {
|
|
|
104
105
|
});
|
|
105
106
|
const finalHtml = doc.outerHTML;
|
|
106
107
|
const filename = this.config.filename || "index.html";
|
|
107
|
-
fs.writeFileSync(path.join(outputDir, filename), finalHtml);
|
|
108
|
+
fs.writeFileSync(path.join((_b = (_a = this.config.output) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : outputDir, filename), finalHtml);
|
|
108
109
|
}
|
|
109
110
|
}
|
package/esm/utils/htmlEntry.js
CHANGED
|
@@ -26,8 +26,10 @@ export function processHtmlEntry(config, projectPath) {
|
|
|
26
26
|
script.parentNode.removeChild(script);
|
|
27
27
|
}
|
|
28
28
|
newEntries.push({
|
|
29
|
+
...entry,
|
|
29
30
|
import: scriptPath,
|
|
30
31
|
html: {
|
|
32
|
+
...entry.html,
|
|
31
33
|
template: entry.import,
|
|
32
34
|
templateContent: doc.outerHTML,
|
|
33
35
|
filename: path.basename(entry.import),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@utoo/pack",
|
|
3
|
-
"version": "1.2.8-alpha.
|
|
3
|
+
"version": "1.2.8-alpha.2",
|
|
4
4
|
"main": "cjs/index.js",
|
|
5
5
|
"module": "esm/index.js",
|
|
6
6
|
"types": "esm/index.d.ts",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@babel/code-frame": "7.22.5",
|
|
41
41
|
"@swc/helpers": "0.5.15",
|
|
42
|
-
"@utoo/pack-shared": "1.2.8-alpha.
|
|
42
|
+
"@utoo/pack-shared": "1.2.8-alpha.2",
|
|
43
43
|
"@utoo/style-loader": "^1.0.0",
|
|
44
|
-
"domparser-rs": "^0.0.
|
|
44
|
+
"domparser-rs": "^0.0.7",
|
|
45
45
|
"find-up": "4.1.0",
|
|
46
46
|
"nanoid": "^3.3.11",
|
|
47
47
|
"picocolors": "^1.1.1",
|
|
@@ -86,12 +86,12 @@
|
|
|
86
86
|
},
|
|
87
87
|
"repository": "git@github.com:utooland/utoo.git",
|
|
88
88
|
"optionalDependencies": {
|
|
89
|
-
"@utoo/pack-darwin-arm64": "1.2.8-alpha.
|
|
90
|
-
"@utoo/pack-darwin-x64": "1.2.8-alpha.
|
|
91
|
-
"@utoo/pack-linux-arm64-gnu": "1.2.8-alpha.
|
|
92
|
-
"@utoo/pack-linux-arm64-musl": "1.2.8-alpha.
|
|
93
|
-
"@utoo/pack-linux-x64-gnu": "1.2.8-alpha.
|
|
94
|
-
"@utoo/pack-linux-x64-musl": "1.2.8-alpha.
|
|
95
|
-
"@utoo/pack-win32-x64-msvc": "1.2.8-alpha.
|
|
89
|
+
"@utoo/pack-darwin-arm64": "1.2.8-alpha.2",
|
|
90
|
+
"@utoo/pack-darwin-x64": "1.2.8-alpha.2",
|
|
91
|
+
"@utoo/pack-linux-arm64-gnu": "1.2.8-alpha.2",
|
|
92
|
+
"@utoo/pack-linux-arm64-musl": "1.2.8-alpha.2",
|
|
93
|
+
"@utoo/pack-linux-x64-gnu": "1.2.8-alpha.2",
|
|
94
|
+
"@utoo/pack-linux-x64-musl": "1.2.8-alpha.2",
|
|
95
|
+
"@utoo/pack-win32-x64-msvc": "1.2.8-alpha.2"
|
|
96
96
|
}
|
|
97
97
|
}
|