@unpackjs/plugin-react 1.5.4 → 1.6.0
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/dist/click-to-component/index.cjs +3 -3
- package/dist/click-to-component/index.d.ts +1 -1
- package/dist/click-to-component/index.d.ts.map +1 -1
- package/dist/click-to-component/index.js +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/mpa.cjs +7 -7
- package/dist/mpa.d.ts +1 -1
- package/dist/mpa.d.ts.map +1 -1
- package/dist/mpa.js +1 -1
- package/package.json +3 -3
|
@@ -33,7 +33,7 @@ module.exports = __toCommonJS(click_to_component_exports);
|
|
|
33
33
|
var import_node_fs = __toESM(require("node:fs"));
|
|
34
34
|
var import_node_http = __toESM(require("node:http"));
|
|
35
35
|
var import_node_path = __toESM(require("node:path"));
|
|
36
|
-
var
|
|
36
|
+
var import_core = require("@unpackjs/core");
|
|
37
37
|
var import_launch_editor = __toESM(require("launch-editor"));
|
|
38
38
|
function createServer() {
|
|
39
39
|
return new Promise((resolve) => {
|
|
@@ -51,7 +51,7 @@ function createServer() {
|
|
|
51
51
|
res.end("ok");
|
|
52
52
|
(0, import_launch_editor.default)(`${file}:${line}:${column}`);
|
|
53
53
|
});
|
|
54
|
-
(0,
|
|
54
|
+
(0, import_core.getPort)(3100).then((port) => {
|
|
55
55
|
server.listen(port, () => {
|
|
56
56
|
resolve({
|
|
57
57
|
port
|
|
@@ -64,7 +64,7 @@ const addClickToComponentSupport = async ({
|
|
|
64
64
|
config,
|
|
65
65
|
bundler
|
|
66
66
|
}) => {
|
|
67
|
-
if (!(0,
|
|
67
|
+
if (!(0, import_core.isDev)())
|
|
68
68
|
return config;
|
|
69
69
|
const { port } = await createServer();
|
|
70
70
|
const injectScript = import_node_fs.default.readFileSync(import_node_path.default.resolve(__dirname, "./injectScript.js"), "utf-8");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/click-to-component/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,oBAAoB,EAAkB,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/click-to-component/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,oBAAoB,EAAkB,MAAM,gBAAgB,CAAA;AA4B1E,eAAO,MAAM,0BAA0B,yBAGpC;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,OAAO,EAAE,GAAG,CAAA;CACb,KAAG,OAAO,CAAC,oBAAoB,CAoB/B,CAAA"}
|
|
@@ -10,7 +10,7 @@ var __filename = /* @__PURE__ */ getFilename();
|
|
|
10
10
|
import fs from "node:fs";
|
|
11
11
|
import http from "node:http";
|
|
12
12
|
import path2 from "node:path";
|
|
13
|
-
import { getPort, isDev } from "@unpackjs/
|
|
13
|
+
import { getPort, isDev } from "@unpackjs/core";
|
|
14
14
|
import launchEditor from "launch-editor";
|
|
15
15
|
function createServer() {
|
|
16
16
|
return new Promise((resolve) => {
|
package/dist/index.cjs
CHANGED
|
@@ -34,7 +34,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
34
34
|
var import_node_path = __toESM(require("node:path"));
|
|
35
35
|
var import_react_refresh_webpack_plugin = __toESM(require("@pmmmwh/react-refresh-webpack-plugin"));
|
|
36
36
|
var import_plugin_react_refresh = __toESM(require("@rspack/plugin-react-refresh"));
|
|
37
|
-
var
|
|
37
|
+
var import_core = require("@unpackjs/core");
|
|
38
38
|
var import_click_to_component = require("./click-to-component/index.cjs");
|
|
39
39
|
var import_mpa = require("./mpa.cjs");
|
|
40
40
|
const PLUGIN_NAME = "unpack:react";
|
|
@@ -63,12 +63,12 @@ const pluginReact = (options = {}) => {
|
|
|
63
63
|
transform: {
|
|
64
64
|
react: {
|
|
65
65
|
runtime: "automatic",
|
|
66
|
-
refresh: (0,
|
|
66
|
+
refresh: (0, import_core.isDevServer)()
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
70
|
env: {
|
|
71
|
-
targets:
|
|
71
|
+
targets: import_core.DEFAULT_BROWSERSLIST
|
|
72
72
|
}
|
|
73
73
|
};
|
|
74
74
|
};
|
|
@@ -90,7 +90,7 @@ const pluginReact = (options = {}) => {
|
|
|
90
90
|
]
|
|
91
91
|
},
|
|
92
92
|
plugins: [
|
|
93
|
-
(0,
|
|
93
|
+
(0, import_core.isDevServer)() && new ReactRefreshPlugin({
|
|
94
94
|
overlay: false
|
|
95
95
|
})
|
|
96
96
|
],
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAwB,KAAK,YAAY,EAAe,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAwB,KAAK,YAAY,EAAe,MAAM,gBAAgB,CAAA;AAIrF,eAAO,MAAM,WAAW,iBAAiB,CAAA;AAEzC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AACD,eAAO,MAAM,WAAW,aAAa,kBAAkB,KAAQ,YAmE9D,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ var __filename = /* @__PURE__ */ getFilename();
|
|
|
10
10
|
import path2 from "node:path";
|
|
11
11
|
import WebpackReactRefreshPlugin from "@pmmmwh/react-refresh-webpack-plugin";
|
|
12
12
|
import RspackReactRefreshPlugin from "@rspack/plugin-react-refresh";
|
|
13
|
-
import { DEFAULT_BROWSERSLIST, isDevServer } from "@unpackjs/
|
|
13
|
+
import { DEFAULT_BROWSERSLIST, isDevServer } from "@unpackjs/core";
|
|
14
14
|
import { addClickToComponentSupport } from "./click-to-component/index.js";
|
|
15
15
|
import { addMpaSupport } from "./mpa.js";
|
|
16
16
|
const PLUGIN_NAME = "unpack:react";
|
package/dist/mpa.cjs
CHANGED
|
@@ -32,7 +32,7 @@ __export(mpa_exports, {
|
|
|
32
32
|
module.exports = __toCommonJS(mpa_exports);
|
|
33
33
|
var import_node_fs = __toESM(require("node:fs"));
|
|
34
34
|
var import_node_path = __toESM(require("node:path"));
|
|
35
|
-
var
|
|
35
|
+
var import_core = require("@unpackjs/core");
|
|
36
36
|
var import_html_webpack_plugin = __toESM(require("html-webpack-plugin"));
|
|
37
37
|
const addMpaSupport = ({
|
|
38
38
|
config,
|
|
@@ -41,8 +41,8 @@ const addMpaSupport = ({
|
|
|
41
41
|
}) => {
|
|
42
42
|
if (!unpackConfig.mpa)
|
|
43
43
|
return config;
|
|
44
|
-
const tempDirectory = import_node_path.default.join(
|
|
45
|
-
const userOptions = (0,
|
|
44
|
+
const tempDirectory = import_node_path.default.join(import_core.TEMP_DIR, "mpa");
|
|
45
|
+
const userOptions = (0, import_core.isPlainObject)(unpackConfig.mpa) ? unpackConfig.mpa : {};
|
|
46
46
|
const getPageConfig = (indexPath) => {
|
|
47
47
|
const filePath = import_node_path.default.join(indexPath, "../config.json");
|
|
48
48
|
let pageConfig = {};
|
|
@@ -124,14 +124,14 @@ ${renderer}
|
|
|
124
124
|
}
|
|
125
125
|
html2.push({
|
|
126
126
|
template: unpackConfig.html?.template || "",
|
|
127
|
-
templateContent: unpackConfig.html?.templateContent ||
|
|
127
|
+
templateContent: unpackConfig.html?.templateContent || import_core.TEMPLATE_CONTENT,
|
|
128
128
|
minify: false,
|
|
129
129
|
filename: `${entryName}.html`,
|
|
130
130
|
chunks: [entryName],
|
|
131
131
|
...pageConfig,
|
|
132
132
|
templateParameters: {
|
|
133
133
|
mountId: unpackConfig.html?.mountId,
|
|
134
|
-
title: (0,
|
|
134
|
+
title: (0, import_core.isFunction)(unpackConfig.html?.title) ? unpackConfig.html?.title({ entryName }) : unpackConfig.html?.title,
|
|
135
135
|
headTag: unpackConfig.html?.headTag,
|
|
136
136
|
...unpackConfig.html?.templateParameters,
|
|
137
137
|
...pageConfig.templateParameters
|
|
@@ -139,8 +139,8 @@ ${renderer}
|
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
141
|
});
|
|
142
|
-
!(0,
|
|
143
|
-
`Collect entries in ${(performance.now() - start).toFixed(2)}ms ${
|
|
142
|
+
!(0, import_core.isDevServer)() && import_core.logger.info(
|
|
143
|
+
`Collect entries in ${(performance.now() - start).toFixed(2)}ms ${import_core.colors.dim("[MPA]")}`
|
|
144
144
|
);
|
|
145
145
|
return { entry: entry2, html: html2 };
|
|
146
146
|
};
|
package/dist/mpa.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BundlerConfiguration, type UnpackConfig } from '@unpackjs/
|
|
1
|
+
import { type BundlerConfiguration, type UnpackConfig } from '@unpackjs/core';
|
|
2
2
|
export declare const addMpaSupport: ({ config, unpackConfig, mergeConfig, }: {
|
|
3
3
|
config: BundlerConfiguration;
|
|
4
4
|
unpackConfig: UnpackConfig;
|
package/dist/mpa.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mpa.d.ts","sourceRoot":"","sources":["../src/mpa.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,oBAAoB,EAGzB,KAAK,YAAY,EAMlB,MAAM,
|
|
1
|
+
{"version":3,"file":"mpa.d.ts","sourceRoot":"","sources":["../src/mpa.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,oBAAoB,EAGzB,KAAK,YAAY,EAMlB,MAAM,gBAAgB,CAAA;AAavB,eAAO,MAAM,aAAa,2CAIvB;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;IAC1B,WAAW,EAAE,CAAC,GAAG,OAAO,EAAE,oBAAoB,EAAE,KAAK,oBAAoB,CAAA;CAC1E,KAAG,oBAoHH,CAAA"}
|
package/dist/mpa.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unpackjs/plugin-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"@rspack/plugin-react-refresh": "1.0.0",
|
|
28
28
|
"react-refresh": "0.14.2",
|
|
29
29
|
"swc-loader": "0.2.6",
|
|
30
|
-
"@swc/core": "1.7.
|
|
30
|
+
"@swc/core": "1.7.39",
|
|
31
31
|
"@swc/helpers": "0.5.13",
|
|
32
32
|
"launch-editor": "2.9.1",
|
|
33
33
|
"html-webpack-plugin": "5.6.2",
|
|
34
|
-
"@unpackjs/
|
|
34
|
+
"@unpackjs/core": "^1.6.0"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"dev": "modern build --watch",
|