@rsbuild/plugin-preact 0.6.14 → 0.7.0-beta.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 +69 -0
- package/dist/index.d.ts +3 -6
- package/dist/index.js +16 -28
- package/package.json +8 -8
- package/dist/index.mjs +0 -47
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
pluginPreact: () => pluginPreact
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(src_exports);
|
|
26
|
+
var import_shared = require("@rsbuild/shared");
|
|
27
|
+
var pluginPreact = (options = {}) => ({
|
|
28
|
+
name: "rsbuild:preact",
|
|
29
|
+
setup(api) {
|
|
30
|
+
const { reactAliasesEnabled = true } = options;
|
|
31
|
+
api.modifyRsbuildConfig((userConfig, { mergeRsbuildConfig }) => {
|
|
32
|
+
const reactOptions = {
|
|
33
|
+
development: (0, import_shared.getNodeEnv)() === "development",
|
|
34
|
+
runtime: "automatic",
|
|
35
|
+
importSource: "preact"
|
|
36
|
+
};
|
|
37
|
+
const extraConfig = {
|
|
38
|
+
tools: {
|
|
39
|
+
swc: {
|
|
40
|
+
jsc: {
|
|
41
|
+
parser: {
|
|
42
|
+
syntax: "typescript",
|
|
43
|
+
// enable supports for JSX/TSX compilation
|
|
44
|
+
tsx: true
|
|
45
|
+
},
|
|
46
|
+
transform: {
|
|
47
|
+
react: reactOptions
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
if (reactAliasesEnabled) {
|
|
54
|
+
extraConfig.source || (extraConfig.source = {});
|
|
55
|
+
extraConfig.source.alias = {
|
|
56
|
+
react: "preact/compat",
|
|
57
|
+
"react-dom/test-utils": "preact/test-utils",
|
|
58
|
+
"react-dom": "preact/compat",
|
|
59
|
+
"react/jsx-runtime": "preact/jsx-runtime"
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return mergeRsbuildConfig(extraConfig, userConfig);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
+
0 && (module.exports = {
|
|
68
|
+
pluginPreact
|
|
69
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import { RsbuildPlugin } from '@rsbuild/core';
|
|
2
|
-
|
|
3
|
-
type PluginPreactOptions = {
|
|
1
|
+
import type { RsbuildPlugin } from '@rsbuild/core';
|
|
2
|
+
export type PluginPreactOptions = {
|
|
4
3
|
/**
|
|
5
4
|
* Whether to aliases `react`, `react-dom` to `preact/compat`
|
|
6
5
|
* @default true
|
|
7
6
|
*/
|
|
8
7
|
reactAliasesEnabled?: boolean;
|
|
9
8
|
};
|
|
10
|
-
declare const pluginPreact: (options?: PluginPreactOptions) => RsbuildPlugin;
|
|
11
|
-
|
|
12
|
-
export { type PluginPreactOptions, pluginPreact };
|
|
9
|
+
export declare const pluginPreact: (options?: PluginPreactOptions) => RsbuildPlugin;
|
package/dist/index.js
CHANGED
|
@@ -1,36 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
|
+
var require = createRequire(import.meta['url']);
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
// ../../node_modules/.pnpm/@modern-js+module-tools@2.49.3_eslint@8.57.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
|
|
6
|
+
import { fileURLToPath } from "url";
|
|
7
|
+
import path from "path";
|
|
19
8
|
|
|
20
9
|
// src/index.ts
|
|
21
|
-
|
|
22
|
-
__export(src_exports, {
|
|
23
|
-
pluginPreact: () => pluginPreact
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(src_exports);
|
|
26
|
-
var import_shared = require("@rsbuild/shared");
|
|
10
|
+
import { getNodeEnv } from "@rsbuild/shared";
|
|
27
11
|
var pluginPreact = (options = {}) => ({
|
|
28
12
|
name: "rsbuild:preact",
|
|
29
13
|
setup(api) {
|
|
30
14
|
const { reactAliasesEnabled = true } = options;
|
|
31
15
|
api.modifyRsbuildConfig((userConfig, { mergeRsbuildConfig }) => {
|
|
32
16
|
const reactOptions = {
|
|
33
|
-
development:
|
|
17
|
+
development: getNodeEnv() === "development",
|
|
34
18
|
runtime: "automatic",
|
|
35
19
|
importSource: "preact"
|
|
36
20
|
};
|
|
@@ -38,6 +22,11 @@ var pluginPreact = (options = {}) => ({
|
|
|
38
22
|
tools: {
|
|
39
23
|
swc: {
|
|
40
24
|
jsc: {
|
|
25
|
+
parser: {
|
|
26
|
+
syntax: "typescript",
|
|
27
|
+
// enable supports for JSX/TSX compilation
|
|
28
|
+
tsx: true
|
|
29
|
+
},
|
|
41
30
|
transform: {
|
|
42
31
|
react: reactOptions
|
|
43
32
|
}
|
|
@@ -58,7 +47,6 @@ var pluginPreact = (options = {}) => ({
|
|
|
58
47
|
});
|
|
59
48
|
}
|
|
60
49
|
});
|
|
61
|
-
|
|
62
|
-
0 && (module.exports = {
|
|
50
|
+
export {
|
|
63
51
|
pluginPreact
|
|
64
|
-
}
|
|
52
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-preact",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0-beta.0",
|
|
4
4
|
"description": "Preact plugin for Rsbuild",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,29 +8,29 @@
|
|
|
8
8
|
"directory": "packages/plugin-preact"
|
|
9
9
|
},
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"type": "
|
|
11
|
+
"type": "module",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
|
-
"import": "./dist/index.
|
|
16
|
-
"
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"require": "./dist/index.cjs"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
|
-
"main": "./dist/index.
|
|
19
|
+
"main": "./dist/index.cjs",
|
|
20
20
|
"types": "./dist/index.d.ts",
|
|
21
21
|
"files": [
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@rsbuild/shared": "0.
|
|
25
|
+
"@rsbuild/shared": "0.7.0-beta.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "18.x",
|
|
29
29
|
"typescript": "^5.4.2",
|
|
30
|
-
"@rsbuild/core": "0.
|
|
30
|
+
"@rsbuild/core": "0.7.0-beta.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@rsbuild/core": "^0.
|
|
33
|
+
"@rsbuild/core": "^0.7.0-beta.0"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public",
|
package/dist/index.mjs
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module';
|
|
2
|
-
var require = createRequire(import.meta['url']);
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
// ../../node_modules/.pnpm/@modern-js+module-tools@2.49.2_eslint@8.57.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
|
|
6
|
-
import { fileURLToPath } from "url";
|
|
7
|
-
import path from "path";
|
|
8
|
-
|
|
9
|
-
// src/index.ts
|
|
10
|
-
import { getNodeEnv } from "@rsbuild/shared";
|
|
11
|
-
var pluginPreact = (options = {}) => ({
|
|
12
|
-
name: "rsbuild:preact",
|
|
13
|
-
setup(api) {
|
|
14
|
-
const { reactAliasesEnabled = true } = options;
|
|
15
|
-
api.modifyRsbuildConfig((userConfig, { mergeRsbuildConfig }) => {
|
|
16
|
-
const reactOptions = {
|
|
17
|
-
development: getNodeEnv() === "development",
|
|
18
|
-
runtime: "automatic",
|
|
19
|
-
importSource: "preact"
|
|
20
|
-
};
|
|
21
|
-
const extraConfig = {
|
|
22
|
-
tools: {
|
|
23
|
-
swc: {
|
|
24
|
-
jsc: {
|
|
25
|
-
transform: {
|
|
26
|
-
react: reactOptions
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
if (reactAliasesEnabled) {
|
|
33
|
-
extraConfig.source || (extraConfig.source = {});
|
|
34
|
-
extraConfig.source.alias = {
|
|
35
|
-
react: "preact/compat",
|
|
36
|
-
"react-dom/test-utils": "preact/test-utils",
|
|
37
|
-
"react-dom": "preact/compat",
|
|
38
|
-
"react/jsx-runtime": "preact/jsx-runtime"
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
return mergeRsbuildConfig(extraConfig, userConfig);
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
export {
|
|
46
|
-
pluginPreact
|
|
47
|
-
};
|