@unpackjs/plugin-react 0.27.0 → 0.28.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/dist/click-to-component/index.cjs +3 -5
- package/dist/click-to-component/index.d.ts +3 -4
- package/dist/click-to-component/index.d.ts.map +1 -1
- package/dist/click-to-component/index.js +3 -5
- package/dist/index.cjs +6 -3
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/package.json +3 -3
|
@@ -62,16 +62,14 @@ function createServer() {
|
|
|
62
62
|
}
|
|
63
63
|
const addClickToComponentSupport = async ({
|
|
64
64
|
config,
|
|
65
|
-
|
|
66
|
-
webpack
|
|
65
|
+
bundler
|
|
67
66
|
}) => {
|
|
68
|
-
if (!(0, import_shared.isDev)()
|
|
67
|
+
if (!(0, import_shared.isDev)())
|
|
69
68
|
return config;
|
|
70
69
|
const { port } = await createServer();
|
|
71
70
|
const injectScript = import_node_fs.default.readFileSync(import_node_path.default.resolve(__dirname, "./injectScript.js"), "utf-8");
|
|
72
71
|
config.plugins.push(
|
|
73
|
-
|
|
74
|
-
new webpack.BannerPlugin({
|
|
72
|
+
new bundler.BannerPlugin({
|
|
75
73
|
banner: `
|
|
76
74
|
if (!document.querySelector('#__click-to-component__')) {
|
|
77
75
|
const script = document.createElement('script')
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { type BundlerConfiguration
|
|
2
|
-
export declare const addClickToComponentSupport: ({ config,
|
|
1
|
+
import { type BundlerConfiguration } from '@unpackjs/shared';
|
|
2
|
+
export declare const addClickToComponentSupport: ({ config, bundler, }: {
|
|
3
3
|
config: BundlerConfiguration;
|
|
4
|
-
|
|
5
|
-
webpack;
|
|
4
|
+
bundler;
|
|
6
5
|
}) => Promise<BundlerConfiguration>;
|
|
7
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/click-to-component/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/click-to-component/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,oBAAoB,EAAkB,MAAM,kBAAkB,CAAA;AA4B5E,eAAO,MAAM,0BAA0B,yBAGpC;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,OAAO,CAAA;CACR,KAAG,QAAQ,oBAAoB,CAoB/B,CAAA"}
|
|
@@ -39,16 +39,14 @@ function createServer() {
|
|
|
39
39
|
}
|
|
40
40
|
const addClickToComponentSupport = async ({
|
|
41
41
|
config,
|
|
42
|
-
|
|
43
|
-
webpack
|
|
42
|
+
bundler
|
|
44
43
|
}) => {
|
|
45
|
-
if (!isDev()
|
|
44
|
+
if (!isDev())
|
|
46
45
|
return config;
|
|
47
46
|
const { port } = await createServer();
|
|
48
47
|
const injectScript = fs.readFileSync(path2.resolve(__dirname, "./injectScript.js"), "utf-8");
|
|
49
48
|
config.plugins.push(
|
|
50
|
-
|
|
51
|
-
new webpack.BannerPlugin({
|
|
49
|
+
new bundler.BannerPlugin({
|
|
52
50
|
banner: `
|
|
53
51
|
if (!document.querySelector('#__click-to-component__')) {
|
|
54
52
|
const script = document.createElement('script')
|
package/dist/index.cjs
CHANGED
|
@@ -37,11 +37,14 @@ var import_plugin_react_refresh = __toESM(require("@rspack/plugin-react-refresh"
|
|
|
37
37
|
var import_shared = require("@unpackjs/shared");
|
|
38
38
|
var import_click_to_component = require("./click-to-component/index.cjs");
|
|
39
39
|
const PLUGIN_NAME = "unpack:react";
|
|
40
|
-
const pluginReact = () => {
|
|
40
|
+
const pluginReact = (options = {}) => {
|
|
41
41
|
return {
|
|
42
42
|
name: PLUGIN_NAME,
|
|
43
|
-
bundlerConfig: async (config, { unpackConfig, mergeConfig,
|
|
44
|
-
|
|
43
|
+
bundlerConfig: async (config, { unpackConfig, mergeConfig, bundler }) => {
|
|
44
|
+
let next = config;
|
|
45
|
+
if (options.clickToComponent) {
|
|
46
|
+
next = await (0, import_click_to_component.addClickToComponentSupport)({ config, bundler });
|
|
47
|
+
}
|
|
45
48
|
const jsExclude = [/node_modules[\\/](?!\.unpack)/];
|
|
46
49
|
const swcLoader = unpackConfig.bundler === "rspack" ? "builtin:swc-loader" : require.resolve("swc-loader");
|
|
47
50
|
const ReactRefreshPlugin = unpackConfig.bundler === "rspack" ? import_plugin_react_refresh.default : import_react_refresh_webpack_plugin.default;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { type UnpackPlugin } from '@unpackjs/shared';
|
|
2
2
|
export declare const PLUGIN_NAME = "unpack:react";
|
|
3
|
-
export
|
|
3
|
+
export type PluginReactOptions = {
|
|
4
|
+
clickToComponent?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare const pluginReact: (options?: PluginReactOptions) => UnpackPlugin;
|
|
4
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,YAAY,EAAe,MAAM,kBAAkB,CAAA;AAGjE,eAAO,MAAM,WAAW,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,YAAY,EAAe,MAAM,kBAAkB,CAAA;AAGjE,eAAO,MAAM,WAAW,iBAAiB,CAAA;AAEzC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,WAAW,aAAa,kBAAkB,KAAQ,YAkE9D,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -13,11 +13,14 @@ import RspackReactRefreshPlugin from "@rspack/plugin-react-refresh";
|
|
|
13
13
|
import { isDevServer } from "@unpackjs/shared";
|
|
14
14
|
import { addClickToComponentSupport } from "./click-to-component/index.js";
|
|
15
15
|
const PLUGIN_NAME = "unpack:react";
|
|
16
|
-
const pluginReact = () => {
|
|
16
|
+
const pluginReact = (options = {}) => {
|
|
17
17
|
return {
|
|
18
18
|
name: PLUGIN_NAME,
|
|
19
|
-
bundlerConfig: async (config, { unpackConfig, mergeConfig,
|
|
20
|
-
|
|
19
|
+
bundlerConfig: async (config, { unpackConfig, mergeConfig, bundler }) => {
|
|
20
|
+
let next = config;
|
|
21
|
+
if (options.clickToComponent) {
|
|
22
|
+
next = await addClickToComponentSupport({ config, bundler });
|
|
23
|
+
}
|
|
21
24
|
const jsExclude = [/node_modules[\\/](?!\.unpack)/];
|
|
22
25
|
const swcLoader = unpackConfig.bundler === "rspack" ? "builtin:swc-loader" : require.resolve("swc-loader");
|
|
23
26
|
const ReactRefreshPlugin = unpackConfig.bundler === "rspack" ? RspackReactRefreshPlugin : WebpackReactRefreshPlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unpackjs/plugin-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"@rspack/plugin-react-refresh": "0.7.5",
|
|
28
28
|
"react-refresh": "0.14.2",
|
|
29
29
|
"swc-loader": "0.2.6",
|
|
30
|
-
"@swc/core": "1.7.
|
|
30
|
+
"@swc/core": "1.7.4",
|
|
31
31
|
"@swc/helpers": "0.5.12",
|
|
32
32
|
"launch-editor": "2.8.0",
|
|
33
|
-
"@unpackjs/shared": "^0.
|
|
33
|
+
"@unpackjs/shared": "^0.28.1"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"dev": "modern build --watch",
|