@vitejs/plugin-react 1.0.9 → 1.1.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/CHANGELOG.md +8 -6
- package/dist/index.js +7 -6
- package/package.json +8 -8
- package/src/index.ts +7 -6
package/CHANGELOG.md
CHANGED
@@ -1,22 +1,24 @@
|
|
1
|
-
## [1.
|
1
|
+
## [1.1.1](https://github.com/vitejs/vite/compare/plugin-react@1.1.0...plugin-react@1.1.1) (2021-12-07)
|
2
2
|
|
3
3
|
|
4
|
-
### Bug Fixes
|
5
4
|
|
6
|
-
|
5
|
+
# [1.1.0](https://github.com/vitejs/vite/compare/plugin-react@1.1.0-beta.1...plugin-react@1.1.0) (2021-11-22)
|
7
6
|
|
8
7
|
|
9
8
|
|
10
|
-
|
9
|
+
# [1.1.0-beta.1](https://github.com/vitejs/vite/compare/plugin-react@1.1.0-beta.0...plugin-react@1.1.0-beta.1) (2021-11-19)
|
11
10
|
|
12
11
|
|
13
12
|
### Bug Fixes
|
14
13
|
|
15
|
-
* **plugin-react:** apply `babel.plugins` to project files only ([#5255](https://github.com/vitejs/vite/issues/5255)) ([
|
14
|
+
* **plugin-react:** apply `babel.plugins` to project files only ([#5255](https://github.com/vitejs/vite/issues/5255)) ([377d0be](https://github.com/vitejs/vite/commit/377d0be5cf85a50240e160beaaafda77b7199452))
|
15
|
+
* **plugin-react:** remove querystring from sourcemap filename ([#5760](https://github.com/vitejs/vite/issues/5760)) ([d93a9fa](https://github.com/vitejs/vite/commit/d93a9fab8986f3659e79d7b0b065e99ef625a5dd))
|
16
|
+
* **plugin-react:** restore usage of extension instead of id ([#5761](https://github.com/vitejs/vite/issues/5761)) ([59471b1](https://github.com/vitejs/vite/commit/59471b186612d3da0083543e23d660747d3287f3))
|
17
|
+
* **plugin-react:** uncompiled JSX in linked pkgs ([#5669](https://github.com/vitejs/vite/issues/5669)) ([41a7c9c](https://github.com/vitejs/vite/commit/41a7c9ccfbc1a7bc60aec672056eac3966ddd036))
|
16
18
|
|
17
19
|
|
18
20
|
|
19
|
-
|
21
|
+
# [1.1.0-beta.0](https://github.com/vitejs/vite/compare/plugin-react@1.0.6...plugin-react@1.1.0-beta.0) (2021-10-28)
|
20
22
|
|
21
23
|
|
22
24
|
### Bug Fixes
|
package/dist/index.js
CHANGED
@@ -358,15 +358,16 @@ function viteReact(opts = {}) {
|
|
358
358
|
}
|
359
359
|
config.plugins.forEach((plugin) => (plugin.name === "react-refresh" || plugin !== viteReactJsx && plugin.name === "vite:react-jsx") && config.logger.warn(`[@vitejs/plugin-react] You should stop using "${plugin.name}" since this plugin conflicts with it.`));
|
360
360
|
},
|
361
|
-
async transform(code, id,
|
361
|
+
async transform(code, id, options) {
|
362
362
|
var _a2, _b2, _c2, _d;
|
363
|
+
const ssr = typeof options === "boolean" ? options : (options == null ? void 0 : options.ssr) === true;
|
363
364
|
const [filepath, querystring = ""] = id.split("?");
|
364
365
|
const [extension = ""] = querystring.match(fileExtensionRE) || filepath.match(fileExtensionRE) || [];
|
365
366
|
if (/\.(mjs|[tj]sx?)$/.test(extension)) {
|
366
367
|
const isJSX = extension.endsWith("x");
|
367
368
|
const isNodeModules = id.includes("/node_modules/");
|
368
369
|
const isProjectFile = !isNodeModules && (id[0] === "\0" || id.startsWith(projectRoot + "/"));
|
369
|
-
|
370
|
+
const plugins = isProjectFile ? [...userPlugins] : [];
|
370
371
|
let useFastRefresh = false;
|
371
372
|
if (!skipFastRefresh && !ssr && !isNodeModules) {
|
372
373
|
const isReactModule = isJSX || code.includes("react");
|
@@ -415,13 +416,13 @@ function viteReact(opts = {}) {
|
|
415
416
|
"classPrivateProperties",
|
416
417
|
"classPrivateMethods"
|
417
418
|
];
|
418
|
-
if (!
|
419
|
+
if (!extension.endsWith(".ts")) {
|
419
420
|
parserPlugins.push("jsx");
|
420
421
|
}
|
421
|
-
if (/\.tsx?$/.test(
|
422
|
+
if (/\.tsx?$/.test(extension)) {
|
422
423
|
parserPlugins.push("typescript");
|
423
424
|
}
|
424
|
-
const isReasonReact =
|
425
|
+
const isReasonReact = extension.endsWith(".bs.js");
|
425
426
|
const babelOpts = __spreadProps(__spreadValues({
|
426
427
|
babelrc: false,
|
427
428
|
configFile: false
|
@@ -429,7 +430,7 @@ function viteReact(opts = {}) {
|
|
429
430
|
ast: !isReasonReact,
|
430
431
|
root: projectRoot,
|
431
432
|
filename: id,
|
432
|
-
sourceFileName:
|
433
|
+
sourceFileName: filepath,
|
433
434
|
parserOpts: __spreadProps(__spreadValues({}, (_c2 = opts.babel) == null ? void 0 : _c2.parserOpts), {
|
434
435
|
sourceType: "module",
|
435
436
|
allowAwaitOutsideFunction: true,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vitejs/plugin-react",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.1.1",
|
4
4
|
"license": "MIT",
|
5
5
|
"author": "Evan You",
|
6
6
|
"contributors": [
|
@@ -18,7 +18,7 @@
|
|
18
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",
|
19
19
|
"build-types": "tsc -p . --emitDeclarationOnly --outDir temp && api-extractor run && rimraf temp",
|
20
20
|
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path . --lerna-package plugin-react",
|
21
|
-
"release": "node ../../scripts/release.
|
21
|
+
"release": "node ../../scripts/release.cjs"
|
22
22
|
},
|
23
23
|
"engines": {
|
24
24
|
"node": ">=12.0.0"
|
@@ -33,13 +33,13 @@
|
|
33
33
|
},
|
34
34
|
"homepage": "https://github.com/vitejs/vite/tree/main/packages/plugin-react#readme",
|
35
35
|
"dependencies": {
|
36
|
-
"@babel/core": "^7.
|
37
|
-
"@babel/plugin-transform-react-jsx": "^7.
|
38
|
-
"@babel/plugin-transform-react-jsx-development": "^7.
|
39
|
-
"@babel/plugin-transform-react-jsx-self": "^7.
|
40
|
-
"@babel/plugin-transform-react-jsx-source": "^7.
|
36
|
+
"@babel/core": "^7.16.0",
|
37
|
+
"@babel/plugin-transform-react-jsx": "^7.16.0",
|
38
|
+
"@babel/plugin-transform-react-jsx-development": "^7.16.0",
|
39
|
+
"@babel/plugin-transform-react-jsx-self": "^7.16.0",
|
40
|
+
"@babel/plugin-transform-react-jsx-source": "^7.16.0",
|
41
41
|
"@rollup/pluginutils": "^4.1.1",
|
42
|
-
"react-refresh": "^0.
|
42
|
+
"react-refresh": "^0.11.0",
|
43
43
|
"resolve": "^1.20.0"
|
44
44
|
}
|
45
45
|
}
|
package/src/index.ts
CHANGED
@@ -98,7 +98,8 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
|
|
98
98
|
)
|
99
99
|
)
|
100
100
|
},
|
101
|
-
async transform(code, id,
|
101
|
+
async transform(code, id, options) {
|
102
|
+
const ssr = typeof options === 'boolean' ? options : options?.ssr === true
|
102
103
|
// File extension could be mocked/overriden in querystring.
|
103
104
|
const [filepath, querystring = ''] = id.split('?')
|
104
105
|
const [extension = ''] =
|
@@ -112,7 +113,7 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
|
|
112
113
|
const isProjectFile =
|
113
114
|
!isNodeModules && (id[0] === '\0' || id.startsWith(projectRoot + '/'))
|
114
115
|
|
115
|
-
|
116
|
+
const plugins = isProjectFile ? [...userPlugins] : []
|
116
117
|
|
117
118
|
let useFastRefresh = false
|
118
119
|
if (!skipFastRefresh && !ssr && !isNodeModules) {
|
@@ -197,15 +198,15 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
|
|
197
198
|
'classPrivateMethods'
|
198
199
|
]
|
199
200
|
|
200
|
-
if (!
|
201
|
+
if (!extension.endsWith('.ts')) {
|
201
202
|
parserPlugins.push('jsx')
|
202
203
|
}
|
203
204
|
|
204
|
-
if (/\.tsx?$/.test(
|
205
|
+
if (/\.tsx?$/.test(extension)) {
|
205
206
|
parserPlugins.push('typescript')
|
206
207
|
}
|
207
208
|
|
208
|
-
const isReasonReact =
|
209
|
+
const isReasonReact = extension.endsWith('.bs.js')
|
209
210
|
|
210
211
|
const babelOpts: TransformOptions = {
|
211
212
|
babelrc: false,
|
@@ -214,7 +215,7 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
|
|
214
215
|
ast: !isReasonReact,
|
215
216
|
root: projectRoot,
|
216
217
|
filename: id,
|
217
|
-
sourceFileName:
|
218
|
+
sourceFileName: filepath,
|
218
219
|
parserOpts: {
|
219
220
|
...opts.babel?.parserOpts,
|
220
221
|
sourceType: 'module',
|