@vitejs/plugin-react 1.3.0 → 1.3.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/README.md CHANGED
@@ -75,7 +75,7 @@ react({
75
75
  })
76
76
  ```
77
77
 
78
- This option does not enable _code transformation_. That is handled by ESBuild.
78
+ This option does not enable _code transformation_. That is handled by esbuild.
79
79
 
80
80
  **Note:** TypeScript syntax is handled automatically.
81
81
 
package/dist/index.js CHANGED
@@ -151,12 +151,12 @@ function babel_restore_jsx_default({ types: t }) {
151
151
  const isPlainObjectExpression = (node) => t.isObjectExpression(node) && node.properties.every((property) => t.isSpreadElement(property) || t.isObjectProperty(property, { computed: false }) && getJSXIdentifier(property.key) != null && getJSXAttributeValue(property.value) != null);
152
152
  return {
153
153
  visitor: {
154
- CallExpression(path) {
155
- const node = getJSXNode(path.node);
154
+ CallExpression(path2) {
155
+ const node = getJSXNode(path2.node);
156
156
  if (node == null) {
157
157
  return null;
158
158
  }
159
- path.replaceWith(node);
159
+ path2.replaceWith(node);
160
160
  }
161
161
  }
162
162
  };
@@ -179,8 +179,10 @@ var import_resolve = __toESM(require("resolve"));
179
179
 
180
180
  // src/fast-refresh.ts
181
181
  var import_fs = __toESM(require("fs"));
182
+ var import_path = __toESM(require("path"));
182
183
  var runtimePublicPath = "/@react-refresh";
183
- var runtimeFilePath = require.resolve("react-refresh/cjs/react-refresh-runtime.development.js");
184
+ var reactRefreshDir = import_path.default.dirname(require.resolve("react-refresh/package.json"));
185
+ var runtimeFilePath = import_path.default.join(reactRefreshDir, "cjs/react-refresh-runtime.development.js");
184
186
  var runtimeCode = `
185
187
  const exports = {}
186
188
  ${import_fs.default.readFileSync(runtimeFilePath, "utf-8")}
@@ -268,10 +270,10 @@ function isComponentLikeName(name) {
268
270
  function babelImportToRequire({ types: t }) {
269
271
  return {
270
272
  visitor: {
271
- ImportDeclaration(path) {
272
- const decl = path.node;
273
+ ImportDeclaration(path2) {
274
+ const decl = path2.node;
273
275
  const spec = decl.specifiers[0];
274
- path.replaceWith(t.variableDeclaration("var", [
276
+ path2.replaceWith(t.variableDeclaration("var", [
275
277
  t.variableDeclarator(spec.local, t.memberExpression(t.callExpression(t.identifier("require"), [decl.source]), spec.imported))
276
278
  ]));
277
279
  }
@@ -388,7 +390,7 @@ function viteReact(opts = {}) {
388
390
  if (isReactModule && filter(id)) {
389
391
  useFastRefresh = true;
390
392
  plugins.push([
391
- await loadPlugin("react-refresh/babel.js"),
393
+ await loadPlugin("react-refresh/babel"),
392
394
  { skipEnvCheck: true }
393
395
  ]);
394
396
  }
@@ -529,8 +531,8 @@ function viteReact(opts = {}) {
529
531
  return [viteBabel, viteReactRefresh, useAutomaticRuntime && viteReactJsx];
530
532
  }
531
533
  viteReact.preambleCode = preambleCode;
532
- function loadPlugin(path) {
533
- return Promise.resolve().then(() => __toESM(require(path))).then((module2) => module2.default || module2);
534
+ function loadPlugin(path2) {
535
+ return Promise.resolve().then(() => __toESM(require(path2))).then((module2) => module2.default || module2);
534
536
  }
535
537
  // Annotate the CommonJS export names for ESM import in node:
536
538
  0 && (module.exports = {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitejs/plugin-react",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "license": "MIT",
5
5
  "author": "Evan You",
6
6
  "contributors": [
@@ -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.17.8",
36
+ "@babel/core": "^7.17.9",
37
37
  "@babel/plugin-transform-react-jsx": "^7.17.3",
38
38
  "@babel/plugin-transform-react-jsx-development": "^7.16.7",
39
39
  "@babel/plugin-transform-react-jsx-self": "^7.16.7",
40
40
  "@babel/plugin-transform-react-jsx-source": "^7.16.7",
41
41
  "@rollup/pluginutils": "^4.2.0",
42
- "react-refresh": "^0.11.0",
42
+ "react-refresh": "^0.12.0",
43
43
  "resolve": "^1.22.0"
44
44
  }
45
45
  }
@@ -1,10 +1,15 @@
1
1
  import type { types as t } from '@babel/core'
2
2
  import fs from 'fs'
3
+ import path from 'path'
3
4
 
4
5
  export const runtimePublicPath = '/@react-refresh'
5
6
 
6
- const runtimeFilePath = require.resolve(
7
- 'react-refresh/cjs/react-refresh-runtime.development.js'
7
+ const reactRefreshDir = path.dirname(
8
+ require.resolve('react-refresh/package.json')
9
+ )
10
+ const runtimeFilePath = path.join(
11
+ reactRefreshDir,
12
+ 'cjs/react-refresh-runtime.development.js'
8
13
  )
9
14
 
10
15
  export const runtimeCode = `
package/src/index.ts CHANGED
@@ -176,7 +176,7 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
176
176
  if (isReactModule && filter(id)) {
177
177
  useFastRefresh = true
178
178
  plugins.push([
179
- await loadPlugin('react-refresh/babel.js'),
179
+ await loadPlugin('react-refresh/babel'),
180
180
  { skipEnvCheck: true }
181
181
  ])
182
182
  }