Initial commit
This commit is contained in:
21
node_modules/@vitejs/plugin-react/LICENSE
generated
vendored
Normal file
21
node_modules/@vitejs/plugin-react/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
128
node_modules/@vitejs/plugin-react/README.md
generated
vendored
Normal file
128
node_modules/@vitejs/plugin-react/README.md
generated
vendored
Normal file
@ -0,0 +1,128 @@
|
||||
# @vitejs/plugin-react [](https://npmjs.com/package/@vitejs/plugin-react)
|
||||
|
||||
The default Vite plugin for React projects.
|
||||
|
||||
- enable [Fast Refresh](https://www.npmjs.com/package/react-refresh) in development (requires react >= 16.9)
|
||||
- use the [automatic JSX runtime](https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html)
|
||||
- use custom Babel plugins/presets
|
||||
- small installation size
|
||||
|
||||
```js
|
||||
// vite.config.js
|
||||
import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
})
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
### include/exclude
|
||||
|
||||
Includes `.js`, `.jsx`, `.ts` & `.tsx` by default. This option can be used to add fast refresh to `.mdx` files:
|
||||
|
||||
```js
|
||||
import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
import mdx from '@mdx-js/rollup'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
{ enforce: 'pre', ...mdx() },
|
||||
react({ include: /\.(mdx|js|jsx|ts|tsx)$/ }),
|
||||
],
|
||||
})
|
||||
```
|
||||
|
||||
> `node_modules` are never processed by this plugin (but esbuild will)
|
||||
|
||||
### jsxImportSource
|
||||
|
||||
Control where the JSX factory is imported from. Default to `'react'`
|
||||
|
||||
```js
|
||||
react({ jsxImportSource: '@emotion/react' })
|
||||
```
|
||||
|
||||
### jsxRuntime
|
||||
|
||||
By default, the plugin uses the [automatic JSX runtime](https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html). However, if you encounter any issues, you may opt out using the `jsxRuntime` option.
|
||||
|
||||
```js
|
||||
react({ jsxRuntime: 'classic' })
|
||||
```
|
||||
|
||||
### babel
|
||||
|
||||
The `babel` option lets you add plugins, presets, and [other configuration](https://babeljs.io/docs/en/options) to the Babel transformation performed on each included file.
|
||||
|
||||
```js
|
||||
react({
|
||||
babel: {
|
||||
presets: [...],
|
||||
// Your plugins run before any built-in transform (eg: Fast Refresh)
|
||||
plugins: [...],
|
||||
// Use .babelrc files
|
||||
babelrc: true,
|
||||
// Use babel.config.js files
|
||||
configFile: true,
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
Note: When not using plugins, only esbuild is used for production builds, resulting in faster builds.
|
||||
|
||||
#### Proposed syntax
|
||||
|
||||
If you are using ES syntax that are still in proposal status (e.g. class properties), you can selectively enable them with the `babel.parserOpts.plugins` option:
|
||||
|
||||
```js
|
||||
react({
|
||||
babel: {
|
||||
parserOpts: {
|
||||
plugins: ['decorators-legacy'],
|
||||
},
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
This option does not enable _code transformation_. That is handled by esbuild.
|
||||
|
||||
**Note:** TypeScript syntax is handled automatically.
|
||||
|
||||
Here's the [complete list of Babel parser plugins](https://babeljs.io/docs/en/babel-parser#ecmascript-proposalshttpsgithubcombabelproposals).
|
||||
|
||||
## Middleware mode
|
||||
|
||||
In [middleware mode](https://vitejs.dev/config/server-options.html#server-middlewaremode), you should make sure your entry `index.html` file is transformed by Vite. Here's an example for an Express server:
|
||||
|
||||
```js
|
||||
app.get('/', async (req, res, next) => {
|
||||
try {
|
||||
let html = fs.readFileSync(path.resolve(root, 'index.html'), 'utf-8')
|
||||
|
||||
// Transform HTML using Vite plugins.
|
||||
html = await viteServer.transformIndexHtml(req.url, html)
|
||||
|
||||
res.send(html)
|
||||
} catch (e) {
|
||||
return next(e)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
Otherwise, you'll probably get this error:
|
||||
|
||||
```
|
||||
Uncaught Error: @vitejs/plugin-react can't detect preamble. Something is wrong.
|
||||
```
|
||||
|
||||
## Consistent components exports
|
||||
|
||||
For React refresh to work correctly, your file should only export React components. You can find a good explanation in the [Gatsby docs](https://www.gatsbyjs.com/docs/reference/local-development/fast-refresh/#how-it-works).
|
||||
|
||||
If an incompatible change in exports is found, the module will be invalidated and HMR will propagate. To make it easier to export simple constants alongside your component, the module is only invalidated when their value changes.
|
||||
|
||||
You can catch mistakes and get more detailed warning with this [eslint rule](https://github.com/ArnaudBarre/eslint-plugin-react-refresh).
|
||||
341
node_modules/@vitejs/plugin-react/dist/index.cjs
generated
vendored
Normal file
341
node_modules/@vitejs/plugin-react/dist/index.cjs
generated
vendored
Normal file
@ -0,0 +1,341 @@
|
||||
'use strict';
|
||||
|
||||
const vite = require('vite');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const node_module = require('node:module');
|
||||
|
||||
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
||||
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
||||
|
||||
const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
||||
const path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
||||
|
||||
const runtimePublicPath = "/@react-refresh";
|
||||
const _require = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
||||
const reactRefreshDir = path__default.dirname(
|
||||
_require.resolve("react-refresh/package.json")
|
||||
);
|
||||
const runtimeFilePath = path__default.join(
|
||||
reactRefreshDir,
|
||||
"cjs/react-refresh-runtime.development.js"
|
||||
);
|
||||
const runtimeCode = `
|
||||
const exports = {}
|
||||
${fs__default.readFileSync(runtimeFilePath, "utf-8")}
|
||||
${fs__default.readFileSync(_require.resolve("./refreshUtils.js"), "utf-8")}
|
||||
export default exports
|
||||
`;
|
||||
const preambleCode = `
|
||||
import RefreshRuntime from "__BASE__${runtimePublicPath.slice(1)}"
|
||||
RefreshRuntime.injectIntoGlobalHook(window)
|
||||
window.$RefreshReg$ = () => {}
|
||||
window.$RefreshSig$ = () => (type) => type
|
||||
window.__vite_plugin_react_preamble_installed__ = true
|
||||
`;
|
||||
const sharedHeader = `
|
||||
import RefreshRuntime from "${runtimePublicPath}";
|
||||
|
||||
const inWebWorker = typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope;
|
||||
`.replace(/\n+/g, "");
|
||||
const functionHeader = `
|
||||
let prevRefreshReg;
|
||||
let prevRefreshSig;
|
||||
|
||||
if (import.meta.hot && !inWebWorker) {
|
||||
if (!window.__vite_plugin_react_preamble_installed__) {
|
||||
throw new Error(
|
||||
"@vitejs/plugin-react can't detect preamble. Something is wrong. " +
|
||||
"See https://github.com/vitejs/vite-plugin-react/pull/11#discussion_r430879201"
|
||||
);
|
||||
}
|
||||
|
||||
prevRefreshReg = window.$RefreshReg$;
|
||||
prevRefreshSig = window.$RefreshSig$;
|
||||
window.$RefreshReg$ = (type, id) => {
|
||||
RefreshRuntime.register(type, __SOURCE__ + " " + id)
|
||||
};
|
||||
window.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
|
||||
}`.replace(/\n+/g, "");
|
||||
const functionFooter = `
|
||||
if (import.meta.hot && !inWebWorker) {
|
||||
window.$RefreshReg$ = prevRefreshReg;
|
||||
window.$RefreshSig$ = prevRefreshSig;
|
||||
}`;
|
||||
const sharedFooter = (id) => `
|
||||
if (import.meta.hot && !inWebWorker) {
|
||||
RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {
|
||||
RefreshRuntime.registerExportsForReactRefresh(${JSON.stringify(
|
||||
id
|
||||
)}, currentExports);
|
||||
import.meta.hot.accept((nextExports) => {
|
||||
if (!nextExports) return;
|
||||
const invalidateMessage = RefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate(${JSON.stringify(
|
||||
id
|
||||
)}, currentExports, nextExports);
|
||||
if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage);
|
||||
});
|
||||
});
|
||||
}`;
|
||||
function addRefreshWrapper(code, id) {
|
||||
return sharedHeader + functionHeader.replace("__SOURCE__", JSON.stringify(id)) + code + functionFooter + sharedFooter(id);
|
||||
}
|
||||
function addClassComponentRefreshWrapper(code, id) {
|
||||
return sharedHeader + code + sharedFooter(id);
|
||||
}
|
||||
|
||||
let babel;
|
||||
async function loadBabel() {
|
||||
if (!babel) {
|
||||
babel = await import('@babel/core');
|
||||
}
|
||||
return babel;
|
||||
}
|
||||
const reactCompRE = /extends\s+(?:React\.)?(?:Pure)?Component/;
|
||||
const refreshContentRE = /\$Refresh(?:Reg|Sig)\$\(/;
|
||||
const defaultIncludeRE = /\.[tj]sx?$/;
|
||||
const tsRE = /\.tsx?$/;
|
||||
function viteReact(opts = {}) {
|
||||
let devBase = "/";
|
||||
const filter = vite.createFilter(opts.include ?? defaultIncludeRE, opts.exclude);
|
||||
const jsxImportSource = opts.jsxImportSource ?? "react";
|
||||
const jsxImportRuntime = `${jsxImportSource}/jsx-runtime`;
|
||||
const jsxImportDevRuntime = `${jsxImportSource}/jsx-dev-runtime`;
|
||||
let isProduction = true;
|
||||
let projectRoot = process.cwd();
|
||||
let skipFastRefresh = false;
|
||||
let runPluginOverrides;
|
||||
let staticBabelOptions;
|
||||
const importReactRE = /\bimport\s+(?:\*\s+as\s+)?React\b/;
|
||||
const viteBabel = {
|
||||
name: "vite:react-babel",
|
||||
enforce: "pre",
|
||||
config() {
|
||||
if (opts.jsxRuntime === "classic") {
|
||||
return {
|
||||
esbuild: {
|
||||
jsx: "transform"
|
||||
}
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
esbuild: {
|
||||
jsx: "automatic",
|
||||
jsxImportSource: opts.jsxImportSource
|
||||
},
|
||||
optimizeDeps: { esbuildOptions: { jsx: "automatic" } }
|
||||
};
|
||||
}
|
||||
},
|
||||
configResolved(config) {
|
||||
devBase = config.base;
|
||||
projectRoot = config.root;
|
||||
isProduction = config.isProduction;
|
||||
skipFastRefresh = isProduction || config.command === "build" || config.server.hmr === false;
|
||||
if ("jsxPure" in opts) {
|
||||
config.logger.warnOnce(
|
||||
"[@vitejs/plugin-react] jsxPure was removed. You can configure esbuild.jsxSideEffects directly."
|
||||
);
|
||||
}
|
||||
const hooks = config.plugins.map((plugin) => plugin.api?.reactBabel).filter(defined);
|
||||
if (hooks.length > 0) {
|
||||
runPluginOverrides = (babelOptions, context) => {
|
||||
hooks.forEach((hook) => hook(babelOptions, context, config));
|
||||
};
|
||||
} else if (typeof opts.babel !== "function") {
|
||||
staticBabelOptions = createBabelOptions(opts.babel);
|
||||
}
|
||||
},
|
||||
async transform(code, id, options) {
|
||||
if (id.includes("/node_modules/"))
|
||||
return;
|
||||
const [filepath] = id.split("?");
|
||||
if (!filter(filepath))
|
||||
return;
|
||||
const ssr = options?.ssr === true;
|
||||
const babelOptions = (() => {
|
||||
if (staticBabelOptions)
|
||||
return staticBabelOptions;
|
||||
const newBabelOptions = createBabelOptions(
|
||||
typeof opts.babel === "function" ? opts.babel(id, { ssr }) : opts.babel
|
||||
);
|
||||
runPluginOverrides?.(newBabelOptions, { id, ssr });
|
||||
return newBabelOptions;
|
||||
})();
|
||||
const plugins = [...babelOptions.plugins];
|
||||
const isJSX = filepath.endsWith("x");
|
||||
const useFastRefresh = !skipFastRefresh && !ssr && (isJSX || (opts.jsxRuntime === "classic" ? importReactRE.test(code) : code.includes(jsxImportDevRuntime) || code.includes(jsxImportRuntime)));
|
||||
if (useFastRefresh) {
|
||||
plugins.push([
|
||||
await loadPlugin("react-refresh/babel"),
|
||||
{ skipEnvCheck: true }
|
||||
]);
|
||||
}
|
||||
if (opts.jsxRuntime === "classic" && isJSX) {
|
||||
if (!isProduction) {
|
||||
plugins.push(
|
||||
await loadPlugin("@babel/plugin-transform-react-jsx-self"),
|
||||
await loadPlugin("@babel/plugin-transform-react-jsx-source")
|
||||
);
|
||||
}
|
||||
}
|
||||
if (!plugins.length && !babelOptions.presets.length && !babelOptions.configFile && !babelOptions.babelrc) {
|
||||
return;
|
||||
}
|
||||
const parserPlugins = [...babelOptions.parserOpts.plugins];
|
||||
if (!filepath.endsWith(".ts")) {
|
||||
parserPlugins.push("jsx");
|
||||
}
|
||||
if (tsRE.test(filepath)) {
|
||||
parserPlugins.push("typescript");
|
||||
}
|
||||
const babel2 = await loadBabel();
|
||||
const result = await babel2.transformAsync(code, {
|
||||
...babelOptions,
|
||||
root: projectRoot,
|
||||
filename: id,
|
||||
sourceFileName: filepath,
|
||||
// Required for esbuild.jsxDev to provide correct line numbers
|
||||
// This crates issues the react compiler because the re-order is too important
|
||||
// People should use @babel/plugin-transform-react-jsx-development to get back good line numbers
|
||||
retainLines: getReactCompilerPlugin(plugins) != null ? false : !isProduction && isJSX && opts.jsxRuntime !== "classic",
|
||||
parserOpts: {
|
||||
...babelOptions.parserOpts,
|
||||
sourceType: "module",
|
||||
allowAwaitOutsideFunction: true,
|
||||
plugins: parserPlugins
|
||||
},
|
||||
generatorOpts: {
|
||||
...babelOptions.generatorOpts,
|
||||
decoratorsBeforeExport: true
|
||||
},
|
||||
plugins,
|
||||
sourceMaps: true
|
||||
});
|
||||
if (result) {
|
||||
let code2 = result.code;
|
||||
if (useFastRefresh) {
|
||||
if (refreshContentRE.test(code2)) {
|
||||
code2 = addRefreshWrapper(code2, id);
|
||||
} else if (reactCompRE.test(code2)) {
|
||||
code2 = addClassComponentRefreshWrapper(code2, id);
|
||||
}
|
||||
}
|
||||
return { code: code2, map: result.map };
|
||||
}
|
||||
}
|
||||
};
|
||||
const dependencies = [
|
||||
"react",
|
||||
"react-dom",
|
||||
jsxImportDevRuntime,
|
||||
jsxImportRuntime
|
||||
];
|
||||
const staticBabelPlugins = typeof opts.babel === "object" ? opts.babel?.plugins ?? [] : [];
|
||||
const reactCompilerPlugin = getReactCompilerPlugin(staticBabelPlugins);
|
||||
if (reactCompilerPlugin != null) {
|
||||
const reactCompilerRuntimeModule = getReactCompilerRuntimeModule(reactCompilerPlugin);
|
||||
dependencies.push(reactCompilerRuntimeModule);
|
||||
}
|
||||
const viteReactRefresh = {
|
||||
name: "vite:react-refresh",
|
||||
enforce: "pre",
|
||||
config: (userConfig) => ({
|
||||
build: silenceUseClientWarning(userConfig),
|
||||
optimizeDeps: {
|
||||
include: dependencies
|
||||
},
|
||||
resolve: {
|
||||
dedupe: ["react", "react-dom"]
|
||||
}
|
||||
}),
|
||||
resolveId(id) {
|
||||
if (id === runtimePublicPath) {
|
||||
return id;
|
||||
}
|
||||
},
|
||||
load(id) {
|
||||
if (id === runtimePublicPath) {
|
||||
return runtimeCode;
|
||||
}
|
||||
},
|
||||
transformIndexHtml() {
|
||||
if (!skipFastRefresh)
|
||||
return [
|
||||
{
|
||||
tag: "script",
|
||||
attrs: { type: "module" },
|
||||
children: preambleCode.replace(`__BASE__`, devBase)
|
||||
}
|
||||
];
|
||||
}
|
||||
};
|
||||
return [viteBabel, viteReactRefresh];
|
||||
}
|
||||
viteReact.preambleCode = preambleCode;
|
||||
const silenceUseClientWarning = (userConfig) => ({
|
||||
rollupOptions: {
|
||||
onwarn(warning, defaultHandler) {
|
||||
if (warning.code === "MODULE_LEVEL_DIRECTIVE" && warning.message.includes("use client")) {
|
||||
return;
|
||||
}
|
||||
if (warning.code === "SOURCEMAP_ERROR" && warning.message.includes("resolve original location") && warning.pos === 0) {
|
||||
return;
|
||||
}
|
||||
if (userConfig.build?.rollupOptions?.onwarn) {
|
||||
userConfig.build.rollupOptions.onwarn(warning, defaultHandler);
|
||||
} else {
|
||||
defaultHandler(warning);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
const loadedPlugin = /* @__PURE__ */ new Map();
|
||||
function loadPlugin(path) {
|
||||
const cached = loadedPlugin.get(path);
|
||||
if (cached)
|
||||
return cached;
|
||||
const promise = import(path).then((module) => {
|
||||
const value = module.default || module;
|
||||
loadedPlugin.set(path, value);
|
||||
return value;
|
||||
});
|
||||
loadedPlugin.set(path, promise);
|
||||
return promise;
|
||||
}
|
||||
function createBabelOptions(rawOptions) {
|
||||
var _a;
|
||||
const babelOptions = {
|
||||
babelrc: false,
|
||||
configFile: false,
|
||||
...rawOptions
|
||||
};
|
||||
babelOptions.plugins || (babelOptions.plugins = []);
|
||||
babelOptions.presets || (babelOptions.presets = []);
|
||||
babelOptions.overrides || (babelOptions.overrides = []);
|
||||
babelOptions.parserOpts || (babelOptions.parserOpts = {});
|
||||
(_a = babelOptions.parserOpts).plugins || (_a.plugins = []);
|
||||
return babelOptions;
|
||||
}
|
||||
function defined(value) {
|
||||
return value !== void 0;
|
||||
}
|
||||
function getReactCompilerPlugin(plugins) {
|
||||
return plugins.find(
|
||||
(p) => p === "babel-plugin-react-compiler" || Array.isArray(p) && p[0] === "babel-plugin-react-compiler"
|
||||
);
|
||||
}
|
||||
function getReactCompilerRuntimeModule(plugin) {
|
||||
let moduleName = "react/compiler-runtime";
|
||||
if (Array.isArray(plugin)) {
|
||||
if (plugin[1]?.target === "17" || plugin[1]?.target === "18") {
|
||||
moduleName = "react-compiler-runtime";
|
||||
} else if (typeof plugin[1]?.runtimeModule === "string") {
|
||||
moduleName = plugin[1]?.runtimeModule;
|
||||
}
|
||||
}
|
||||
return moduleName;
|
||||
}
|
||||
|
||||
module.exports = viteReact;
|
||||
module.exports.default = viteReact;
|
||||
54
node_modules/@vitejs/plugin-react/dist/index.d.cts
generated
vendored
Normal file
54
node_modules/@vitejs/plugin-react/dist/index.d.cts
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
import { TransformOptions, ParserOptions } from '@babel/core';
|
||||
import { PluginOption, ResolvedConfig } from 'vite';
|
||||
|
||||
interface Options {
|
||||
include?: string | RegExp | Array<string | RegExp>;
|
||||
exclude?: string | RegExp | Array<string | RegExp>;
|
||||
/**
|
||||
* Control where the JSX factory is imported from.
|
||||
* https://esbuild.github.io/api/#jsx-import-source
|
||||
* @default 'react'
|
||||
*/
|
||||
jsxImportSource?: string;
|
||||
/**
|
||||
* Note: Skipping React import with classic runtime is not supported from v4
|
||||
* @default "automatic"
|
||||
*/
|
||||
jsxRuntime?: 'classic' | 'automatic';
|
||||
/**
|
||||
* Babel configuration applied in both dev and prod.
|
||||
*/
|
||||
babel?: BabelOptions | ((id: string, options: {
|
||||
ssr?: boolean;
|
||||
}) => BabelOptions);
|
||||
}
|
||||
type BabelOptions = Omit<TransformOptions, 'ast' | 'filename' | 'root' | 'sourceFileName' | 'sourceMaps' | 'inputSourceMap'>;
|
||||
/**
|
||||
* The object type used by the `options` passed to plugins with
|
||||
* an `api.reactBabel` method.
|
||||
*/
|
||||
interface ReactBabelOptions extends BabelOptions {
|
||||
plugins: Extract<BabelOptions['plugins'], any[]>;
|
||||
presets: Extract<BabelOptions['presets'], any[]>;
|
||||
overrides: Extract<BabelOptions['overrides'], any[]>;
|
||||
parserOpts: ParserOptions & {
|
||||
plugins: Extract<ParserOptions['plugins'], any[]>;
|
||||
};
|
||||
}
|
||||
type ReactBabelHook = (babelConfig: ReactBabelOptions, context: ReactBabelHookContext, config: ResolvedConfig) => void;
|
||||
type ReactBabelHookContext = {
|
||||
ssr: boolean;
|
||||
id: string;
|
||||
};
|
||||
type ViteReactPluginApi = {
|
||||
/**
|
||||
* Manipulate the Babel options of `@vitejs/plugin-react`
|
||||
*/
|
||||
reactBabel?: ReactBabelHook;
|
||||
};
|
||||
declare function viteReact(opts?: Options): PluginOption[];
|
||||
declare namespace viteReact {
|
||||
var preambleCode: string;
|
||||
}
|
||||
|
||||
export { type BabelOptions, type Options, type ReactBabelOptions, type ViteReactPluginApi, viteReact as default };
|
||||
54
node_modules/@vitejs/plugin-react/dist/index.d.mts
generated
vendored
Normal file
54
node_modules/@vitejs/plugin-react/dist/index.d.mts
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
import { TransformOptions, ParserOptions } from '@babel/core';
|
||||
import { PluginOption, ResolvedConfig } from 'vite';
|
||||
|
||||
interface Options {
|
||||
include?: string | RegExp | Array<string | RegExp>;
|
||||
exclude?: string | RegExp | Array<string | RegExp>;
|
||||
/**
|
||||
* Control where the JSX factory is imported from.
|
||||
* https://esbuild.github.io/api/#jsx-import-source
|
||||
* @default 'react'
|
||||
*/
|
||||
jsxImportSource?: string;
|
||||
/**
|
||||
* Note: Skipping React import with classic runtime is not supported from v4
|
||||
* @default "automatic"
|
||||
*/
|
||||
jsxRuntime?: 'classic' | 'automatic';
|
||||
/**
|
||||
* Babel configuration applied in both dev and prod.
|
||||
*/
|
||||
babel?: BabelOptions | ((id: string, options: {
|
||||
ssr?: boolean;
|
||||
}) => BabelOptions);
|
||||
}
|
||||
type BabelOptions = Omit<TransformOptions, 'ast' | 'filename' | 'root' | 'sourceFileName' | 'sourceMaps' | 'inputSourceMap'>;
|
||||
/**
|
||||
* The object type used by the `options` passed to plugins with
|
||||
* an `api.reactBabel` method.
|
||||
*/
|
||||
interface ReactBabelOptions extends BabelOptions {
|
||||
plugins: Extract<BabelOptions['plugins'], any[]>;
|
||||
presets: Extract<BabelOptions['presets'], any[]>;
|
||||
overrides: Extract<BabelOptions['overrides'], any[]>;
|
||||
parserOpts: ParserOptions & {
|
||||
plugins: Extract<ParserOptions['plugins'], any[]>;
|
||||
};
|
||||
}
|
||||
type ReactBabelHook = (babelConfig: ReactBabelOptions, context: ReactBabelHookContext, config: ResolvedConfig) => void;
|
||||
type ReactBabelHookContext = {
|
||||
ssr: boolean;
|
||||
id: string;
|
||||
};
|
||||
type ViteReactPluginApi = {
|
||||
/**
|
||||
* Manipulate the Babel options of `@vitejs/plugin-react`
|
||||
*/
|
||||
reactBabel?: ReactBabelHook;
|
||||
};
|
||||
declare function viteReact(opts?: Options): PluginOption[];
|
||||
declare namespace viteReact {
|
||||
var preambleCode: string;
|
||||
}
|
||||
|
||||
export { type BabelOptions, type Options, type ReactBabelOptions, type ViteReactPluginApi, viteReact as default };
|
||||
54
node_modules/@vitejs/plugin-react/dist/index.d.ts
generated
vendored
Normal file
54
node_modules/@vitejs/plugin-react/dist/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
import { TransformOptions, ParserOptions } from '@babel/core';
|
||||
import { PluginOption, ResolvedConfig } from 'vite';
|
||||
|
||||
interface Options {
|
||||
include?: string | RegExp | Array<string | RegExp>;
|
||||
exclude?: string | RegExp | Array<string | RegExp>;
|
||||
/**
|
||||
* Control where the JSX factory is imported from.
|
||||
* https://esbuild.github.io/api/#jsx-import-source
|
||||
* @default 'react'
|
||||
*/
|
||||
jsxImportSource?: string;
|
||||
/**
|
||||
* Note: Skipping React import with classic runtime is not supported from v4
|
||||
* @default "automatic"
|
||||
*/
|
||||
jsxRuntime?: 'classic' | 'automatic';
|
||||
/**
|
||||
* Babel configuration applied in both dev and prod.
|
||||
*/
|
||||
babel?: BabelOptions | ((id: string, options: {
|
||||
ssr?: boolean;
|
||||
}) => BabelOptions);
|
||||
}
|
||||
type BabelOptions = Omit<TransformOptions, 'ast' | 'filename' | 'root' | 'sourceFileName' | 'sourceMaps' | 'inputSourceMap'>;
|
||||
/**
|
||||
* The object type used by the `options` passed to plugins with
|
||||
* an `api.reactBabel` method.
|
||||
*/
|
||||
interface ReactBabelOptions extends BabelOptions {
|
||||
plugins: Extract<BabelOptions['plugins'], any[]>;
|
||||
presets: Extract<BabelOptions['presets'], any[]>;
|
||||
overrides: Extract<BabelOptions['overrides'], any[]>;
|
||||
parserOpts: ParserOptions & {
|
||||
plugins: Extract<ParserOptions['plugins'], any[]>;
|
||||
};
|
||||
}
|
||||
type ReactBabelHook = (babelConfig: ReactBabelOptions, context: ReactBabelHookContext, config: ResolvedConfig) => void;
|
||||
type ReactBabelHookContext = {
|
||||
ssr: boolean;
|
||||
id: string;
|
||||
};
|
||||
type ViteReactPluginApi = {
|
||||
/**
|
||||
* Manipulate the Babel options of `@vitejs/plugin-react`
|
||||
*/
|
||||
reactBabel?: ReactBabelHook;
|
||||
};
|
||||
declare function viteReact(opts?: Options): PluginOption[];
|
||||
declare namespace viteReact {
|
||||
var preambleCode: string;
|
||||
}
|
||||
|
||||
export { type BabelOptions, type Options, type ReactBabelOptions, type ViteReactPluginApi, viteReact as default };
|
||||
332
node_modules/@vitejs/plugin-react/dist/index.mjs
generated
vendored
Normal file
332
node_modules/@vitejs/plugin-react/dist/index.mjs
generated
vendored
Normal file
@ -0,0 +1,332 @@
|
||||
import { createFilter } from 'vite';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { createRequire } from 'node:module';
|
||||
|
||||
const runtimePublicPath = "/@react-refresh";
|
||||
const _require = createRequire(import.meta.url);
|
||||
const reactRefreshDir = path.dirname(
|
||||
_require.resolve("react-refresh/package.json")
|
||||
);
|
||||
const runtimeFilePath = path.join(
|
||||
reactRefreshDir,
|
||||
"cjs/react-refresh-runtime.development.js"
|
||||
);
|
||||
const runtimeCode = `
|
||||
const exports = {}
|
||||
${fs.readFileSync(runtimeFilePath, "utf-8")}
|
||||
${fs.readFileSync(_require.resolve("./refreshUtils.js"), "utf-8")}
|
||||
export default exports
|
||||
`;
|
||||
const preambleCode = `
|
||||
import RefreshRuntime from "__BASE__${runtimePublicPath.slice(1)}"
|
||||
RefreshRuntime.injectIntoGlobalHook(window)
|
||||
window.$RefreshReg$ = () => {}
|
||||
window.$RefreshSig$ = () => (type) => type
|
||||
window.__vite_plugin_react_preamble_installed__ = true
|
||||
`;
|
||||
const sharedHeader = `
|
||||
import RefreshRuntime from "${runtimePublicPath}";
|
||||
|
||||
const inWebWorker = typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope;
|
||||
`.replace(/\n+/g, "");
|
||||
const functionHeader = `
|
||||
let prevRefreshReg;
|
||||
let prevRefreshSig;
|
||||
|
||||
if (import.meta.hot && !inWebWorker) {
|
||||
if (!window.__vite_plugin_react_preamble_installed__) {
|
||||
throw new Error(
|
||||
"@vitejs/plugin-react can't detect preamble. Something is wrong. " +
|
||||
"See https://github.com/vitejs/vite-plugin-react/pull/11#discussion_r430879201"
|
||||
);
|
||||
}
|
||||
|
||||
prevRefreshReg = window.$RefreshReg$;
|
||||
prevRefreshSig = window.$RefreshSig$;
|
||||
window.$RefreshReg$ = (type, id) => {
|
||||
RefreshRuntime.register(type, __SOURCE__ + " " + id)
|
||||
};
|
||||
window.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
|
||||
}`.replace(/\n+/g, "");
|
||||
const functionFooter = `
|
||||
if (import.meta.hot && !inWebWorker) {
|
||||
window.$RefreshReg$ = prevRefreshReg;
|
||||
window.$RefreshSig$ = prevRefreshSig;
|
||||
}`;
|
||||
const sharedFooter = (id) => `
|
||||
if (import.meta.hot && !inWebWorker) {
|
||||
RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {
|
||||
RefreshRuntime.registerExportsForReactRefresh(${JSON.stringify(
|
||||
id
|
||||
)}, currentExports);
|
||||
import.meta.hot.accept((nextExports) => {
|
||||
if (!nextExports) return;
|
||||
const invalidateMessage = RefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate(${JSON.stringify(
|
||||
id
|
||||
)}, currentExports, nextExports);
|
||||
if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage);
|
||||
});
|
||||
});
|
||||
}`;
|
||||
function addRefreshWrapper(code, id) {
|
||||
return sharedHeader + functionHeader.replace("__SOURCE__", JSON.stringify(id)) + code + functionFooter + sharedFooter(id);
|
||||
}
|
||||
function addClassComponentRefreshWrapper(code, id) {
|
||||
return sharedHeader + code + sharedFooter(id);
|
||||
}
|
||||
|
||||
let babel;
|
||||
async function loadBabel() {
|
||||
if (!babel) {
|
||||
babel = await import('@babel/core');
|
||||
}
|
||||
return babel;
|
||||
}
|
||||
const reactCompRE = /extends\s+(?:React\.)?(?:Pure)?Component/;
|
||||
const refreshContentRE = /\$Refresh(?:Reg|Sig)\$\(/;
|
||||
const defaultIncludeRE = /\.[tj]sx?$/;
|
||||
const tsRE = /\.tsx?$/;
|
||||
function viteReact(opts = {}) {
|
||||
let devBase = "/";
|
||||
const filter = createFilter(opts.include ?? defaultIncludeRE, opts.exclude);
|
||||
const jsxImportSource = opts.jsxImportSource ?? "react";
|
||||
const jsxImportRuntime = `${jsxImportSource}/jsx-runtime`;
|
||||
const jsxImportDevRuntime = `${jsxImportSource}/jsx-dev-runtime`;
|
||||
let isProduction = true;
|
||||
let projectRoot = process.cwd();
|
||||
let skipFastRefresh = false;
|
||||
let runPluginOverrides;
|
||||
let staticBabelOptions;
|
||||
const importReactRE = /\bimport\s+(?:\*\s+as\s+)?React\b/;
|
||||
const viteBabel = {
|
||||
name: "vite:react-babel",
|
||||
enforce: "pre",
|
||||
config() {
|
||||
if (opts.jsxRuntime === "classic") {
|
||||
return {
|
||||
esbuild: {
|
||||
jsx: "transform"
|
||||
}
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
esbuild: {
|
||||
jsx: "automatic",
|
||||
jsxImportSource: opts.jsxImportSource
|
||||
},
|
||||
optimizeDeps: { esbuildOptions: { jsx: "automatic" } }
|
||||
};
|
||||
}
|
||||
},
|
||||
configResolved(config) {
|
||||
devBase = config.base;
|
||||
projectRoot = config.root;
|
||||
isProduction = config.isProduction;
|
||||
skipFastRefresh = isProduction || config.command === "build" || config.server.hmr === false;
|
||||
if ("jsxPure" in opts) {
|
||||
config.logger.warnOnce(
|
||||
"[@vitejs/plugin-react] jsxPure was removed. You can configure esbuild.jsxSideEffects directly."
|
||||
);
|
||||
}
|
||||
const hooks = config.plugins.map((plugin) => plugin.api?.reactBabel).filter(defined);
|
||||
if (hooks.length > 0) {
|
||||
runPluginOverrides = (babelOptions, context) => {
|
||||
hooks.forEach((hook) => hook(babelOptions, context, config));
|
||||
};
|
||||
} else if (typeof opts.babel !== "function") {
|
||||
staticBabelOptions = createBabelOptions(opts.babel);
|
||||
}
|
||||
},
|
||||
async transform(code, id, options) {
|
||||
if (id.includes("/node_modules/"))
|
||||
return;
|
||||
const [filepath] = id.split("?");
|
||||
if (!filter(filepath))
|
||||
return;
|
||||
const ssr = options?.ssr === true;
|
||||
const babelOptions = (() => {
|
||||
if (staticBabelOptions)
|
||||
return staticBabelOptions;
|
||||
const newBabelOptions = createBabelOptions(
|
||||
typeof opts.babel === "function" ? opts.babel(id, { ssr }) : opts.babel
|
||||
);
|
||||
runPluginOverrides?.(newBabelOptions, { id, ssr });
|
||||
return newBabelOptions;
|
||||
})();
|
||||
const plugins = [...babelOptions.plugins];
|
||||
const isJSX = filepath.endsWith("x");
|
||||
const useFastRefresh = !skipFastRefresh && !ssr && (isJSX || (opts.jsxRuntime === "classic" ? importReactRE.test(code) : code.includes(jsxImportDevRuntime) || code.includes(jsxImportRuntime)));
|
||||
if (useFastRefresh) {
|
||||
plugins.push([
|
||||
await loadPlugin("react-refresh/babel"),
|
||||
{ skipEnvCheck: true }
|
||||
]);
|
||||
}
|
||||
if (opts.jsxRuntime === "classic" && isJSX) {
|
||||
if (!isProduction) {
|
||||
plugins.push(
|
||||
await loadPlugin("@babel/plugin-transform-react-jsx-self"),
|
||||
await loadPlugin("@babel/plugin-transform-react-jsx-source")
|
||||
);
|
||||
}
|
||||
}
|
||||
if (!plugins.length && !babelOptions.presets.length && !babelOptions.configFile && !babelOptions.babelrc) {
|
||||
return;
|
||||
}
|
||||
const parserPlugins = [...babelOptions.parserOpts.plugins];
|
||||
if (!filepath.endsWith(".ts")) {
|
||||
parserPlugins.push("jsx");
|
||||
}
|
||||
if (tsRE.test(filepath)) {
|
||||
parserPlugins.push("typescript");
|
||||
}
|
||||
const babel2 = await loadBabel();
|
||||
const result = await babel2.transformAsync(code, {
|
||||
...babelOptions,
|
||||
root: projectRoot,
|
||||
filename: id,
|
||||
sourceFileName: filepath,
|
||||
// Required for esbuild.jsxDev to provide correct line numbers
|
||||
// This crates issues the react compiler because the re-order is too important
|
||||
// People should use @babel/plugin-transform-react-jsx-development to get back good line numbers
|
||||
retainLines: getReactCompilerPlugin(plugins) != null ? false : !isProduction && isJSX && opts.jsxRuntime !== "classic",
|
||||
parserOpts: {
|
||||
...babelOptions.parserOpts,
|
||||
sourceType: "module",
|
||||
allowAwaitOutsideFunction: true,
|
||||
plugins: parserPlugins
|
||||
},
|
||||
generatorOpts: {
|
||||
...babelOptions.generatorOpts,
|
||||
decoratorsBeforeExport: true
|
||||
},
|
||||
plugins,
|
||||
sourceMaps: true
|
||||
});
|
||||
if (result) {
|
||||
let code2 = result.code;
|
||||
if (useFastRefresh) {
|
||||
if (refreshContentRE.test(code2)) {
|
||||
code2 = addRefreshWrapper(code2, id);
|
||||
} else if (reactCompRE.test(code2)) {
|
||||
code2 = addClassComponentRefreshWrapper(code2, id);
|
||||
}
|
||||
}
|
||||
return { code: code2, map: result.map };
|
||||
}
|
||||
}
|
||||
};
|
||||
const dependencies = [
|
||||
"react",
|
||||
"react-dom",
|
||||
jsxImportDevRuntime,
|
||||
jsxImportRuntime
|
||||
];
|
||||
const staticBabelPlugins = typeof opts.babel === "object" ? opts.babel?.plugins ?? [] : [];
|
||||
const reactCompilerPlugin = getReactCompilerPlugin(staticBabelPlugins);
|
||||
if (reactCompilerPlugin != null) {
|
||||
const reactCompilerRuntimeModule = getReactCompilerRuntimeModule(reactCompilerPlugin);
|
||||
dependencies.push(reactCompilerRuntimeModule);
|
||||
}
|
||||
const viteReactRefresh = {
|
||||
name: "vite:react-refresh",
|
||||
enforce: "pre",
|
||||
config: (userConfig) => ({
|
||||
build: silenceUseClientWarning(userConfig),
|
||||
optimizeDeps: {
|
||||
include: dependencies
|
||||
},
|
||||
resolve: {
|
||||
dedupe: ["react", "react-dom"]
|
||||
}
|
||||
}),
|
||||
resolveId(id) {
|
||||
if (id === runtimePublicPath) {
|
||||
return id;
|
||||
}
|
||||
},
|
||||
load(id) {
|
||||
if (id === runtimePublicPath) {
|
||||
return runtimeCode;
|
||||
}
|
||||
},
|
||||
transformIndexHtml() {
|
||||
if (!skipFastRefresh)
|
||||
return [
|
||||
{
|
||||
tag: "script",
|
||||
attrs: { type: "module" },
|
||||
children: preambleCode.replace(`__BASE__`, devBase)
|
||||
}
|
||||
];
|
||||
}
|
||||
};
|
||||
return [viteBabel, viteReactRefresh];
|
||||
}
|
||||
viteReact.preambleCode = preambleCode;
|
||||
const silenceUseClientWarning = (userConfig) => ({
|
||||
rollupOptions: {
|
||||
onwarn(warning, defaultHandler) {
|
||||
if (warning.code === "MODULE_LEVEL_DIRECTIVE" && warning.message.includes("use client")) {
|
||||
return;
|
||||
}
|
||||
if (warning.code === "SOURCEMAP_ERROR" && warning.message.includes("resolve original location") && warning.pos === 0) {
|
||||
return;
|
||||
}
|
||||
if (userConfig.build?.rollupOptions?.onwarn) {
|
||||
userConfig.build.rollupOptions.onwarn(warning, defaultHandler);
|
||||
} else {
|
||||
defaultHandler(warning);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
const loadedPlugin = /* @__PURE__ */ new Map();
|
||||
function loadPlugin(path) {
|
||||
const cached = loadedPlugin.get(path);
|
||||
if (cached)
|
||||
return cached;
|
||||
const promise = import(path).then((module) => {
|
||||
const value = module.default || module;
|
||||
loadedPlugin.set(path, value);
|
||||
return value;
|
||||
});
|
||||
loadedPlugin.set(path, promise);
|
||||
return promise;
|
||||
}
|
||||
function createBabelOptions(rawOptions) {
|
||||
var _a;
|
||||
const babelOptions = {
|
||||
babelrc: false,
|
||||
configFile: false,
|
||||
...rawOptions
|
||||
};
|
||||
babelOptions.plugins || (babelOptions.plugins = []);
|
||||
babelOptions.presets || (babelOptions.presets = []);
|
||||
babelOptions.overrides || (babelOptions.overrides = []);
|
||||
babelOptions.parserOpts || (babelOptions.parserOpts = {});
|
||||
(_a = babelOptions.parserOpts).plugins || (_a.plugins = []);
|
||||
return babelOptions;
|
||||
}
|
||||
function defined(value) {
|
||||
return value !== void 0;
|
||||
}
|
||||
function getReactCompilerPlugin(plugins) {
|
||||
return plugins.find(
|
||||
(p) => p === "babel-plugin-react-compiler" || Array.isArray(p) && p[0] === "babel-plugin-react-compiler"
|
||||
);
|
||||
}
|
||||
function getReactCompilerRuntimeModule(plugin) {
|
||||
let moduleName = "react/compiler-runtime";
|
||||
if (Array.isArray(plugin)) {
|
||||
if (plugin[1]?.target === "17" || plugin[1]?.target === "18") {
|
||||
moduleName = "react-compiler-runtime";
|
||||
} else if (typeof plugin[1]?.runtimeModule === "string") {
|
||||
moduleName = plugin[1]?.runtimeModule;
|
||||
}
|
||||
}
|
||||
return moduleName;
|
||||
}
|
||||
|
||||
export { viteReact as default };
|
||||
93
node_modules/@vitejs/plugin-react/dist/refreshUtils.js
generated
vendored
Normal file
93
node_modules/@vitejs/plugin-react/dist/refreshUtils.js
generated
vendored
Normal file
@ -0,0 +1,93 @@
|
||||
function debounce(fn, delay) {
|
||||
let handle
|
||||
return () => {
|
||||
clearTimeout(handle)
|
||||
handle = setTimeout(fn, delay)
|
||||
}
|
||||
}
|
||||
|
||||
/* eslint-disable no-undef */
|
||||
const hooks = []
|
||||
window.__registerBeforePerformReactRefresh = (cb) => {
|
||||
hooks.push(cb)
|
||||
}
|
||||
const enqueueUpdate = debounce(async () => {
|
||||
if (hooks.length) await Promise.all(hooks.map((cb) => cb()))
|
||||
exports.performReactRefresh()
|
||||
}, 16)
|
||||
|
||||
// Taken from https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/lib/runtime/RefreshUtils.js#L141
|
||||
// This allows to resister components not detected by SWC like styled component
|
||||
function registerExportsForReactRefresh(filename, moduleExports) {
|
||||
for (const key in moduleExports) {
|
||||
if (key === '__esModule') continue
|
||||
const exportValue = moduleExports[key]
|
||||
if (exports.isLikelyComponentType(exportValue)) {
|
||||
// 'export' is required to avoid key collision when renamed exports that
|
||||
// shadow a local component name: https://github.com/vitejs/vite-plugin-react/issues/116
|
||||
// The register function has an identity check to not register twice the same component,
|
||||
// so this is safe to not used the same key here.
|
||||
exports.register(exportValue, filename + ' export ' + key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function validateRefreshBoundaryAndEnqueueUpdate(id, prevExports, nextExports) {
|
||||
const ignoredExports = window.__getReactRefreshIgnoredExports?.({ id }) ?? []
|
||||
if (
|
||||
predicateOnExport(
|
||||
ignoredExports,
|
||||
prevExports,
|
||||
(key) => key in nextExports,
|
||||
) !== true
|
||||
) {
|
||||
return 'Could not Fast Refresh (export removed)'
|
||||
}
|
||||
if (
|
||||
predicateOnExport(
|
||||
ignoredExports,
|
||||
nextExports,
|
||||
(key) => key in prevExports,
|
||||
) !== true
|
||||
) {
|
||||
return 'Could not Fast Refresh (new export)'
|
||||
}
|
||||
|
||||
let hasExports = false
|
||||
const allExportsAreComponentsOrUnchanged = predicateOnExport(
|
||||
ignoredExports,
|
||||
nextExports,
|
||||
(key, value) => {
|
||||
hasExports = true
|
||||
if (exports.isLikelyComponentType(value)) return true
|
||||
return prevExports[key] === nextExports[key]
|
||||
},
|
||||
)
|
||||
if (hasExports && allExportsAreComponentsOrUnchanged === true) {
|
||||
enqueueUpdate()
|
||||
} else {
|
||||
return `Could not Fast Refresh ("${allExportsAreComponentsOrUnchanged}" export is incompatible). Learn more at https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react#consistent-components-exports`
|
||||
}
|
||||
}
|
||||
|
||||
function predicateOnExport(ignoredExports, moduleExports, predicate) {
|
||||
for (const key in moduleExports) {
|
||||
if (key === '__esModule') continue
|
||||
if (ignoredExports.includes(key)) continue
|
||||
const desc = Object.getOwnPropertyDescriptor(moduleExports, key)
|
||||
if (desc && desc.get) return key
|
||||
if (!predicate(key, moduleExports[key])) return key
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Hides vite-ignored dynamic import so that Vite can skip analysis if no other
|
||||
// dynamic import is present (https://github.com/vitejs/vite/pull/12732)
|
||||
function __hmr_import(module) {
|
||||
return import(/* @vite-ignore */ module)
|
||||
}
|
||||
|
||||
exports.__hmr_import = __hmr_import
|
||||
exports.registerExportsForReactRefresh = registerExportsForReactRefresh
|
||||
exports.validateRefreshBoundaryAndEnqueueUpdate =
|
||||
validateRefreshBoundaryAndEnqueueUpdate
|
||||
53
node_modules/@vitejs/plugin-react/package.json
generated
vendored
Normal file
53
node_modules/@vitejs/plugin-react/package.json
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
{
|
||||
"name": "@vitejs/plugin-react",
|
||||
"version": "4.3.3",
|
||||
"license": "MIT",
|
||||
"author": "Evan You",
|
||||
"contributors": [
|
||||
"Alec Larson",
|
||||
"Arnaud Barré"
|
||||
],
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/index.mjs",
|
||||
"require": "./dist/index.cjs"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "unbuild --stub",
|
||||
"build": "unbuild && pnpm run patch-cjs && tsx scripts/copyRefreshUtils.ts",
|
||||
"patch-cjs": "tsx ../../scripts/patchCJS.ts",
|
||||
"prepublishOnly": "npm run build"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.18.0 || >=16.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/vitejs/vite-plugin-react.git",
|
||||
"directory": "packages/plugin-react"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/vitejs/vite-plugin-react/issues"
|
||||
},
|
||||
"homepage": "https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react#readme",
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.25.2",
|
||||
"@babel/plugin-transform-react-jsx-self": "^7.24.7",
|
||||
"@babel/plugin-transform-react-jsx-source": "^7.24.7",
|
||||
"@types/babel__core": "^7.20.5",
|
||||
"react-refresh": "^0.14.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vite": "^4.2.0 || ^5.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"unbuild": "^2.0.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user