@rsbuild/plugin-preact 1.6.0 → 1.7.0-beta.1
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 +1 -1
- package/dist/index.cjs +70 -85
- package/dist/index.d.ts +2 -2
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ An Rsbuild plugin to provide support for Preact.
|
|
|
7
7
|
<img src="https://img.shields.io/npm/v/@rsbuild/plugin-preact?style=flat-square&colorA=564341&colorB=EDED91" alt="npm version" />
|
|
8
8
|
</a>
|
|
9
9
|
<img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="license" />
|
|
10
|
-
<a href="https://npmcharts.com/compare/@rsbuild/plugin-preact
|
|
10
|
+
<a href="https://npmcharts.com/compare/@rsbuild/plugin-preact"><img src="https://img.shields.io/npm/dm/@rsbuild/plugin-preact.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="downloads" /></a>
|
|
11
11
|
</p>
|
|
12
12
|
|
|
13
13
|
## Documentation
|
package/dist/index.cjs
CHANGED
|
@@ -1,107 +1,92 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const __rslib_import_meta_url__ =
|
|
3
|
-
var
|
|
4
|
-
"@rspack/plugin-preact-refresh": function(module) {
|
|
5
|
-
module.exports = import("@rspack/plugin-preact-refresh").then(function(module) {
|
|
6
|
-
return module;
|
|
7
|
-
});
|
|
8
|
-
}
|
|
9
|
-
}, __webpack_module_cache__ = {};
|
|
10
|
-
function __webpack_require__(moduleId) {
|
|
11
|
-
var cachedModule = __webpack_module_cache__[moduleId];
|
|
12
|
-
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
13
|
-
var module = __webpack_module_cache__[moduleId] = {
|
|
14
|
-
exports: {}
|
|
15
|
-
};
|
|
16
|
-
return __webpack_modules__[moduleId](module, module.exports, __webpack_require__), module.exports;
|
|
17
|
-
}
|
|
2
|
+
const __rslib_import_meta_url__ = "u" < typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
3
|
+
var __webpack_require__ = {};
|
|
18
4
|
__webpack_require__.d = (exports1, definition)=>{
|
|
19
5
|
for(var key in definition)__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key) && Object.defineProperty(exports1, key, {
|
|
20
6
|
enumerable: !0,
|
|
21
7
|
get: definition[key]
|
|
22
8
|
});
|
|
23
9
|
}, __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop), __webpack_require__.r = (exports1)=>{
|
|
24
|
-
|
|
10
|
+
"u" > typeof Symbol && Symbol.toStringTag && Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
25
11
|
value: 'Module'
|
|
26
12
|
}), Object.defineProperty(exports1, '__esModule', {
|
|
27
13
|
value: !0
|
|
28
14
|
});
|
|
29
15
|
};
|
|
30
16
|
var __webpack_exports__ = {};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
'
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
react: reactOptions
|
|
70
|
-
}
|
|
17
|
+
__webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, {
|
|
18
|
+
pluginPreact: ()=>pluginPreact,
|
|
19
|
+
PLUGIN_PREACT_NAME: ()=>PLUGIN_PREACT_NAME
|
|
20
|
+
});
|
|
21
|
+
const 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 = {})=>({
|
|
22
|
+
name: PLUGIN_PREACT_NAME,
|
|
23
|
+
setup (api) {
|
|
24
|
+
let options = {
|
|
25
|
+
include: /\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/,
|
|
26
|
+
exclude: /[\\/]node_modules[\\/]/,
|
|
27
|
+
prefreshEnabled: !0,
|
|
28
|
+
reactAliasesEnabled: !0,
|
|
29
|
+
...userOptions
|
|
30
|
+
};
|
|
31
|
+
'win32' === process.platform && (options.prefreshEnabled = !1), api.modifyEnvironmentConfig((config, { mergeEnvironmentConfig })=>{
|
|
32
|
+
let usePrefresh = 'development' === config.mode && options.prefreshEnabled && config.dev.hmr && 'web' === config.output.target, reactOptions = {
|
|
33
|
+
development: 'development' === config.mode,
|
|
34
|
+
refresh: usePrefresh,
|
|
35
|
+
runtime: 'automatic',
|
|
36
|
+
importSource: 'preact'
|
|
37
|
+
}, extraConfig = {
|
|
38
|
+
tools: {
|
|
39
|
+
swc: {
|
|
40
|
+
jsc: {
|
|
41
|
+
experimental: {
|
|
42
|
+
plugins: usePrefresh ? [
|
|
43
|
+
[
|
|
44
|
+
src_require.resolve('@swc/plugin-prefresh'),
|
|
45
|
+
{}
|
|
46
|
+
]
|
|
47
|
+
] : void 0
|
|
48
|
+
},
|
|
49
|
+
parser: {
|
|
50
|
+
syntax: "typescript",
|
|
51
|
+
tsx: !0
|
|
52
|
+
},
|
|
53
|
+
transform: {
|
|
54
|
+
react: reactOptions
|
|
71
55
|
}
|
|
72
56
|
}
|
|
73
57
|
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
])
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}),
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
chain.plugin('preact-refresh').use(PreactRefreshPlugin, [
|
|
92
|
-
{
|
|
93
|
-
include: options.include,
|
|
94
|
-
exclude: options.exclude,
|
|
95
|
-
preactPath
|
|
96
|
-
}
|
|
97
|
-
]);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
return extraConfig.source ||= {}, extraConfig.resolve ||= {}, usePrefresh && (extraConfig.source.include = [
|
|
61
|
+
/node_modules[\\/]@prefresh[\\/](core|utils)/
|
|
62
|
+
]), options.reactAliasesEnabled && (extraConfig.resolve.alias = {
|
|
63
|
+
react: 'preact/compat',
|
|
64
|
+
'react-dom/test-utils': 'preact/test-utils',
|
|
65
|
+
'react-dom': 'preact/compat',
|
|
66
|
+
'react/jsx-runtime': 'preact/jsx-runtime'
|
|
67
|
+
}), mergeEnvironmentConfig(extraConfig, config);
|
|
68
|
+
}), api.modifyBundlerChain(async (chain, { isDev, target })=>{
|
|
69
|
+
let config = api.getNormalizedConfig();
|
|
70
|
+
if (!(isDev && options.prefreshEnabled && config.dev.hmr && 'web' === target)) return;
|
|
71
|
+
let { default: PreactRefreshPlugin } = await import("@rspack/plugin-preact-refresh"), preactPath = src_require.resolve('preact', {
|
|
72
|
+
paths: [
|
|
73
|
+
api.context.rootPath
|
|
74
|
+
]
|
|
98
75
|
});
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
76
|
+
chain.plugin('preact-refresh').use(PreactRefreshPlugin, [
|
|
77
|
+
{
|
|
78
|
+
include: options.include,
|
|
79
|
+
exclude: options.exclude,
|
|
80
|
+
preactPath
|
|
81
|
+
}
|
|
82
|
+
]);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
for(var __rspack_i in exports.PLUGIN_PREACT_NAME = __webpack_exports__.PLUGIN_PREACT_NAME, exports.pluginPreact = __webpack_exports__.pluginPreact, __webpack_exports__)-1 === [
|
|
102
87
|
"PLUGIN_PREACT_NAME",
|
|
103
88
|
"pluginPreact"
|
|
104
|
-
].indexOf(
|
|
89
|
+
].indexOf(__rspack_i) && (exports[__rspack_i] = __webpack_exports__[__rspack_i]);
|
|
105
90
|
Object.defineProperty(exports, '__esModule', {
|
|
106
91
|
value: !0
|
|
107
92
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -12,13 +12,13 @@ export type PluginPreactOptions = {
|
|
|
12
12
|
prefreshEnabled?: boolean;
|
|
13
13
|
/**
|
|
14
14
|
* Include files to be processed by the `@rspack/plugin-preact-refresh` plugin.
|
|
15
|
-
* The value is the same as the `
|
|
15
|
+
* The value is the same as the `rules[].test` option in Rspack.
|
|
16
16
|
* @default /\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/
|
|
17
17
|
*/
|
|
18
18
|
include?: Rspack.RuleSetCondition;
|
|
19
19
|
/**
|
|
20
20
|
* Exclude files from being processed by the `@rspack/plugin-preact-refresh` plugin.
|
|
21
|
-
* The value is the same as the `
|
|
21
|
+
* The value is the same as the `rules[].exclude` option in Rspack.
|
|
22
22
|
* @default /[\\/]node_modules[\\/]/
|
|
23
23
|
*/
|
|
24
24
|
exclude?: Rspack.RuleSetCondition;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-preact",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0-beta.1",
|
|
4
4
|
"description": "Preact plugin for Rsbuild",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@prefresh/core": "^1.5.
|
|
25
|
+
"@prefresh/core": "^1.5.9",
|
|
26
26
|
"@prefresh/utils": "^1.2.1",
|
|
27
27
|
"@rspack/plugin-preact-refresh": "^1.1.4",
|
|
28
|
-
"@swc/plugin-prefresh": "^
|
|
28
|
+
"@swc/plugin-prefresh": "^12.1.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@rslib/core": "0.
|
|
32
|
-
"@types/node": "^
|
|
33
|
-
"preact": "^10.
|
|
31
|
+
"@rslib/core": "0.18.5",
|
|
32
|
+
"@types/node": "^24.10.4",
|
|
33
|
+
"preact": "^10.28.0",
|
|
34
34
|
"typescript": "^5.9.3",
|
|
35
|
-
"@rsbuild/core": "1.
|
|
35
|
+
"@rsbuild/core": "1.7.0-beta.1"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@rsbuild/core": "1.x"
|