@vitejs/plugin-react 1.1.4 → 1.2.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/CHANGELOG.md +9 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +20 -14
- package/package.json +9 -8
- package/src/index.ts +7 -2
- package/src/jsx-runtime/restore-jsx.ts +2 -1
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
# [1.2.0](https://github.com/vitejs/vite/compare/plugin-react@1.1.4...plugin-react@1.2.0) (2022-02-09)
|
2
|
+
|
3
|
+
|
4
|
+
### Features
|
5
|
+
|
6
|
+
* **plugin-react:** ensure `overrides` array exists before `api.reactBabel` hooks are called ([#6750](https://github.com/vitejs/vite/issues/6750)) ([104bdb5](https://github.com/vitejs/vite/commit/104bdb5b5e44e79bf3456cabe15f3753f7c1ef28))
|
7
|
+
|
8
|
+
|
9
|
+
|
1
10
|
## [1.1.4](https://github.com/vitejs/vite/compare/plugin-react@1.1.3...plugin-react@1.1.4) (2022-01-04)
|
2
11
|
|
3
12
|
|
package/dist/index.d.ts
CHANGED
@@ -40,6 +40,7 @@ export declare interface Options {
|
|
40
40
|
export declare interface ReactBabelOptions extends BabelOptions {
|
41
41
|
plugins: Extract<BabelOptions['plugins'], any[]>;
|
42
42
|
presets: Extract<BabelOptions['presets'], any[]>;
|
43
|
+
overrides: Extract<BabelOptions['overrides'], any[]>;
|
43
44
|
parserOpts: ParserOptions & {
|
44
45
|
plugins: Extract<ParserOptions['plugins'], any[]>;
|
45
46
|
};
|
package/dist/index.js
CHANGED
@@ -23,24 +23,28 @@ var __spreadValues = (a, b) => {
|
|
23
23
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
24
24
|
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
25
25
|
var __esm = (fn, res) => function __init() {
|
26
|
-
return fn && (res = (0, fn[
|
26
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
27
27
|
};
|
28
28
|
var __export = (target, all) => {
|
29
|
-
__markAsModule(target);
|
30
29
|
for (var name in all)
|
31
30
|
__defProp(target, name, { get: all[name], enumerable: true });
|
32
31
|
};
|
33
|
-
var __reExport = (target, module2, desc) => {
|
32
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
34
33
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
35
34
|
for (let key of __getOwnPropNames(module2))
|
36
|
-
if (!__hasOwnProp.call(target, key) && key !== "default")
|
35
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
37
36
|
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
38
37
|
}
|
39
38
|
return target;
|
40
39
|
};
|
41
|
-
var
|
42
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default",
|
40
|
+
var __toESM = (module2, isNodeMode) => {
|
41
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
43
42
|
};
|
43
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
44
|
+
return (module2, temp) => {
|
45
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
46
|
+
};
|
47
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
44
48
|
|
45
49
|
// src/jsx-runtime/babel-restore-jsx.ts
|
46
50
|
var babel_restore_jsx_exports = {};
|
@@ -170,15 +174,16 @@ var init_babel_restore_jsx = __esm({
|
|
170
174
|
});
|
171
175
|
|
172
176
|
// src/index.ts
|
173
|
-
|
177
|
+
var src_exports = {};
|
178
|
+
__export(src_exports, {
|
174
179
|
default: () => viteReact
|
175
180
|
});
|
176
|
-
var babel =
|
177
|
-
var import_pluginutils =
|
178
|
-
var import_resolve =
|
181
|
+
var babel = __toESM(require("@babel/core"));
|
182
|
+
var import_pluginutils = require("@rollup/pluginutils");
|
183
|
+
var import_resolve = __toESM(require("resolve"));
|
179
184
|
|
180
185
|
// src/fast-refresh.ts
|
181
|
-
var import_fs =
|
186
|
+
var import_fs = __toESM(require("fs"));
|
182
187
|
var runtimePublicPath = "/@react-refresh";
|
183
188
|
var runtimeFilePath = require.resolve("react-refresh/cjs/react-refresh-runtime.development.js");
|
184
189
|
var runtimeCode = `
|
@@ -310,7 +315,7 @@ async function restoreJSX(babel2, code, filename) {
|
|
310
315
|
parserOpts: {
|
311
316
|
plugins: ["jsx"]
|
312
317
|
},
|
313
|
-
plugins: [await babelRestoreJSX]
|
318
|
+
plugins: [(await babelRestoreJSX).default]
|
314
319
|
});
|
315
320
|
return [result == null ? void 0 : result.ast, isCommonJS];
|
316
321
|
}
|
@@ -342,6 +347,7 @@ function viteReact(opts = {}) {
|
|
342
347
|
}, opts.babel);
|
343
348
|
babelOptions.plugins || (babelOptions.plugins = []);
|
344
349
|
babelOptions.presets || (babelOptions.presets = []);
|
350
|
+
babelOptions.overrides || (babelOptions.overrides = []);
|
345
351
|
babelOptions.parserOpts || (babelOptions.parserOpts = {});
|
346
352
|
(_a = babelOptions.parserOpts).plugins || (_a.plugins = opts.parserPlugins || []);
|
347
353
|
const importReactRE = /(^|\n)import\s+(\*\s+as\s+)?React(,|\s+)/;
|
@@ -528,10 +534,10 @@ function viteReact(opts = {}) {
|
|
528
534
|
}
|
529
535
|
viteReact.preambleCode = preambleCode;
|
530
536
|
function loadPlugin(path) {
|
531
|
-
return Promise.resolve().then(() =>
|
537
|
+
return Promise.resolve().then(() => __toESM(require(path))).then((module2) => module2.default || module2);
|
532
538
|
}
|
533
539
|
module.exports = viteReact;
|
534
|
-
viteReact[
|
540
|
+
viteReact['default'] = viteReact;
|
535
541
|
// Annotate the CommonJS export names for ESM import in node:
|
536
542
|
0 && (module.exports = {});
|
537
543
|
/**
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vitejs/plugin-react",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.2.0",
|
4
4
|
"license": "MIT",
|
5
5
|
"author": "Evan You",
|
6
6
|
"contributors": [
|
@@ -15,7 +15,8 @@
|
|
15
15
|
"scripts": {
|
16
16
|
"dev": "tsc -p . -w --incremental",
|
17
17
|
"build": "rimraf dist && run-s build-bundle build-types",
|
18
|
-
"build-bundle": "esbuild src/index.ts --bundle --platform=node --target=node12 --external:@babel/* --external:@rollup/* --external:resolve --external:react-refresh/* --outfile=dist/index.js",
|
18
|
+
"build-bundle": "esbuild src/index.ts --bundle --platform=node --target=node12 --external:@babel/* --external:@rollup/* --external:resolve --external:react-refresh/* --outfile=dist/index.js && npm run patch-dist",
|
19
|
+
"patch-dist": "ts-node ../../scripts/patchEsbuildDist.ts dist/index.js viteReact",
|
19
20
|
"build-types": "tsc -p . --emitDeclarationOnly --outDir temp && api-extractor run && rimraf temp",
|
20
21
|
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path . --lerna-package plugin-react",
|
21
22
|
"release": "ts-node ../../scripts/release.ts"
|
@@ -33,13 +34,13 @@
|
|
33
34
|
},
|
34
35
|
"homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-react#readme",
|
35
36
|
"dependencies": {
|
36
|
-
"@babel/core": "^7.16.
|
37
|
-
"@babel/plugin-transform-react-jsx": "^7.16.
|
38
|
-
"@babel/plugin-transform-react-jsx-development": "^7.16.
|
39
|
-
"@babel/plugin-transform-react-jsx-self": "^7.16.
|
40
|
-
"@babel/plugin-transform-react-jsx-source": "^7.16.
|
37
|
+
"@babel/core": "^7.16.12",
|
38
|
+
"@babel/plugin-transform-react-jsx": "^7.16.7",
|
39
|
+
"@babel/plugin-transform-react-jsx-development": "^7.16.7",
|
40
|
+
"@babel/plugin-transform-react-jsx-self": "^7.16.7",
|
41
|
+
"@babel/plugin-transform-react-jsx-source": "^7.16.7",
|
41
42
|
"@rollup/pluginutils": "^4.1.2",
|
42
43
|
"react-refresh": "^0.11.0",
|
43
|
-
"resolve": "^1.
|
44
|
+
"resolve": "^1.22.0"
|
44
45
|
}
|
45
46
|
}
|
package/src/index.ts
CHANGED
@@ -60,6 +60,7 @@ export type BabelOptions = Omit<
|
|
60
60
|
export interface ReactBabelOptions extends BabelOptions {
|
61
61
|
plugins: Extract<BabelOptions['plugins'], any[]>
|
62
62
|
presets: Extract<BabelOptions['presets'], any[]>
|
63
|
+
overrides: Extract<BabelOptions['overrides'], any[]>
|
63
64
|
parserOpts: ParserOptions & {
|
64
65
|
plugins: Extract<ParserOptions['plugins'], any[]>
|
65
66
|
}
|
@@ -95,6 +96,7 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
|
|
95
96
|
|
96
97
|
babelOptions.plugins ||= []
|
97
98
|
babelOptions.presets ||= []
|
99
|
+
babelOptions.overrides ||= []
|
98
100
|
babelOptions.parserOpts ||= {} as any
|
99
101
|
babelOptions.parserOpts.plugins ||= opts.parserPlugins || []
|
100
102
|
|
@@ -366,5 +368,8 @@ function loadPlugin(path: string): Promise<any> {
|
|
366
368
|
}
|
367
369
|
|
368
370
|
// overwrite for cjs require('...')() usage
|
369
|
-
|
370
|
-
|
371
|
+
// The following lines are inserted by scripts/patchEsbuildDist.ts,
|
372
|
+
// this doesn't bundle correctly after esbuild 0.14.4
|
373
|
+
//
|
374
|
+
// module.exports = viteReact
|
375
|
+
// viteReact['default'] = viteReact
|