@unpackjs/plugin-react 3.1.2 → 3.2.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/index.cjs +55 -59
- package/dist/index.js +49 -54
- package/dist/injectScript.js +5 -3
- package/dist-types/click-to-component/index.d.ts.map +1 -1
- package/package.json +4 -3
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
const __rslib_import_meta_url__ = 'undefined' == typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
3
3
|
var __webpack_require__ = {};
|
|
4
4
|
__webpack_require__.n = (module)=>{
|
|
5
5
|
var getter = module && module.__esModule ? ()=>module.default : ()=>module;
|
|
@@ -23,15 +23,17 @@ __webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_expo
|
|
|
23
23
|
pluginReact: ()=>pluginReact,
|
|
24
24
|
PLUGIN_NAME: ()=>PLUGIN_NAME
|
|
25
25
|
});
|
|
26
|
-
|
|
26
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
27
27
|
var external_node_path_default = __webpack_require__.n(external_node_path_namespaceObject);
|
|
28
|
-
|
|
28
|
+
const plugin_react_refresh_namespaceObject = require("@rspack/plugin-react-refresh");
|
|
29
29
|
var plugin_react_refresh_default = __webpack_require__.n(plugin_react_refresh_namespaceObject);
|
|
30
|
-
|
|
30
|
+
const core_namespaceObject = require("@unpackjs/core"), external_node_fs_namespaceObject = require("node:fs");
|
|
31
31
|
var external_node_fs_default = __webpack_require__.n(external_node_fs_namespaceObject);
|
|
32
|
-
|
|
32
|
+
const external_node_http_namespaceObject = require("node:http");
|
|
33
33
|
var external_node_http_default = __webpack_require__.n(external_node_http_namespaceObject);
|
|
34
|
-
|
|
34
|
+
const external_launch_editor_namespaceObject = require("launch-editor");
|
|
35
|
+
var external_launch_editor_default = __webpack_require__.n(external_launch_editor_namespaceObject);
|
|
36
|
+
const createServer = ()=>new Promise((resolve)=>{
|
|
35
37
|
let server = external_node_http_default().createServer((req, res)=>{
|
|
36
38
|
let params = new URLSearchParams(req.url.slice(1)), file = decodeURIComponent(params.get('file')), line = Number(params.get('line')), column = Number(params.get('column'));
|
|
37
39
|
res.writeHead(200, {
|
|
@@ -39,7 +41,7 @@ let createServer = ()=>new Promise((resolve)=>{
|
|
|
39
41
|
'Access-Control-Allow-Methods': '*',
|
|
40
42
|
'Access-Control-Allow-Headers': '*',
|
|
41
43
|
'Access-Control-Allow-Private-Network': 'true'
|
|
42
|
-
}), res.end('ok'), (
|
|
44
|
+
}), res.end('ok'), external_launch_editor_default()(`${file}:${line}:${column}`);
|
|
43
45
|
});
|
|
44
46
|
(0, core_namespaceObject.getPort)().then((port)=>{
|
|
45
47
|
server.listen(port, ()=>{
|
|
@@ -47,7 +49,7 @@ let createServer = ()=>new Promise((resolve)=>{
|
|
|
47
49
|
port
|
|
48
50
|
});
|
|
49
51
|
});
|
|
50
|
-
}), core_namespaceObject.
|
|
52
|
+
}), (0, core_namespaceObject.addRestartCleaner)(()=>new Promise((resolve)=>server.close(()=>resolve())));
|
|
51
53
|
}), applyClickToComponentConfig = async ({ config, unpackConfig })=>{
|
|
52
54
|
let { port } = await createServer(), injectScript = external_node_fs_default().readFileSync(external_node_path_default().resolve(__dirname, './injectScript.js'), 'utf-8'), scriptTpl = `
|
|
53
55
|
if (!document.querySelector('#__click-to-component__')) {
|
|
@@ -74,56 +76,50 @@ import '${(0, core_namespaceObject.getPathInJs)(external_node_path_default().res
|
|
|
74
76
|
}
|
|
75
77
|
return config;
|
|
76
78
|
}, applyMpaConfig = ({ config, unpackConfig })=>{
|
|
77
|
-
let tempDirectory = external_node_path_default().join(core_namespaceObject.TEMP_DIR, 'mpa'), userOptions = (0, core_namespaceObject.isPlainObject)(unpackConfig.mpa) ? unpackConfig.mpa : {}, { entry, html } = (()=>{
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
let indexFilePath = external_node_path_default().join(dir, `index${extension}`);
|
|
87
|
-
if (external_node_fs_default().existsSync(indexFilePath)) return indexFilePath;
|
|
88
|
-
}
|
|
89
|
-
return null;
|
|
90
|
-
})(external_node_path_default().join(pagesRoot, filename));
|
|
91
|
-
if (indexFilePath) {
|
|
92
|
-
var _unpackConfig_html, _unpackConfig_html1, _unpackConfig_html2, _unpackConfig_html3, _unpackConfig_html4, _unpackConfig_html5, _unpackConfig_html6, _unpackConfig_html7, _unpackConfig_html8;
|
|
93
|
-
let pageConfig = ((indexPath)=>{
|
|
94
|
-
let filePath = external_node_path_default().join(indexPath, '../config.json'), pageConfig = {};
|
|
95
|
-
return external_node_fs_default().existsSync(filePath) && (pageConfig = JSON.parse(external_node_fs_default().readFileSync(filePath, 'utf-8'))), pageConfig;
|
|
96
|
-
})(indexFilePath), entryName = !0 === userOptions.lowerCase ? filename.toLowerCase() : filename;
|
|
97
|
-
pageConfig.filename && (entryName = pageConfig.filename.slice(0, -5)), entry[entryName] = {
|
|
98
|
-
import: [
|
|
99
|
-
indexFilePath
|
|
100
|
-
]
|
|
101
|
-
}, pageConfig.template && (pageConfig.template = external_node_path_default().join(indexFilePath, '../', pageConfig.template)), html.push({
|
|
102
|
-
template: (null == (_unpackConfig_html = unpackConfig.html) ? void 0 : _unpackConfig_html.template) || void 0,
|
|
103
|
-
templateContent: (null == (_unpackConfig_html1 = unpackConfig.html) ? void 0 : _unpackConfig_html1.templateContent) || ((null == (_unpackConfig_html2 = unpackConfig.html) ? void 0 : _unpackConfig_html2.template) ? void 0 : core_namespaceObject.TEMPLATE_CONTENT),
|
|
104
|
-
minify: !1,
|
|
105
|
-
filename: `${entryName}.html`,
|
|
106
|
-
chunks: [
|
|
107
|
-
entryName
|
|
108
|
-
],
|
|
109
|
-
...pageConfig,
|
|
110
|
-
templateParameters: {
|
|
111
|
-
mountId: null == (_unpackConfig_html3 = unpackConfig.html) ? void 0 : _unpackConfig_html3.mountId,
|
|
112
|
-
title: (0, core_namespaceObject.isFunction)(null == (_unpackConfig_html4 = unpackConfig.html) ? void 0 : _unpackConfig_html4.title) ? null == (_unpackConfig_html5 = unpackConfig.html) ? void 0 : _unpackConfig_html5.title({
|
|
113
|
-
entryName
|
|
114
|
-
}) : (null == (_unpackConfig_html6 = unpackConfig.html) ? void 0 : _unpackConfig_html6.title) || '',
|
|
115
|
-
headTag: (null == (_unpackConfig_html7 = unpackConfig.html) ? void 0 : _unpackConfig_html7.headTag) || '',
|
|
116
|
-
...null == (_unpackConfig_html8 = unpackConfig.html) ? void 0 : _unpackConfig_html8.templateParameters,
|
|
117
|
-
...pageConfig.templateParameters
|
|
118
|
-
}
|
|
119
|
-
});
|
|
79
|
+
let start, entry, html, pagesRoot, tempDirectory = external_node_path_default().join(core_namespaceObject.TEMP_DIR, 'mpa'), userOptions = (0, core_namespaceObject.isPlainObject)(unpackConfig.mpa) ? unpackConfig.mpa : {}, { entry: entry1, html: html1 } = (start = performance.now(), entry = {}, html = [], pagesRoot = external_node_path_default().join(unpackConfig.root, 'src', 'pages'), external_node_fs_default().readdirSync(pagesRoot).forEach((filename)=>{
|
|
80
|
+
if (filename.startsWith('.')) return;
|
|
81
|
+
let indexFilePath = ((dir)=>{
|
|
82
|
+
for (let extension of [
|
|
83
|
+
'.tsx',
|
|
84
|
+
'.jsx'
|
|
85
|
+
]){
|
|
86
|
+
let indexFilePath = external_node_path_default().join(dir, `index${extension}`);
|
|
87
|
+
if (external_node_fs_default().existsSync(indexFilePath)) return indexFilePath;
|
|
120
88
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
89
|
+
return null;
|
|
90
|
+
})(external_node_path_default().join(pagesRoot, filename));
|
|
91
|
+
if (indexFilePath) {
|
|
92
|
+
var _unpackConfig_html, _unpackConfig_html1, _unpackConfig_html2, _unpackConfig_html3, _unpackConfig_html4, _unpackConfig_html5, _unpackConfig_html6, _unpackConfig_html7, _unpackConfig_html8;
|
|
93
|
+
let filePath, pageConfig, pageConfig1 = (filePath = external_node_path_default().join(indexFilePath, '../config.json'), pageConfig = {}, external_node_fs_default().existsSync(filePath) && (pageConfig = JSON.parse(external_node_fs_default().readFileSync(filePath, 'utf-8'))), pageConfig), entryName = !0 === userOptions.lowerCase ? filename.toLowerCase() : filename;
|
|
94
|
+
pageConfig1.filename && (entryName = pageConfig1.filename.slice(0, -5)), entry[entryName] = {
|
|
95
|
+
import: [
|
|
96
|
+
indexFilePath
|
|
97
|
+
]
|
|
98
|
+
}, pageConfig1.template && (pageConfig1.template = external_node_path_default().join(indexFilePath, '../', pageConfig1.template)), html.push({
|
|
99
|
+
template: (null == (_unpackConfig_html = unpackConfig.html) ? void 0 : _unpackConfig_html.template) || void 0,
|
|
100
|
+
templateContent: (null == (_unpackConfig_html1 = unpackConfig.html) ? void 0 : _unpackConfig_html1.templateContent) || ((null == (_unpackConfig_html2 = unpackConfig.html) ? void 0 : _unpackConfig_html2.template) ? void 0 : core_namespaceObject.TEMPLATE_CONTENT),
|
|
101
|
+
minify: !1,
|
|
102
|
+
filename: `${entryName}.html`,
|
|
103
|
+
chunks: [
|
|
104
|
+
entryName
|
|
105
|
+
],
|
|
106
|
+
...pageConfig1,
|
|
107
|
+
templateParameters: {
|
|
108
|
+
mountId: null == (_unpackConfig_html3 = unpackConfig.html) ? void 0 : _unpackConfig_html3.mountId,
|
|
109
|
+
title: (0, core_namespaceObject.isFunction)(null == (_unpackConfig_html4 = unpackConfig.html) ? void 0 : _unpackConfig_html4.title) ? null == (_unpackConfig_html5 = unpackConfig.html) ? void 0 : _unpackConfig_html5.title({
|
|
110
|
+
entryName
|
|
111
|
+
}) : (null == (_unpackConfig_html6 = unpackConfig.html) ? void 0 : _unpackConfig_html6.title) || '',
|
|
112
|
+
headTag: (null == (_unpackConfig_html7 = unpackConfig.html) ? void 0 : _unpackConfig_html7.headTag) || '',
|
|
113
|
+
...null == (_unpackConfig_html8 = unpackConfig.html) ? void 0 : _unpackConfig_html8.templateParameters,
|
|
114
|
+
...pageConfig1.templateParameters
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}), (0, core_namespaceObject.isDevServer)() || core_namespaceObject.logger.info(`collect entries in ${(performance.now() - start).toFixed(2)}ms ${core_namespaceObject.colors.dim('[MPA]')}`), {
|
|
119
|
+
entry,
|
|
120
|
+
html
|
|
121
|
+
});
|
|
122
|
+
return (0, core_namespaceObject.mergeConfig)(config, {
|
|
127
123
|
entry: ((entry)=>{
|
|
128
124
|
var _userOptions_globalImport, _unpackConfig_html;
|
|
129
125
|
let root = unpackConfig.root;
|
|
@@ -141,8 +137,8 @@ ${renderer}
|
|
|
141
137
|
recursive: !0
|
|
142
138
|
}), external_node_fs_default().writeFileSync(filePath, tpl, 'utf-8'), entryConfig.import[0] = filePath;
|
|
143
139
|
}), entry;
|
|
144
|
-
})(
|
|
145
|
-
plugins:
|
|
140
|
+
})(entry1),
|
|
141
|
+
plugins: html1.map((h)=>new core_namespaceObject.rspack.HtmlRspackPlugin(h))
|
|
146
142
|
});
|
|
147
143
|
}, applySplitChunksConfig = ({ config })=>{
|
|
148
144
|
let currentConfig = config.optimization.splitChunks, extraGroups = {};
|
package/dist/index.js
CHANGED
|
@@ -4,9 +4,10 @@ import { fileURLToPath as __webpack_fileURLToPath__ } from "node:url";
|
|
|
4
4
|
import { dirname as __webpack_dirname__ } from "node:path";
|
|
5
5
|
import node_path from "node:path";
|
|
6
6
|
import plugin_react_refresh from "@rspack/plugin-react-refresh";
|
|
7
|
-
import { TEMPLATE_CONTENT, TEMP_DIR, colors, esVersionToBrowserslist, getPathInJs, getPort, isDev, isDevServer, isFunction, isPlainObject,
|
|
7
|
+
import { TEMPLATE_CONTENT, TEMP_DIR, addRestartCleaner, colors, esVersionToBrowserslist, getPathInJs, getPort, isDev, isDevServer, isFunction, isPlainObject, logger, mergeConfig as core_mergeConfig, removeDir, rspack } from "@unpackjs/core";
|
|
8
8
|
import node_fs from "node:fs";
|
|
9
9
|
import node_http from "node:http";
|
|
10
|
+
import launch_editor from "launch-editor";
|
|
10
11
|
var click_to_component_dirname = __webpack_dirname__(__webpack_fileURLToPath__(import.meta.url));
|
|
11
12
|
let applyClickToComponentConfig = async ({ config, unpackConfig })=>{
|
|
12
13
|
let { port } = await new Promise((resolve)=>{
|
|
@@ -17,7 +18,7 @@ let applyClickToComponentConfig = async ({ config, unpackConfig })=>{
|
|
|
17
18
|
'Access-Control-Allow-Methods': '*',
|
|
18
19
|
'Access-Control-Allow-Headers': '*',
|
|
19
20
|
'Access-Control-Allow-Private-Network': 'true'
|
|
20
|
-
}), res.end('ok'),
|
|
21
|
+
}), res.end('ok'), launch_editor(`${file}:${line}:${column}`);
|
|
21
22
|
});
|
|
22
23
|
getPort().then((port)=>{
|
|
23
24
|
server.listen(port, ()=>{
|
|
@@ -25,7 +26,7 @@ let applyClickToComponentConfig = async ({ config, unpackConfig })=>{
|
|
|
25
26
|
port
|
|
26
27
|
});
|
|
27
28
|
});
|
|
28
|
-
}),
|
|
29
|
+
}), addRestartCleaner(()=>new Promise((resolve)=>server.close(()=>resolve())));
|
|
29
30
|
}), injectScript = node_fs.readFileSync(node_path.resolve(click_to_component_dirname, './injectScript.js'), 'utf-8'), scriptTpl = `
|
|
30
31
|
if (!document.querySelector('#__click-to-component__')) {
|
|
31
32
|
const script = document.createElement('script')
|
|
@@ -58,56 +59,50 @@ import '${getPathInJs(node_path.resolve(Object.values(config.entry)[0]))}'
|
|
|
58
59
|
var _unpackConfig_performance_chunkSplit, _unpackConfig_performance;
|
|
59
60
|
let config = originalConfig;
|
|
60
61
|
unpackConfig.mpa && (config = (({ config, unpackConfig })=>{
|
|
61
|
-
let tempDirectory = node_path.join(TEMP_DIR, 'mpa'), userOptions = isPlainObject(unpackConfig.mpa) ? unpackConfig.mpa : {}, { entry, html } = (()=>{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
let indexFilePath = node_path.join(dir, `index${extension}`);
|
|
71
|
-
if (node_fs.existsSync(indexFilePath)) return indexFilePath;
|
|
72
|
-
}
|
|
73
|
-
return null;
|
|
74
|
-
})(node_path.join(pagesRoot, filename));
|
|
75
|
-
if (indexFilePath) {
|
|
76
|
-
var _unpackConfig_html, _unpackConfig_html1, _unpackConfig_html2, _unpackConfig_html3, _unpackConfig_html4, _unpackConfig_html5, _unpackConfig_html6, _unpackConfig_html7, _unpackConfig_html8;
|
|
77
|
-
let pageConfig = ((indexPath)=>{
|
|
78
|
-
let filePath = node_path.join(indexPath, '../config.json'), pageConfig = {};
|
|
79
|
-
return node_fs.existsSync(filePath) && (pageConfig = JSON.parse(node_fs.readFileSync(filePath, 'utf-8'))), pageConfig;
|
|
80
|
-
})(indexFilePath), entryName = !0 === userOptions.lowerCase ? filename.toLowerCase() : filename;
|
|
81
|
-
pageConfig.filename && (entryName = pageConfig.filename.slice(0, -5)), entry[entryName] = {
|
|
82
|
-
import: [
|
|
83
|
-
indexFilePath
|
|
84
|
-
]
|
|
85
|
-
}, pageConfig.template && (pageConfig.template = node_path.join(indexFilePath, '../', pageConfig.template)), html.push({
|
|
86
|
-
template: (null == (_unpackConfig_html = unpackConfig.html) ? void 0 : _unpackConfig_html.template) || void 0,
|
|
87
|
-
templateContent: (null == (_unpackConfig_html1 = unpackConfig.html) ? void 0 : _unpackConfig_html1.templateContent) || ((null == (_unpackConfig_html2 = unpackConfig.html) ? void 0 : _unpackConfig_html2.template) ? void 0 : TEMPLATE_CONTENT),
|
|
88
|
-
minify: !1,
|
|
89
|
-
filename: `${entryName}.html`,
|
|
90
|
-
chunks: [
|
|
91
|
-
entryName
|
|
92
|
-
],
|
|
93
|
-
...pageConfig,
|
|
94
|
-
templateParameters: {
|
|
95
|
-
mountId: null == (_unpackConfig_html3 = unpackConfig.html) ? void 0 : _unpackConfig_html3.mountId,
|
|
96
|
-
title: isFunction(null == (_unpackConfig_html4 = unpackConfig.html) ? void 0 : _unpackConfig_html4.title) ? null == (_unpackConfig_html5 = unpackConfig.html) ? void 0 : _unpackConfig_html5.title({
|
|
97
|
-
entryName
|
|
98
|
-
}) : (null == (_unpackConfig_html6 = unpackConfig.html) ? void 0 : _unpackConfig_html6.title) || '',
|
|
99
|
-
headTag: (null == (_unpackConfig_html7 = unpackConfig.html) ? void 0 : _unpackConfig_html7.headTag) || '',
|
|
100
|
-
...null == (_unpackConfig_html8 = unpackConfig.html) ? void 0 : _unpackConfig_html8.templateParameters,
|
|
101
|
-
...pageConfig.templateParameters
|
|
102
|
-
}
|
|
103
|
-
});
|
|
62
|
+
let start, entry, html, pagesRoot, tempDirectory = node_path.join(TEMP_DIR, 'mpa'), userOptions = isPlainObject(unpackConfig.mpa) ? unpackConfig.mpa : {}, { entry: entry1, html: html1 } = (start = performance.now(), entry = {}, html = [], pagesRoot = node_path.join(unpackConfig.root, 'src', 'pages'), node_fs.readdirSync(pagesRoot).forEach((filename)=>{
|
|
63
|
+
if (filename.startsWith('.')) return;
|
|
64
|
+
let indexFilePath = ((dir)=>{
|
|
65
|
+
for (let extension of [
|
|
66
|
+
'.tsx',
|
|
67
|
+
'.jsx'
|
|
68
|
+
]){
|
|
69
|
+
let indexFilePath = node_path.join(dir, `index${extension}`);
|
|
70
|
+
if (node_fs.existsSync(indexFilePath)) return indexFilePath;
|
|
104
71
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
72
|
+
return null;
|
|
73
|
+
})(node_path.join(pagesRoot, filename));
|
|
74
|
+
if (indexFilePath) {
|
|
75
|
+
var _unpackConfig_html, _unpackConfig_html1, _unpackConfig_html2, _unpackConfig_html3, _unpackConfig_html4, _unpackConfig_html5, _unpackConfig_html6, _unpackConfig_html7, _unpackConfig_html8;
|
|
76
|
+
let filePath, pageConfig, pageConfig1 = (filePath = node_path.join(indexFilePath, '../config.json'), pageConfig = {}, node_fs.existsSync(filePath) && (pageConfig = JSON.parse(node_fs.readFileSync(filePath, 'utf-8'))), pageConfig), entryName = !0 === userOptions.lowerCase ? filename.toLowerCase() : filename;
|
|
77
|
+
pageConfig1.filename && (entryName = pageConfig1.filename.slice(0, -5)), entry[entryName] = {
|
|
78
|
+
import: [
|
|
79
|
+
indexFilePath
|
|
80
|
+
]
|
|
81
|
+
}, pageConfig1.template && (pageConfig1.template = node_path.join(indexFilePath, '../', pageConfig1.template)), html.push({
|
|
82
|
+
template: (null == (_unpackConfig_html = unpackConfig.html) ? void 0 : _unpackConfig_html.template) || void 0,
|
|
83
|
+
templateContent: (null == (_unpackConfig_html1 = unpackConfig.html) ? void 0 : _unpackConfig_html1.templateContent) || ((null == (_unpackConfig_html2 = unpackConfig.html) ? void 0 : _unpackConfig_html2.template) ? void 0 : TEMPLATE_CONTENT),
|
|
84
|
+
minify: !1,
|
|
85
|
+
filename: `${entryName}.html`,
|
|
86
|
+
chunks: [
|
|
87
|
+
entryName
|
|
88
|
+
],
|
|
89
|
+
...pageConfig1,
|
|
90
|
+
templateParameters: {
|
|
91
|
+
mountId: null == (_unpackConfig_html3 = unpackConfig.html) ? void 0 : _unpackConfig_html3.mountId,
|
|
92
|
+
title: isFunction(null == (_unpackConfig_html4 = unpackConfig.html) ? void 0 : _unpackConfig_html4.title) ? null == (_unpackConfig_html5 = unpackConfig.html) ? void 0 : _unpackConfig_html5.title({
|
|
93
|
+
entryName
|
|
94
|
+
}) : (null == (_unpackConfig_html6 = unpackConfig.html) ? void 0 : _unpackConfig_html6.title) || '',
|
|
95
|
+
headTag: (null == (_unpackConfig_html7 = unpackConfig.html) ? void 0 : _unpackConfig_html7.headTag) || '',
|
|
96
|
+
...null == (_unpackConfig_html8 = unpackConfig.html) ? void 0 : _unpackConfig_html8.templateParameters,
|
|
97
|
+
...pageConfig1.templateParameters
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}), isDevServer() || logger.info(`collect entries in ${(performance.now() - start).toFixed(2)}ms ${colors.dim('[MPA]')}`), {
|
|
102
|
+
entry,
|
|
103
|
+
html
|
|
104
|
+
});
|
|
105
|
+
return core_mergeConfig(config, {
|
|
111
106
|
entry: ((entry)=>{
|
|
112
107
|
var _userOptions_globalImport, _unpackConfig_html;
|
|
113
108
|
let root = unpackConfig.root;
|
|
@@ -125,8 +120,8 @@ ${renderer}
|
|
|
125
120
|
recursive: !0
|
|
126
121
|
}), node_fs.writeFileSync(filePath, tpl, 'utf-8'), entryConfig.import[0] = filePath;
|
|
127
122
|
}), entry;
|
|
128
|
-
})(
|
|
129
|
-
plugins:
|
|
123
|
+
})(entry1),
|
|
124
|
+
plugins: html1.map((h)=>new rspack.HtmlRspackPlugin(h))
|
|
130
125
|
});
|
|
131
126
|
})({
|
|
132
127
|
config,
|
package/dist/injectScript.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
const COVER_ID = '__click-to-component__';
|
|
2
|
+
let cover = null, currentDebugSource = null, enabled = !1;
|
|
2
3
|
function debounce(fn, delay = 200) {
|
|
3
4
|
let timer = null;
|
|
4
5
|
return (...args)=>{
|
|
@@ -52,9 +53,10 @@ function getClosestNodeFromFiber(fiber) {
|
|
|
52
53
|
return fiber.stateNode ? fiber.stateNode : getClosestNodeFromFiber(fiber.return);
|
|
53
54
|
}
|
|
54
55
|
function openEditor() {
|
|
56
|
+
let xhr;
|
|
55
57
|
if (!currentDebugSource) return;
|
|
56
|
-
let port = window.CLICK_TO_COMPONENT.port, { fileName, lineNumber, columnNumber } = currentDebugSource, url = "http://localhost:" + port + "/?file=" + fileName + "&line=" + lineNumber + "&column=" + columnNumber
|
|
57
|
-
xhr.open('GET', url, !0), xhr.send(), xhr.addEventListener('error', ()=>{
|
|
58
|
+
let port = window.CLICK_TO_COMPONENT.port, { fileName, lineNumber, columnNumber } = currentDebugSource, url = "http://localhost:" + port + "/?file=" + fileName + "&line=" + lineNumber + "&column=" + columnNumber;
|
|
59
|
+
(xhr = new XMLHttpRequest()).open('GET', url, !0), xhr.send(), xhr.addEventListener('error', ()=>{
|
|
58
60
|
document.createElement('img').src = url;
|
|
59
61
|
});
|
|
60
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/click-to-component/index.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/click-to-component/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,oBAAoB,EAIzB,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAA;AA6BvB,eAAO,MAAM,2BAA2B,GAAU,2BAG/C;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;CAC3B,KAAG,OAAO,CAAC,oBAAoB,CA+B/B,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unpackjs/plugin-react",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "React plugin for Unpack",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -24,13 +24,14 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@rspack/plugin-react-refresh": "1.
|
|
27
|
+
"@rspack/plugin-react-refresh": "1.5.1",
|
|
28
28
|
"@svgr/webpack": "8.1.0",
|
|
29
29
|
"@swc/helpers": "0.5.17",
|
|
30
|
+
"launch-editor": "2.11.1",
|
|
30
31
|
"react-refresh": "0.17.0"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
|
-
"@unpackjs/core": "3.
|
|
34
|
+
"@unpackjs/core": "3.3.0"
|
|
34
35
|
},
|
|
35
36
|
"peerDependencies": {
|
|
36
37
|
"@unpackjs/core": "3.x"
|