@vitejs/plugin-react 2.0.0-alpha.0 → 2.0.0-alpha.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/index.cjs CHANGED
@@ -5,6 +5,7 @@ const pluginutils = require('@rollup/pluginutils');
5
5
  const resolve = require('resolve');
6
6
  const fs = require('fs');
7
7
  const path = require('path');
8
+ const module$1 = require('module');
8
9
 
9
10
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
10
11
 
@@ -26,7 +27,8 @@ const fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
26
27
  const path__default = /*#__PURE__*/_interopDefaultLegacy(path);
27
28
 
28
29
  const runtimePublicPath = "/@react-refresh";
29
- const reactRefreshDir = path__default.dirname(require.resolve("react-refresh/package.json"));
30
+ const _require = module$1.createRequire((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index.cjs', document.baseURI).href)));
31
+ const reactRefreshDir = path__default.dirname(_require.resolve("react-refresh/package.json"));
30
32
  const runtimeFilePath = path__default.join(reactRefreshDir, "cjs/react-refresh-runtime.development.js");
31
33
  const runtimeCode = `
32
34
  const exports = {}
package/dist/index.mjs CHANGED
@@ -3,9 +3,11 @@ import { createFilter } from '@rollup/pluginutils';
3
3
  import resolve from 'resolve';
4
4
  import fs from 'fs';
5
5
  import path from 'path';
6
+ import { createRequire } from 'module';
6
7
 
7
8
  const runtimePublicPath = "/@react-refresh";
8
- const reactRefreshDir = path.dirname(require.resolve("react-refresh/package.json"));
9
+ const _require = createRequire(import.meta.url);
10
+ const reactRefreshDir = path.dirname(_require.resolve("react-refresh/package.json"));
9
11
  const runtimeFilePath = path.join(reactRefreshDir, "cjs/react-refresh-runtime.development.js");
10
12
  const runtimeCode = `
11
13
  const exports = {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitejs/plugin-react",
3
- "version": "2.0.0-alpha.0",
3
+ "version": "2.0.0-alpha.1",
4
4
  "license": "MIT",
5
5
  "author": "Evan You",
6
6
  "contributors": [
@@ -1,11 +1,13 @@
1
1
  import fs from 'fs'
2
2
  import path from 'path'
3
+ import { createRequire } from 'module'
3
4
  import type { types as t } from '@babel/core'
4
5
 
5
6
  export const runtimePublicPath = '/@react-refresh'
6
7
 
8
+ const _require = createRequire(import.meta.url)
7
9
  const reactRefreshDir = path.dirname(
8
- require.resolve('react-refresh/package.json')
10
+ _require.resolve('react-refresh/package.json')
9
11
  )
10
12
  const runtimeFilePath = path.join(
11
13
  reactRefreshDir,
@@ -1,5 +1,4 @@
1
1
  import type * as babelCore from '@babel/core'
2
- import type { Visitor, types as t } from '@babel/core'
3
2
 
4
3
  /**
5
4
  * Replace this:
@@ -11,13 +10,13 @@ import type { Visitor, types as t } from '@babel/core'
11
10
  * var _jsx = require("react/jsx-runtime").jsx
12
11
  */
13
12
  export function babelImportToRequire({ types: t }: typeof babelCore): {
14
- visitor: Visitor
13
+ visitor: babelCore.Visitor
15
14
  } {
16
15
  return {
17
16
  visitor: {
18
17
  ImportDeclaration(path) {
19
18
  const decl = path.node
20
- const spec = decl.specifiers[0] as t.ImportSpecifier
19
+ const spec = decl.specifiers[0] as babelCore.types.ImportSpecifier
21
20
 
22
21
  path.replaceWith(
23
22
  t.variableDeclaration('var', [
@@ -1,9 +1,11 @@
1
1
  import type * as babelCore from '@babel/core'
2
- import type { PluginItem, types as t } from '@babel/core'
3
2
 
4
- type RestoredJSX = [result: t.File | null | undefined, isCommonJS: boolean]
3
+ type RestoredJSX = [
4
+ result: babelCore.types.File | null | undefined,
5
+ isCommonJS: boolean
6
+ ]
5
7
 
6
- let babelRestoreJSX: Promise<PluginItem> | undefined
8
+ let babelRestoreJSX: Promise<babelCore.PluginItem> | undefined
7
9
 
8
10
  const jsxNotFound: RestoredJSX = [null, false]
9
11