@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 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?minimal=true"><img src="https://img.shields.io/npm/dm/@rsbuild/plugin-preact.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="downloads" /></a>
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__ = 'undefined' == 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_modules__ = {
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
- 'undefined' != typeof Symbol && Symbol.toStringTag && Object.defineProperty(exports1, Symbol.toStringTag, {
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
- for(var __webpack_i__ in (()=>{
32
- __webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, {
33
- pluginPreact: ()=>pluginPreact,
34
- PLUGIN_PREACT_NAME: ()=>PLUGIN_PREACT_NAME
35
- });
36
- let src_require = (0, require("node:module").createRequire)(__rslib_import_meta_url__), PLUGIN_PREACT_NAME = 'rsbuild:preact', pluginPreact = (userOptions = {})=>({
37
- name: PLUGIN_PREACT_NAME,
38
- setup (api) {
39
- let options = {
40
- include: /\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/,
41
- exclude: /[\\/]node_modules[\\/]/,
42
- prefreshEnabled: !0,
43
- reactAliasesEnabled: !0,
44
- ...userOptions
45
- };
46
- 'win32' === process.platform && (options.prefreshEnabled = !1), api.modifyEnvironmentConfig((config, { mergeEnvironmentConfig })=>{
47
- let usePrefresh = 'development' === config.mode && options.prefreshEnabled && config.dev.hmr && 'web' === config.output.target, reactOptions = {
48
- development: 'development' === config.mode,
49
- refresh: usePrefresh,
50
- runtime: 'automatic',
51
- importSource: 'preact'
52
- }, extraConfig = {
53
- tools: {
54
- swc: {
55
- jsc: {
56
- experimental: {
57
- plugins: usePrefresh ? [
58
- [
59
- src_require.resolve('@swc/plugin-prefresh'),
60
- {}
61
- ]
62
- ] : void 0
63
- },
64
- parser: {
65
- syntax: "typescript",
66
- tsx: !0
67
- },
68
- transform: {
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
- return extraConfig.source ||= {}, extraConfig.resolve ||= {}, usePrefresh && (extraConfig.source.include = [
76
- /node_modules[\\/]@prefresh[\\/](core|utils)/
77
- ]), options.reactAliasesEnabled && (extraConfig.resolve.alias = {
78
- react: 'preact/compat',
79
- 'react-dom/test-utils': 'preact/test-utils',
80
- 'react-dom': 'preact/compat',
81
- 'react/jsx-runtime': 'preact/jsx-runtime'
82
- }), mergeEnvironmentConfig(extraConfig, config);
83
- }), api.modifyBundlerChain(async (chain, { isDev, target })=>{
84
- let config = api.getNormalizedConfig();
85
- if (!(isDev && options.prefreshEnabled && config.dev.hmr && 'web' === target)) return;
86
- let { default: PreactRefreshPlugin } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "@rspack/plugin-preact-refresh")), preactPath = src_require.resolve('preact', {
87
- paths: [
88
- api.context.rootPath
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
- })(), exports.PLUGIN_PREACT_NAME = __webpack_exports__.PLUGIN_PREACT_NAME, exports.pluginPreact = __webpack_exports__.pluginPreact, __webpack_exports__)-1 === [
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(__webpack_i__) && (exports[__webpack_i__] = __webpack_exports__[__webpack_i__]);
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 `rule.test` option in Rspack.
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 `rule.exclude` option in Rspack.
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.6.0",
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.8",
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": "^10.0.0"
28
+ "@swc/plugin-prefresh": "^12.1.0"
29
29
  },
30
30
  "devDependencies": {
31
- "@rslib/core": "0.16.1",
32
- "@types/node": "^22.18.12",
33
- "preact": "^10.27.2",
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.6.0"
35
+ "@rsbuild/core": "1.7.0-beta.1"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@rsbuild/core": "1.x"