@rsbuild/plugin-preact 1.0.1 → 1.0.2
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 +85 -67
- package/dist/index.js +43 -51
- package/package.json +7 -8
- package/dist-types/package.json +0 -1
- /package/{dist-types → dist}/index.d.ts +0 -0
package/dist/index.cjs
CHANGED
|
@@ -1,71 +1,89 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
2
|
+
// The require scope
|
|
3
|
+
var __webpack_require__ = {};
|
|
4
|
+
/************************************************************************/ // webpack/runtime/define_property_getters
|
|
5
|
+
(()=>{
|
|
6
|
+
__webpack_require__.d = function(exports1, definition) {
|
|
7
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: definition[key]
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
})();
|
|
13
|
+
// webpack/runtime/has_own_property
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.o = function(obj, prop) {
|
|
16
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
};
|
|
18
|
+
})();
|
|
19
|
+
// webpack/runtime/make_namespace_object
|
|
20
|
+
(()=>{
|
|
21
|
+
// define __esModule on exports
|
|
22
|
+
__webpack_require__.r = function(exports1) {
|
|
23
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
24
|
+
value: 'Module'
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
27
|
+
value: true
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
})();
|
|
31
|
+
/************************************************************************/ var __webpack_exports__ = {};
|
|
32
|
+
__webpack_require__.r(__webpack_exports__);
|
|
33
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
34
|
+
PLUGIN_PREACT_NAME: function() {
|
|
35
|
+
return PLUGIN_PREACT_NAME;
|
|
36
|
+
},
|
|
37
|
+
pluginPreact: function() {
|
|
38
|
+
return pluginPreact;
|
|
39
|
+
}
|
|
25
40
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
const PLUGIN_PREACT_NAME = 'rsbuild:preact';
|
|
42
|
+
const pluginPreact = function() {
|
|
43
|
+
let options = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
|
|
44
|
+
return {
|
|
45
|
+
name: PLUGIN_PREACT_NAME,
|
|
46
|
+
setup (api) {
|
|
47
|
+
const { reactAliasesEnabled = true } = options;
|
|
48
|
+
api.modifyEnvironmentConfig((userConfig, param)=>{
|
|
49
|
+
let { mergeEnvironmentConfig } = param;
|
|
50
|
+
const reactOptions = {
|
|
51
|
+
development: 'development' === userConfig.mode,
|
|
52
|
+
runtime: 'automatic',
|
|
53
|
+
importSource: 'preact'
|
|
54
|
+
};
|
|
55
|
+
const extraConfig = {
|
|
56
|
+
tools: {
|
|
57
|
+
swc: {
|
|
58
|
+
jsc: {
|
|
59
|
+
parser: {
|
|
60
|
+
syntax: 'typescript',
|
|
61
|
+
// enable supports for JSX/TSX compilation
|
|
62
|
+
tsx: true
|
|
63
|
+
},
|
|
64
|
+
transform: {
|
|
65
|
+
react: reactOptions
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
if (reactAliasesEnabled) {
|
|
72
|
+
extraConfig.source ||= {};
|
|
73
|
+
extraConfig.source.alias = {
|
|
74
|
+
react: 'preact/compat',
|
|
75
|
+
'react-dom/test-utils': 'preact/test-utils',
|
|
76
|
+
'react-dom': 'preact/compat',
|
|
77
|
+
'react/jsx-runtime': 'preact/jsx-runtime'
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return mergeEnvironmentConfig(extraConfig, userConfig);
|
|
81
|
+
});
|
|
52
82
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"react-dom": "preact/compat",
|
|
60
|
-
"react/jsx-runtime": "preact/jsx-runtime"
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
return mergeEnvironmentConfig(extraConfig, userConfig);
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
68
|
-
0 && (module.exports = {
|
|
69
|
-
PLUGIN_PREACT_NAME,
|
|
70
|
-
pluginPreact
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
var __webpack_export_target__ = exports;
|
|
86
|
+
for(var i in __webpack_exports__)__webpack_export_target__[i] = __webpack_exports__[i];
|
|
87
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
88
|
+
value: true
|
|
71
89
|
});
|
package/dist/index.js
CHANGED
|
@@ -1,53 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
const PLUGIN_PREACT_NAME = 'rsbuild:preact';
|
|
2
|
+
const pluginPreact = function() {
|
|
3
|
+
let options = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
|
|
4
|
+
return {
|
|
5
|
+
name: PLUGIN_PREACT_NAME,
|
|
6
|
+
setup (api) {
|
|
7
|
+
const { reactAliasesEnabled = true } = options;
|
|
8
|
+
api.modifyEnvironmentConfig((userConfig, param)=>{
|
|
9
|
+
let { mergeEnvironmentConfig } = param;
|
|
10
|
+
const reactOptions = {
|
|
11
|
+
development: 'development' === userConfig.mode,
|
|
12
|
+
runtime: 'automatic',
|
|
13
|
+
importSource: 'preact'
|
|
14
|
+
};
|
|
15
|
+
const extraConfig = {
|
|
16
|
+
tools: {
|
|
17
|
+
swc: {
|
|
18
|
+
jsc: {
|
|
19
|
+
parser: {
|
|
20
|
+
syntax: 'typescript',
|
|
21
|
+
// enable supports for JSX/TSX compilation
|
|
22
|
+
tsx: true
|
|
23
|
+
},
|
|
24
|
+
transform: {
|
|
25
|
+
react: reactOptions
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
if (reactAliasesEnabled) {
|
|
32
|
+
extraConfig.source ||= {};
|
|
33
|
+
extraConfig.source.alias = {
|
|
34
|
+
react: 'preact/compat',
|
|
35
|
+
'react-dom/test-utils': 'preact/test-utils',
|
|
36
|
+
'react-dom': 'preact/compat',
|
|
37
|
+
'react/jsx-runtime': 'preact/jsx-runtime'
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return mergeEnvironmentConfig(extraConfig, userConfig);
|
|
41
|
+
});
|
|
35
42
|
}
|
|
36
|
-
|
|
37
|
-
if (reactAliasesEnabled) {
|
|
38
|
-
extraConfig.source ||= {};
|
|
39
|
-
extraConfig.source.alias = {
|
|
40
|
-
react: "preact/compat",
|
|
41
|
-
"react-dom/test-utils": "preact/test-utils",
|
|
42
|
-
"react-dom": "preact/compat",
|
|
43
|
-
"react/jsx-runtime": "preact/jsx-runtime"
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
return mergeEnvironmentConfig(extraConfig, userConfig);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
export {
|
|
51
|
-
PLUGIN_PREACT_NAME,
|
|
52
|
-
pluginPreact
|
|
43
|
+
};
|
|
53
44
|
};
|
|
45
|
+
export { PLUGIN_PREACT_NAME, pluginPreact };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-preact",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Preact plugin for Rsbuild",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,21 +11,20 @@
|
|
|
11
11
|
"type": "module",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
-
"types": "./dist
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
15
|
"import": "./dist/index.js",
|
|
16
16
|
"require": "./dist/index.cjs"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"main": "./dist/index.cjs",
|
|
20
|
-
"types": "./dist
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
21
|
"files": [
|
|
22
|
-
"dist"
|
|
23
|
-
"dist-types"
|
|
22
|
+
"dist"
|
|
24
23
|
],
|
|
25
24
|
"devDependencies": {
|
|
26
25
|
"@types/node": "18.x",
|
|
27
26
|
"typescript": "^5.5.2",
|
|
28
|
-
"@rsbuild/core": "1.0.
|
|
27
|
+
"@rsbuild/core": "1.0.8"
|
|
29
28
|
},
|
|
30
29
|
"peerDependencies": {
|
|
31
30
|
"@rsbuild/core": "1.x || ^1.0.1-rc.0"
|
|
@@ -36,7 +35,7 @@
|
|
|
36
35
|
"registry": "https://registry.npmjs.org/"
|
|
37
36
|
},
|
|
38
37
|
"scripts": {
|
|
39
|
-
"build": "
|
|
40
|
-
"dev": "
|
|
38
|
+
"build": "rslib build",
|
|
39
|
+
"dev": "rslib build --watch"
|
|
41
40
|
}
|
|
42
41
|
}
|
package/dist-types/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"//":"This file is for making TypeScript work with moduleResolution node16+.","version":"1.0.0"}
|
|
File without changes
|