@rsbuild/plugin-preact 1.1.1 → 1.3.0-alpha.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 +42 -125
- package/dist/index.js +15 -30
- package/package.json +9 -8
package/dist/index.cjs
CHANGED
|
@@ -1,129 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
let __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;
|
|
2
3
|
var __webpack_modules__ = {
|
|
3
|
-
"@rspack/plugin-preact-refresh": function(
|
|
4
|
-
|
|
4
|
+
"@rspack/plugin-preact-refresh": function(module) {
|
|
5
|
+
module.exports = import("@rspack/plugin-preact-refresh");
|
|
5
6
|
}
|
|
6
|
-
};
|
|
7
|
-
/************************************************************************/ // The module cache
|
|
8
|
-
var __webpack_module_cache__ = {};
|
|
9
|
-
// The require function
|
|
7
|
+
}, __webpack_module_cache__ = {};
|
|
10
8
|
function __webpack_require__(moduleId) {
|
|
11
|
-
// Check if module is in cache
|
|
12
9
|
var cachedModule = __webpack_module_cache__[moduleId];
|
|
13
10
|
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
14
|
-
|
|
15
|
-
var module1 = __webpack_module_cache__[moduleId] = {
|
|
11
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
16
12
|
exports: {}
|
|
17
13
|
};
|
|
18
|
-
|
|
19
|
-
__webpack_modules__[moduleId](module1, module1.exports, __webpack_require__);
|
|
20
|
-
// Return the exports of the module
|
|
21
|
-
return module1.exports;
|
|
14
|
+
return __webpack_modules__[moduleId](module, module.exports, __webpack_require__), module.exports;
|
|
22
15
|
}
|
|
23
|
-
|
|
24
|
-
(()
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (4 & mode && value.__esModule) return value;
|
|
42
|
-
if (16 & mode && 'function' == typeof value.then) return value;
|
|
43
|
-
}
|
|
44
|
-
var ns = Object.create(null);
|
|
45
|
-
__webpack_require__.r(ns);
|
|
46
|
-
var def = {};
|
|
47
|
-
leafPrototypes = leafPrototypes || [
|
|
48
|
-
null,
|
|
49
|
-
getProto({}),
|
|
50
|
-
getProto([]),
|
|
51
|
-
getProto(getProto)
|
|
52
|
-
];
|
|
53
|
-
for(var current = 2 & mode && value; 'object' == typeof current && !~leafPrototypes.indexOf(current); current = getProto(current))Object.getOwnPropertyNames(current).forEach(function(key) {
|
|
54
|
-
def[key] = function() {
|
|
55
|
-
return value[key];
|
|
56
|
-
};
|
|
57
|
-
});
|
|
58
|
-
def['default'] = function() {
|
|
59
|
-
return value;
|
|
60
|
-
};
|
|
61
|
-
__webpack_require__.d(ns, def);
|
|
62
|
-
return ns;
|
|
63
|
-
};
|
|
64
|
-
})();
|
|
65
|
-
// webpack/runtime/define_property_getters
|
|
66
|
-
(()=>{
|
|
67
|
-
__webpack_require__.d = function(exports1, definition) {
|
|
68
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
69
|
-
enumerable: true,
|
|
70
|
-
get: definition[key]
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
})();
|
|
74
|
-
// webpack/runtime/has_own_property
|
|
75
|
-
(()=>{
|
|
76
|
-
__webpack_require__.o = function(obj, prop) {
|
|
77
|
-
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
78
|
-
};
|
|
79
|
-
})();
|
|
80
|
-
// webpack/runtime/make_namespace_object
|
|
81
|
-
(()=>{
|
|
82
|
-
// define __esModule on exports
|
|
83
|
-
__webpack_require__.r = function(exports1) {
|
|
84
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
85
|
-
value: 'Module'
|
|
86
|
-
});
|
|
87
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
88
|
-
value: true
|
|
89
|
-
});
|
|
90
|
-
};
|
|
91
|
-
})();
|
|
92
|
-
/************************************************************************/ var __webpack_exports__ = {};
|
|
93
|
-
// ESM COMPAT FLAG
|
|
94
|
-
__webpack_require__.r(__webpack_exports__);
|
|
95
|
-
// EXPORTS
|
|
96
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
97
|
-
PLUGIN_PREACT_NAME: ()=>/* binding */ PLUGIN_PREACT_NAME,
|
|
98
|
-
pluginPreact: ()=>/* binding */ pluginPreact
|
|
16
|
+
__webpack_require__.d = function(exports1, definition) {
|
|
17
|
+
for(var key in definition)__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key) && Object.defineProperty(exports1, key, {
|
|
18
|
+
enumerable: !0,
|
|
19
|
+
get: definition[key]
|
|
20
|
+
});
|
|
21
|
+
}, __webpack_require__.o = function(obj, prop) {
|
|
22
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
23
|
+
}, __webpack_require__.r = function(exports1) {
|
|
24
|
+
'undefined' != typeof Symbol && Symbol.toStringTag && Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
25
|
+
value: 'Module'
|
|
26
|
+
}), Object.defineProperty(exports1, '__esModule', {
|
|
27
|
+
value: !0
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
var __webpack_exports__ = {};
|
|
31
|
+
__webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, {
|
|
32
|
+
pluginPreact: ()=>pluginPreact,
|
|
33
|
+
PLUGIN_PREACT_NAME: ()=>PLUGIN_PREACT_NAME
|
|
99
34
|
});
|
|
100
|
-
|
|
101
|
-
const src_require = (0, external_node_module_namespaceObject.createRequire)(/*#__PURE__*/ function() {
|
|
102
|
-
return 'undefined' == typeof document ? new (module.require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
103
|
-
}());
|
|
104
|
-
const PLUGIN_PREACT_NAME = 'rsbuild:preact';
|
|
105
|
-
const pluginPreact = (userOptions = {})=>({
|
|
35
|
+
let external_node_module_namespaceObject = require("node:module"), src_require = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__), PLUGIN_PREACT_NAME = 'rsbuild:preact', pluginPreact = (userOptions = {})=>({
|
|
106
36
|
name: PLUGIN_PREACT_NAME,
|
|
107
37
|
setup (api) {
|
|
108
|
-
|
|
38
|
+
let options = {
|
|
109
39
|
include: /\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/,
|
|
110
40
|
exclude: /[\\/]node_modules[\\/]/,
|
|
111
|
-
prefreshEnabled:
|
|
112
|
-
reactAliasesEnabled:
|
|
41
|
+
prefreshEnabled: !0,
|
|
42
|
+
reactAliasesEnabled: !0,
|
|
113
43
|
...userOptions
|
|
114
44
|
};
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
api.modifyEnvironmentConfig((config, { mergeEnvironmentConfig })=>{
|
|
118
|
-
const isDev = 'development' === config.mode;
|
|
119
|
-
const usePrefresh = isDev && options.prefreshEnabled && config.dev.hmr && 'web' === config.output.target;
|
|
120
|
-
const reactOptions = {
|
|
45
|
+
'win32' === process.platform && (options.prefreshEnabled = !1), api.modifyEnvironmentConfig((config, { mergeEnvironmentConfig })=>{
|
|
46
|
+
let usePrefresh = 'development' === config.mode && options.prefreshEnabled && config.dev.hmr && 'web' === config.output.target, reactOptions = {
|
|
121
47
|
development: 'development' === config.mode,
|
|
122
48
|
refresh: usePrefresh,
|
|
123
49
|
runtime: 'automatic',
|
|
124
50
|
importSource: 'preact'
|
|
125
|
-
}
|
|
126
|
-
const extraConfig = {
|
|
51
|
+
}, extraConfig = {
|
|
127
52
|
tools: {
|
|
128
53
|
swc: {
|
|
129
54
|
jsc: {
|
|
@@ -137,8 +62,7 @@ const pluginPreact = (userOptions = {})=>({
|
|
|
137
62
|
},
|
|
138
63
|
parser: {
|
|
139
64
|
syntax: 'typescript',
|
|
140
|
-
|
|
141
|
-
tsx: true
|
|
65
|
+
tsx: !0
|
|
142
66
|
},
|
|
143
67
|
transform: {
|
|
144
68
|
react: reactOptions
|
|
@@ -147,25 +71,18 @@ const pluginPreact = (userOptions = {})=>({
|
|
|
147
71
|
}
|
|
148
72
|
}
|
|
149
73
|
};
|
|
150
|
-
extraConfig.source ||= {}
|
|
151
|
-
if (usePrefresh) // transpile `@prefresh/core` and `@prefresh/utils` to ensure browser compatibility
|
|
152
|
-
extraConfig.source.include = [
|
|
74
|
+
return extraConfig.source ||= {}, extraConfig.resolve ||= {}, usePrefresh && (extraConfig.source.include = [
|
|
153
75
|
/node_modules[\\/]@prefresh[\\/](core|utils)/
|
|
154
|
-
]
|
|
155
|
-
if (options.reactAliasesEnabled) extraConfig.source.alias = {
|
|
76
|
+
]), options.reactAliasesEnabled && (extraConfig.resolve.alias = {
|
|
156
77
|
react: 'preact/compat',
|
|
157
78
|
'react-dom/test-utils': 'preact/test-utils',
|
|
158
79
|
'react-dom': 'preact/compat',
|
|
159
80
|
'react/jsx-runtime': 'preact/jsx-runtime'
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
const usePrefresh = isDev && options.prefreshEnabled && config.dev.hmr && 'web' === target;
|
|
166
|
-
if (!usePrefresh) return;
|
|
167
|
-
const { default: PreactRefreshPlugin } = await Promise.resolve().then(__webpack_require__.t.bind(__webpack_require__, "@rspack/plugin-preact-refresh", 23));
|
|
168
|
-
const preactPath = src_require.resolve('preact', {
|
|
81
|
+
}), mergeEnvironmentConfig(extraConfig, config);
|
|
82
|
+
}), api.modifyBundlerChain(async (chain, { isDev, target })=>{
|
|
83
|
+
let config = api.getNormalizedConfig();
|
|
84
|
+
if (!(isDev && options.prefreshEnabled && config.dev.hmr && 'web' === target)) return;
|
|
85
|
+
let { default: PreactRefreshPlugin } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "@rspack/plugin-preact-refresh")), preactPath = src_require.resolve('preact', {
|
|
169
86
|
paths: [
|
|
170
87
|
api.context.rootPath
|
|
171
88
|
]
|
|
@@ -181,7 +98,7 @@ const pluginPreact = (userOptions = {})=>({
|
|
|
181
98
|
}
|
|
182
99
|
});
|
|
183
100
|
var __webpack_export_target__ = exports;
|
|
184
|
-
for(var
|
|
185
|
-
|
|
186
|
-
value:
|
|
101
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
102
|
+
__webpack_exports__.__esModule && Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
103
|
+
value: !0
|
|
187
104
|
});
|
package/dist/index.js
CHANGED
|
@@ -1,28 +1,21 @@
|
|
|
1
1
|
import * as __WEBPACK_EXTERNAL_MODULE_node_module__ from "node:module";
|
|
2
|
-
|
|
3
|
-
const PLUGIN_PREACT_NAME = 'rsbuild:preact';
|
|
4
|
-
const pluginPreact = (userOptions = {})=>({
|
|
2
|
+
let src_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module__.createRequire)(import.meta.url), PLUGIN_PREACT_NAME = 'rsbuild:preact', pluginPreact = (userOptions = {})=>({
|
|
5
3
|
name: PLUGIN_PREACT_NAME,
|
|
6
4
|
setup (api) {
|
|
7
|
-
|
|
5
|
+
let options = {
|
|
8
6
|
include: /\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/,
|
|
9
7
|
exclude: /[\\/]node_modules[\\/]/,
|
|
10
|
-
prefreshEnabled:
|
|
11
|
-
reactAliasesEnabled:
|
|
8
|
+
prefreshEnabled: !0,
|
|
9
|
+
reactAliasesEnabled: !0,
|
|
12
10
|
...userOptions
|
|
13
11
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
api.modifyEnvironmentConfig((config, { mergeEnvironmentConfig })=>{
|
|
17
|
-
const isDev = 'development' === config.mode;
|
|
18
|
-
const usePrefresh = isDev && options.prefreshEnabled && config.dev.hmr && 'web' === config.output.target;
|
|
19
|
-
const reactOptions = {
|
|
12
|
+
'win32' === process.platform && (options.prefreshEnabled = !1), api.modifyEnvironmentConfig((config, { mergeEnvironmentConfig })=>{
|
|
13
|
+
let usePrefresh = 'development' === config.mode && options.prefreshEnabled && config.dev.hmr && 'web' === config.output.target, reactOptions = {
|
|
20
14
|
development: 'development' === config.mode,
|
|
21
15
|
refresh: usePrefresh,
|
|
22
16
|
runtime: 'automatic',
|
|
23
17
|
importSource: 'preact'
|
|
24
|
-
}
|
|
25
|
-
const extraConfig = {
|
|
18
|
+
}, extraConfig = {
|
|
26
19
|
tools: {
|
|
27
20
|
swc: {
|
|
28
21
|
jsc: {
|
|
@@ -36,8 +29,7 @@ const pluginPreact = (userOptions = {})=>({
|
|
|
36
29
|
},
|
|
37
30
|
parser: {
|
|
38
31
|
syntax: 'typescript',
|
|
39
|
-
|
|
40
|
-
tsx: true
|
|
32
|
+
tsx: !0
|
|
41
33
|
},
|
|
42
34
|
transform: {
|
|
43
35
|
react: reactOptions
|
|
@@ -46,25 +38,18 @@ const pluginPreact = (userOptions = {})=>({
|
|
|
46
38
|
}
|
|
47
39
|
}
|
|
48
40
|
};
|
|
49
|
-
extraConfig.source ||= {}
|
|
50
|
-
if (usePrefresh) // transpile `@prefresh/core` and `@prefresh/utils` to ensure browser compatibility
|
|
51
|
-
extraConfig.source.include = [
|
|
41
|
+
return extraConfig.source ||= {}, extraConfig.resolve ||= {}, usePrefresh && (extraConfig.source.include = [
|
|
52
42
|
/node_modules[\\/]@prefresh[\\/](core|utils)/
|
|
53
|
-
]
|
|
54
|
-
if (options.reactAliasesEnabled) extraConfig.source.alias = {
|
|
43
|
+
]), options.reactAliasesEnabled && (extraConfig.resolve.alias = {
|
|
55
44
|
react: 'preact/compat',
|
|
56
45
|
'react-dom/test-utils': 'preact/test-utils',
|
|
57
46
|
'react-dom': 'preact/compat',
|
|
58
47
|
'react/jsx-runtime': 'preact/jsx-runtime'
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const usePrefresh = isDev && options.prefreshEnabled && config.dev.hmr && 'web' === target;
|
|
65
|
-
if (!usePrefresh) return;
|
|
66
|
-
const { default: PreactRefreshPlugin } = await import("@rspack/plugin-preact-refresh");
|
|
67
|
-
const preactPath = src_require.resolve('preact', {
|
|
48
|
+
}), mergeEnvironmentConfig(extraConfig, config);
|
|
49
|
+
}), api.modifyBundlerChain(async (chain, { isDev, target })=>{
|
|
50
|
+
let config = api.getNormalizedConfig();
|
|
51
|
+
if (!(isDev && options.prefreshEnabled && config.dev.hmr && 'web' === target)) return;
|
|
52
|
+
let { default: PreactRefreshPlugin } = await import("@rspack/plugin-preact-refresh"), preactPath = src_require.resolve('preact', {
|
|
68
53
|
paths: [
|
|
69
54
|
api.context.rootPath
|
|
70
55
|
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-preact",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0-alpha.0",
|
|
4
4
|
"description": "Preact plugin for Rsbuild",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,16 +22,17 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@prefresh/core": "^1.5.
|
|
25
|
+
"@prefresh/core": "^1.5.3",
|
|
26
26
|
"@prefresh/utils": "^1.2.0",
|
|
27
|
-
"@rspack/plugin-preact-refresh": "^1.1.
|
|
28
|
-
"@swc/plugin-prefresh": "^
|
|
27
|
+
"@rspack/plugin-preact-refresh": "^1.1.2",
|
|
28
|
+
"@swc/plugin-prefresh": "^6.0.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
31
|
+
"@rslib/core": "0.2.2",
|
|
32
|
+
"@types/node": "^22.10.2",
|
|
33
|
+
"preact": "^10.25.4",
|
|
34
|
+
"typescript": "^5.7.2",
|
|
35
|
+
"@rsbuild/core": "1.2.0-alpha.0"
|
|
35
36
|
},
|
|
36
37
|
"peerDependencies": {
|
|
37
38
|
"@rsbuild/core": "1.x"
|