mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-21 14:13:36 +08:00
chore:更换到主分支
This commit is contained in:
13
node_modules/vite/dist/node/build/buildPluginAsset.d.ts
generated
vendored
13
node_modules/vite/dist/node/build/buildPluginAsset.d.ts
generated
vendored
@@ -1,13 +0,0 @@
|
||||
/// <reference types="node" />
|
||||
import { Plugin, OutputBundle } from 'rollup';
|
||||
import { InternalResolver } from '../resolver';
|
||||
interface AssetCacheEntry {
|
||||
content?: Buffer;
|
||||
fileName?: string;
|
||||
url: string | undefined;
|
||||
}
|
||||
export declare const injectAssetRe: RegExp;
|
||||
export declare const resolveAsset: (id: string, root: string, publicBase: string, assetsDir: string, inlineLimit: number) => Promise<AssetCacheEntry>;
|
||||
export declare const registerAssets: (assets: Map<string, Buffer>, bundle: OutputBundle) => void;
|
||||
export declare const createBuildAssetPlugin: (root: string, resolver: InternalResolver, publicBase: string, assetsDir: string, inlineLimit: number) => Plugin;
|
||||
export {};
|
||||
106
node_modules/vite/dist/node/build/buildPluginAsset.js
generated
vendored
106
node_modules/vite/dist/node/build/buildPluginAsset.js
generated
vendored
@@ -1,106 +0,0 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createBuildAssetPlugin = exports.registerAssets = exports.resolveAsset = exports.injectAssetRe = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const utils_1 = require("../utils");
|
||||
const slash_1 = __importDefault(require("slash"));
|
||||
const mime_types_1 = __importDefault(require("mime-types"));
|
||||
const debug = require('debug')('vite:build:asset');
|
||||
const assetResolveCache = new Map();
|
||||
const publicDirRE = /^public(\/|\\)/;
|
||||
exports.injectAssetRe = /import.meta.ROLLUP_FILE_URL_(\w+)/;
|
||||
exports.resolveAsset = async (id, root, publicBase, assetsDir, inlineLimit) => {
|
||||
id = utils_1.cleanUrl(id);
|
||||
const cached = assetResolveCache.get(id);
|
||||
if (cached) {
|
||||
return cached;
|
||||
}
|
||||
let resolved;
|
||||
const relativePath = path_1.default.relative(root, id);
|
||||
if (!fs_extra_1.default.existsSync(id)) {
|
||||
// try resolving from public dir
|
||||
const publicDirPath = path_1.default.join(root, 'public', relativePath);
|
||||
if (fs_extra_1.default.existsSync(publicDirPath)) {
|
||||
// file is resolved from public dir, it will be copied verbatim so no
|
||||
// need to read content here.
|
||||
resolved = {
|
||||
url: publicBase + slash_1.default(relativePath)
|
||||
};
|
||||
}
|
||||
}
|
||||
if (!resolved) {
|
||||
if (publicDirRE.test(relativePath)) {
|
||||
resolved = {
|
||||
url: publicBase + slash_1.default(relativePath.replace(publicDirRE, ''))
|
||||
};
|
||||
}
|
||||
}
|
||||
if (!resolved) {
|
||||
let url;
|
||||
let content = await fs_extra_1.default.readFile(id);
|
||||
if (!id.endsWith(`.svg`) && content.length < Number(inlineLimit)) {
|
||||
url = `data:${mime_types_1.default.lookup(id)};base64,${content.toString('base64')}`;
|
||||
content = undefined;
|
||||
}
|
||||
resolved = {
|
||||
content,
|
||||
fileName: path_1.default.basename(id),
|
||||
url
|
||||
};
|
||||
}
|
||||
assetResolveCache.set(id, resolved);
|
||||
return resolved;
|
||||
};
|
||||
exports.registerAssets = (assets, bundle) => {
|
||||
for (const [fileName, source] of assets) {
|
||||
bundle[fileName] = {
|
||||
name: fileName,
|
||||
isAsset: true,
|
||||
type: 'asset',
|
||||
fileName,
|
||||
source
|
||||
};
|
||||
}
|
||||
};
|
||||
exports.createBuildAssetPlugin = (root, resolver, publicBase, assetsDir, inlineLimit) => {
|
||||
const handleToIdMap = new Map();
|
||||
return {
|
||||
name: 'vite:asset',
|
||||
async load(id) {
|
||||
if (resolver.isAssetRequest(id)) {
|
||||
let { fileName, content, url } = await exports.resolveAsset(id, root, publicBase, assetsDir, inlineLimit);
|
||||
if (!url && fileName && content) {
|
||||
const fileHandle = this.emitFile({
|
||||
name: fileName,
|
||||
type: 'asset',
|
||||
source: content
|
||||
});
|
||||
url = 'import.meta.ROLLUP_FILE_URL_' + fileHandle;
|
||||
handleToIdMap.set(fileHandle, id);
|
||||
}
|
||||
else if (url && url.startsWith(`data:`)) {
|
||||
debug(`${id} -> base64 inlined`);
|
||||
}
|
||||
return `export default ${JSON.stringify(url)}`;
|
||||
}
|
||||
},
|
||||
async renderChunk(code) {
|
||||
let match;
|
||||
while ((match = exports.injectAssetRe.exec(code))) {
|
||||
const fileHandle = match[1];
|
||||
const outputFilepath = publicBase + slash_1.default(path_1.default.join(assetsDir, this.getFileName(fileHandle)));
|
||||
code = code.replace(match[0], outputFilepath);
|
||||
const originalId = handleToIdMap.get(fileHandle);
|
||||
if (originalId) {
|
||||
debug(`${originalId} -> ${outputFilepath}`);
|
||||
}
|
||||
}
|
||||
return { code, map: null };
|
||||
}
|
||||
};
|
||||
};
|
||||
//# sourceMappingURL=buildPluginAsset.js.map
|
||||
1
node_modules/vite/dist/node/build/buildPluginAsset.js.map
generated
vendored
1
node_modules/vite/dist/node/build/buildPluginAsset.js.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"buildPluginAsset.js","sourceRoot":"","sources":["../../../src/node/build/buildPluginAsset.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AACvB,wDAAyB;AAEzB,oCAAmC;AACnC,kDAAyB;AACzB,4DAA6B;AAG7B,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,kBAAkB,CAAC,CAAA;AAQlD,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAA2B,CAAA;AAC5D,MAAM,WAAW,GAAG,gBAAgB,CAAA;AACvB,QAAA,aAAa,GAAG,mCAAmC,CAAA;AAEnD,QAAA,YAAY,GAAG,KAAK,EAC/B,EAAU,EACV,IAAY,EACZ,UAAkB,EAClB,SAAiB,EACjB,WAAmB,EACO,EAAE;IAC5B,EAAE,GAAG,g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AC,CAAA;iBAClC;qBAAM,IAAI,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;oBACzC,KAAK,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAA;iBACjC;gBACD,OAAO,kBAAkB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAA;aAC/C;QACH,CAAC;QAED,KAAK,CAAC,WAAW,CAAC,IAAI;YACpB,IAAI,KAAK,CAAA;YACT,OAAO,CAAC,KAAK,GAAG,qBAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE;gBACzC,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;gBAC3B,MAAM,cAAc,GAClB,UAAU,GAAG,eAAK,CAAC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;gBACxE,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAA;gBAC7C,MAAM,UAAU,GAAG,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;gBAChD,IAAI,UAAU,EAAE;oBACd,KAAK,CAAC,GAAG,UAAU,OAAO,cAAc,EAAE,CAAC,CAAA;iBAC5C;aACF;YACD,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,CAAA;QAC5B,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
|
||||
16
node_modules/vite/dist/node/build/buildPluginCss.d.ts
generated
vendored
16
node_modules/vite/dist/node/build/buildPluginCss.d.ts
generated
vendored
@@ -1,16 +0,0 @@
|
||||
import { Plugin } from 'rollup';
|
||||
import { BuildConfig } from '../config';
|
||||
import { SFCAsyncStyleCompileOptions } from '@vue/compiler-sfc';
|
||||
import { CssPreprocessOptions } from '../config';
|
||||
interface BuildCssOption {
|
||||
root: string;
|
||||
publicBase: string;
|
||||
assetsDir: string;
|
||||
minify?: BuildConfig['minify'];
|
||||
inlineLimit?: number;
|
||||
cssCodeSplit?: boolean;
|
||||
preprocessOptions?: CssPreprocessOptions;
|
||||
modulesOptions?: SFCAsyncStyleCompileOptions['modulesOptions'];
|
||||
}
|
||||
export declare const createBuildCssPlugin: ({ root, publicBase, assetsDir, minify, inlineLimit, cssCodeSplit, preprocessOptions, modulesOptions }: BuildCssOption) => Plugin;
|
||||
export {};
|
||||
157
node_modules/vite/dist/node/build/buildPluginCss.js
generated
vendored
157
node_modules/vite/dist/node/build/buildPluginCss.js
generated
vendored
@@ -1,157 +0,0 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createBuildCssPlugin = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const buildPluginAsset_1 = require("./buildPluginAsset");
|
||||
const cssUtils_1 = require("../utils/cssUtils");
|
||||
const chalk_1 = __importDefault(require("chalk"));
|
||||
const pluginutils_1 = require("@rollup/pluginutils");
|
||||
const slash_1 = __importDefault(require("slash"));
|
||||
const debug = require('debug')('vite:build:css');
|
||||
const cssInjectionMarker = `__VITE_CSS__`;
|
||||
const cssInjectionRE = /__VITE_CSS__\(\)/g;
|
||||
exports.createBuildCssPlugin = ({ root, publicBase, assetsDir, minify = false, inlineLimit = 0, cssCodeSplit = true, preprocessOptions, modulesOptions = {} }) => {
|
||||
const styles = new Map();
|
||||
let staticCss = '';
|
||||
return {
|
||||
name: 'vite:css',
|
||||
async transform(css, id) {
|
||||
if (cssUtils_1.isCSSRequest(id)) {
|
||||
// if this is a Vue SFC style request, it's already processed by
|
||||
// rollup-plugin-vue and we just need to rewrite URLs + collect it
|
||||
const isVueStyle = /\?vue&type=style/.test(id);
|
||||
const preprocessLang = (id.match(cssUtils_1.cssPreprocessLangRE) ||
|
||||
[])[1];
|
||||
const result = isVueStyle
|
||||
? css
|
||||
: await cssUtils_1.compileCss(root, id, {
|
||||
id: '',
|
||||
source: css,
|
||||
filename: id,
|
||||
scoped: false,
|
||||
modules: cssUtils_1.cssModuleRE.test(id),
|
||||
preprocessLang,
|
||||
preprocessOptions,
|
||||
modulesOptions
|
||||
}, true);
|
||||
let modules;
|
||||
if (typeof result === 'string') {
|
||||
css = result;
|
||||
}
|
||||
else {
|
||||
if (result.errors.length) {
|
||||
console.error(`[vite] error applying css transforms: `);
|
||||
result.errors.forEach(console.error);
|
||||
}
|
||||
css = result.code;
|
||||
modules = result.modules;
|
||||
}
|
||||
// process url() - register referenced files as assets
|
||||
// and rewrite the url to the resolved public path
|
||||
if (cssUtils_1.urlRE.test(css)) {
|
||||
const fileDir = path_1.default.dirname(id);
|
||||
css = await cssUtils_1.rewriteCssUrls(css, async (rawUrl) => {
|
||||
const file = path_1.default.posix.isAbsolute(rawUrl)
|
||||
? path_1.default.join(root, rawUrl)
|
||||
: path_1.default.join(fileDir, rawUrl);
|
||||
let { fileName, content, url } = await buildPluginAsset_1.resolveAsset(file, root, publicBase, assetsDir, inlineLimit);
|
||||
if (!url && fileName && content) {
|
||||
url =
|
||||
'import.meta.ROLLUP_FILE_URL_' +
|
||||
this.emitFile({
|
||||
name: fileName,
|
||||
type: 'asset',
|
||||
source: content
|
||||
});
|
||||
}
|
||||
debug(`url(${rawUrl}) -> ${url.startsWith('data:') ? `base64 inlined` : `${file}`}`);
|
||||
return url;
|
||||
});
|
||||
}
|
||||
styles.set(id, css);
|
||||
return {
|
||||
code: modules
|
||||
? pluginutils_1.dataToEsm(modules, { namedExports: true })
|
||||
: (cssCodeSplit
|
||||
? // If code-splitting CSS, inject a fake marker to avoid the module
|
||||
// from being tree-shaken. This preserves the .css file as a
|
||||
// module in the chunk's metadata so that we can retrieve them in
|
||||
// renderChunk.
|
||||
`${cssInjectionMarker}()\n`
|
||||
: ``) + `export default ${JSON.stringify(css)}`,
|
||||
map: null,
|
||||
// #795 css always has side effect
|
||||
moduleSideEffects: true
|
||||
};
|
||||
}
|
||||
},
|
||||
async renderChunk(code, chunk) {
|
||||
let chunkCSS = '';
|
||||
for (const id in chunk.modules) {
|
||||
if (styles.has(id)) {
|
||||
chunkCSS += styles.get(id);
|
||||
}
|
||||
}
|
||||
let match;
|
||||
while ((match = buildPluginAsset_1.injectAssetRe.exec(chunkCSS))) {
|
||||
const outputFilepath = publicBase + slash_1.default(path_1.default.join(assetsDir, this.getFileName(match[1])));
|
||||
chunkCSS = chunkCSS.replace(match[0], outputFilepath);
|
||||
}
|
||||
if (cssCodeSplit) {
|
||||
code = code.replace(cssInjectionRE, '');
|
||||
// for each dynamic entry chunk, collect its css and inline it as JS
|
||||
// strings.
|
||||
if (chunk.isDynamicEntry && chunkCSS) {
|
||||
chunkCSS = minifyCSS(chunkCSS);
|
||||
code =
|
||||
`let ${cssInjectionMarker} = document.createElement('style');` +
|
||||
`${cssInjectionMarker}.innerHTML = ${JSON.stringify(chunkCSS)};` +
|
||||
`document.head.appendChild(${cssInjectionMarker});` +
|
||||
code;
|
||||
}
|
||||
else {
|
||||
staticCss += chunkCSS;
|
||||
}
|
||||
return {
|
||||
code,
|
||||
map: null
|
||||
};
|
||||
}
|
||||
else {
|
||||
staticCss += chunkCSS;
|
||||
return null;
|
||||
}
|
||||
},
|
||||
async generateBundle(_options, bundle) {
|
||||
// minify css
|
||||
if (minify && staticCss) {
|
||||
staticCss = minifyCSS(staticCss);
|
||||
}
|
||||
if (staticCss) {
|
||||
this.emitFile({
|
||||
name: 'style.css',
|
||||
type: 'asset',
|
||||
source: staticCss
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
let CleanCSS;
|
||||
function minifyCSS(css) {
|
||||
CleanCSS = CleanCSS || require('clean-css');
|
||||
const res = new CleanCSS({ level: 2, rebase: false }).minify(css);
|
||||
if (res.errors && res.errors.length) {
|
||||
console.error(chalk_1.default.red(`[vite] error when minifying css:`));
|
||||
console.error(res.errors);
|
||||
}
|
||||
if (res.warnings && res.warnings.length) {
|
||||
console.error(chalk_1.default.yellow(`[vite] warnings when minifying css:`));
|
||||
console.error(res.warnings);
|
||||
}
|
||||
return res.styles;
|
||||
}
|
||||
//# sourceMappingURL=buildPluginCss.js.map
|
||||
1
node_modules/vite/dist/node/build/buildPluginCss.js.map
generated
vendored
1
node_modules/vite/dist/node/build/buildPluginCss.js.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"buildPluginCss.js","sourceRoot":"","sources":["../../../src/node/build/buildPluginCss.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AAEvB,yDAAgE;AAEhE,gDAO0B;AAK1B,kDAAyB;AAEzB,qDAA+C;AAC/C,kDAAyB;AAEzB,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,gBAAgB,CAAC,CAAA;AAEhD,MAAM,kBAAkB,GAAG,cAAc,CAAA;AACzC,MAAM,cAAc,GAAG,mBAAmB,CAAA;AAa7B,QAAA,oBAAoB,GAAG,CAAC,EACnC,IAAI,EACJ,UAAU,EACV,SAAS,EACT,MAAM,GAAG,KAAK,EACd,WAAW,GAAG,CAAC,EACf,YAAY,GAAG,IAAI,EACnB,iBAAiB,EACjB,cAAc,GAAG,EAAE,EACJ,EAAU,EAAE;IAC3B,MAAM,MAAM,GAAwB,IAAI,GAAG,EAAE,CAAA;IAC7C,IAAI,SAAS,GAAG,EAAE,CAAA;IAElB,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,KAAK,CAAC,SAAS,CAAC,GAAW,EAAE,EAAU;YACrC,IAAI,uBAAY,CAAC,EAAE,CAAC,EAAE;gBACpB,gEAAgE;gBAChE,kEAAkE;gBAClE,MAAM,UAAU,GAAG,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;gBAC9C,MAAM,cAAc,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,8BAAmB,CAAC;oBACnD,EAAE,CAAC,CAAC,CAAC,CAAkD,CAAA;gBAEzD,M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AAI,EAAE,OAAO;oBACb,MAAM,EAAE,SAAS;iBAClB,CAAC,CAAA;aACH;QACH,CAAC;KACF,CAAA;AACH,CAAC,CAAA;AAED,IAAI,QAAa,CAAA;AAEjB,SAAS,SAAS,CAAC,GAAW;IAC5B,QAAQ,GAAG,QAAQ,IAAI,OAAO,CAAC,WAAW,CAAC,CAAA;IAC3C,MAAM,GAAG,GAAG,IAAI,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IAEjE,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE;QACnC,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC,CAAA;QAC5D,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;KAC1B;IAED,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE;QACvC,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,MAAM,CAAC,qCAAqC,CAAC,CAAC,CAAA;QAClE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;KAC5B;IAED,OAAO,GAAG,CAAC,MAAM,CAAA;AACnB,CAAC"}
|
||||
4
node_modules/vite/dist/node/build/buildPluginEsbuild.d.ts
generated
vendored
4
node_modules/vite/dist/node/build/buildPluginEsbuild.d.ts
generated
vendored
@@ -1,4 +0,0 @@
|
||||
import { Plugin } from 'rollup';
|
||||
import { SharedConfig } from '../config';
|
||||
export declare const createEsbuildPlugin: (jsx?: SharedConfig['jsx']) => Promise<Plugin>;
|
||||
export declare const createEsbuildRenderChunkPlugin: (target: string, minify: boolean) => Plugin;
|
||||
45
node_modules/vite/dist/node/build/buildPluginEsbuild.js
generated
vendored
45
node_modules/vite/dist/node/build/buildPluginEsbuild.js
generated
vendored
@@ -1,45 +0,0 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createEsbuildRenderChunkPlugin = exports.createEsbuildPlugin = void 0;
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const esbuildService_1 = require("../esbuildService");
|
||||
exports.createEsbuildPlugin = async (jsx = 'vue') => {
|
||||
const jsxConfig = esbuildService_1.resolveJsxOptions(jsx);
|
||||
return {
|
||||
name: 'vite:esbuild',
|
||||
resolveId(id) {
|
||||
if (id === esbuildService_1.vueJsxPublicPath) {
|
||||
return esbuildService_1.vueJsxPublicPath;
|
||||
}
|
||||
},
|
||||
load(id) {
|
||||
if (id === esbuildService_1.vueJsxPublicPath) {
|
||||
return fs_extra_1.default.readFileSync(esbuildService_1.vueJsxFilePath, 'utf-8');
|
||||
}
|
||||
},
|
||||
async transform(code, id) {
|
||||
const isVueTs = /\.vue\?/.test(id) && id.endsWith('lang.ts');
|
||||
if (esbuildService_1.tjsxRE.test(id) || isVueTs) {
|
||||
return esbuildService_1.transform(code, id, {
|
||||
...jsxConfig,
|
||||
...(isVueTs ? { loader: 'ts' } : null)
|
||||
}, jsx);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
exports.createEsbuildRenderChunkPlugin = (target, minify) => {
|
||||
return {
|
||||
name: 'vite:esbuild-transpile',
|
||||
async renderChunk(code, chunk) {
|
||||
return esbuildService_1.transform(code, chunk.fileName, {
|
||||
target,
|
||||
minify
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
//# sourceMappingURL=buildPluginEsbuild.js.map
|
||||
1
node_modules/vite/dist/node/build/buildPluginEsbuild.js.map
generated
vendored
1
node_modules/vite/dist/node/build/buildPluginEsbuild.js.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"buildPluginEsbuild.js","sourceRoot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ACF,CAAA;AACH,CAAC,CAAA"}
|
||||
10
node_modules/vite/dist/node/build/buildPluginHtml.d.ts
generated
vendored
10
node_modules/vite/dist/node/build/buildPluginHtml.d.ts
generated
vendored
@@ -1,10 +0,0 @@
|
||||
import { Plugin, OutputChunk, RollupOutput } from 'rollup';
|
||||
import { InternalResolver } from '../resolver';
|
||||
import { UserConfig } from '../config';
|
||||
export declare const createBuildHtmlPlugin: (root: string, indexPath: string, publicBasePath: string, assetsDir: string, inlineLimit: number, resolver: InternalResolver, shouldPreload: ((chunk: OutputChunk) => boolean) | null, config: UserConfig) => Promise<{
|
||||
renderIndex: () => string;
|
||||
htmlPlugin: null;
|
||||
} | {
|
||||
renderIndex: (bundleOutput: RollupOutput['output']) => Promise<string>;
|
||||
htmlPlugin: Plugin;
|
||||
}>;
|
||||
181
node_modules/vite/dist/node/build/buildPluginHtml.js
generated
vendored
181
node_modules/vite/dist/node/build/buildPluginHtml.js
generated
vendored
@@ -1,181 +0,0 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createBuildHtmlPlugin = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const magic_string_1 = __importDefault(require("magic-string"));
|
||||
const utils_1 = require("../utils");
|
||||
const buildPluginAsset_1 = require("./buildPluginAsset");
|
||||
exports.createBuildHtmlPlugin = async (root, indexPath, publicBasePath, assetsDir, inlineLimit, resolver, shouldPreload, config) => {
|
||||
if (!fs_extra_1.default.existsSync(indexPath)) {
|
||||
return {
|
||||
renderIndex: () => '',
|
||||
htmlPlugin: null
|
||||
};
|
||||
}
|
||||
const rawHtml = await fs_extra_1.default.readFile(indexPath, 'utf-8');
|
||||
const preprocessedHtml = await utils_1.transformIndexHtml(rawHtml, config.indexHtmlTransforms, 'pre', true);
|
||||
const assets = new Map();
|
||||
let { html: processedHtml, js } = await compileHtml(root, preprocessedHtml, publicBasePath, assetsDir, inlineLimit, resolver, assets);
|
||||
const htmlPlugin = {
|
||||
name: 'vite:html',
|
||||
async load(id) {
|
||||
if (id === indexPath) {
|
||||
return js;
|
||||
}
|
||||
},
|
||||
generateBundle(_options, bundle) {
|
||||
buildPluginAsset_1.registerAssets(assets, bundle);
|
||||
}
|
||||
};
|
||||
const injectCSS = (html, filename) => {
|
||||
const tag = `<link rel="stylesheet" href="${publicBasePath}${path_1.default.posix.join(assetsDir, filename)}">`;
|
||||
if (/<\/head>/.test(html)) {
|
||||
return html.replace(/<\/head>/, `${tag}\n</head>`);
|
||||
}
|
||||
else {
|
||||
return tag + '\n' + html;
|
||||
}
|
||||
};
|
||||
const injectScript = (html, filename) => {
|
||||
filename = utils_1.isExternalUrl(filename)
|
||||
? filename
|
||||
: `${publicBasePath}${path_1.default.posix.join(assetsDir, filename)}`;
|
||||
const tag = `<script type="module" src="${filename}"></script>`;
|
||||
if (/<\/head>/.test(html)) {
|
||||
return html.replace(/<\/head>/, `${tag}\n</head>`);
|
||||
}
|
||||
else {
|
||||
return html + '\n' + tag;
|
||||
}
|
||||
};
|
||||
const injectPreload = (html, filename) => {
|
||||
filename = utils_1.isExternalUrl(filename)
|
||||
? filename
|
||||
: `${publicBasePath}${path_1.default.posix.join(assetsDir, filename)}`;
|
||||
const tag = `<link rel="modulepreload" href="${filename}" />`;
|
||||
if (/<\/head>/.test(html)) {
|
||||
return html.replace(/<\/head>/, `${tag}\n</head>`);
|
||||
}
|
||||
else {
|
||||
return tag + '\n' + html;
|
||||
}
|
||||
};
|
||||
const renderIndex = async (bundleOutput) => {
|
||||
let result = processedHtml;
|
||||
for (const chunk of bundleOutput) {
|
||||
if (chunk.type === 'chunk') {
|
||||
if (chunk.isEntry) {
|
||||
// js entry chunk
|
||||
result = injectScript(result, chunk.fileName);
|
||||
}
|
||||
else if (shouldPreload && shouldPreload(chunk)) {
|
||||
// async preloaded chunk
|
||||
result = injectPreload(result, chunk.fileName);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// imported css chunks
|
||||
if (chunk.fileName.endsWith('.css') &&
|
||||
chunk.source &&
|
||||
!assets.has(chunk.fileName)) {
|
||||
result = injectCSS(result, chunk.fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
return await utils_1.transformIndexHtml(result, config.indexHtmlTransforms, 'post', true);
|
||||
};
|
||||
return {
|
||||
renderIndex,
|
||||
htmlPlugin
|
||||
};
|
||||
};
|
||||
// this extends the config in @vue/compiler-sfc with <link href>
|
||||
const assetAttrsConfig = {
|
||||
link: ['href'],
|
||||
video: ['src', 'poster'],
|
||||
source: ['src'],
|
||||
img: ['src'],
|
||||
image: ['xlink:href', 'href'],
|
||||
use: ['xlink:href', 'href']
|
||||
};
|
||||
// compile index.html to a JS module, importing referenced assets
|
||||
// and scripts
|
||||
const compileHtml = async (root, html, publicBasePath, assetsDir, inlineLimit, resolver, assets) => {
|
||||
const { parse, transform } = require('@vue/compiler-dom');
|
||||
// @vue/compiler-core doesn't like lowercase doctypes
|
||||
html = html.replace(/<!doctype\s/i, '<!DOCTYPE ');
|
||||
const ast = parse(html);
|
||||
let js = '';
|
||||
const s = new magic_string_1.default(html);
|
||||
const assetUrls = [];
|
||||
const viteHtmlTransform = (node) => {
|
||||
if (node.type === 1 /* ELEMENT */) {
|
||||
if (node.tag === 'script') {
|
||||
let shouldRemove = false;
|
||||
const srcAttr = node.props.find((p) => p.type === 6 /* ATTRIBUTE */ && p.name === 'src');
|
||||
const typeAttr = node.props.find((p) => p.type === 6 /* ATTRIBUTE */ && p.name === 'type');
|
||||
const isJsModule = typeAttr && typeAttr.value && typeAttr.value.content === 'module';
|
||||
if (isJsModule) {
|
||||
if (srcAttr && srcAttr.value) {
|
||||
if (!utils_1.isExternalUrl(srcAttr.value.content)) {
|
||||
// <script type="module" src="..."/>
|
||||
// add it as an import
|
||||
js += `\nimport ${JSON.stringify(srcAttr.value.content)}`;
|
||||
shouldRemove = true;
|
||||
}
|
||||
}
|
||||
else if (node.children.length) {
|
||||
// <script type="module">...</script>
|
||||
// add its content
|
||||
// TODO: if there are multiple inline module scripts on the page,
|
||||
// they should technically be turned into separate modules, but
|
||||
// it's hard to imagine any reason for anyone to do that.
|
||||
js += `\n` + node.children[0].content.trim() + `\n`;
|
||||
shouldRemove = true;
|
||||
}
|
||||
}
|
||||
if (shouldRemove) {
|
||||
// remove the script tag from the html. we are going to inject new
|
||||
// ones in the end.
|
||||
s.remove(node.loc.start.offset, node.loc.end.offset);
|
||||
}
|
||||
}
|
||||
// For asset references in index.html, also generate an import
|
||||
// statement for each - this will be handled by the asset plugin
|
||||
const assetAttrs = assetAttrsConfig[node.tag];
|
||||
if (assetAttrs) {
|
||||
for (const p of node.props) {
|
||||
if (p.type === 6 /* ATTRIBUTE */ &&
|
||||
p.value &&
|
||||
assetAttrs.includes(p.name) &&
|
||||
!utils_1.isExternalUrl(p.value.content) &&
|
||||
!utils_1.isDataUrl(p.value.content)) {
|
||||
assetUrls.push(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
transform(ast, {
|
||||
nodeTransforms: [viteHtmlTransform]
|
||||
});
|
||||
// for each encountered asset url, rewrite original html so that it
|
||||
// references the post-build location.
|
||||
for (const attr of assetUrls) {
|
||||
const value = attr.value;
|
||||
const { fileName, content, url } = await buildPluginAsset_1.resolveAsset(resolver.requestToFile(value.content), root, publicBasePath, assetsDir, utils_1.cleanUrl(value.content).endsWith('.css') ? 0 : inlineLimit);
|
||||
s.overwrite(value.loc.start.offset, value.loc.end.offset, `"${url}"`);
|
||||
if (fileName && content) {
|
||||
assets.set(fileName, content);
|
||||
}
|
||||
}
|
||||
return {
|
||||
html: s.toString(),
|
||||
js
|
||||
};
|
||||
};
|
||||
//# sourceMappingURL=buildPluginHtml.js.map
|
||||
1
node_modules/vite/dist/node/build/buildPluginHtml.js.map
generated
vendored
1
node_modules/vite/dist/node/build/buildPluginHtml.js.map
generated
vendored
File diff suppressed because one or more lines are too long
2
node_modules/vite/dist/node/build/buildPluginManifest.d.ts
generated
vendored
2
node_modules/vite/dist/node/build/buildPluginManifest.d.ts
generated
vendored
@@ -1,2 +0,0 @@
|
||||
import { Plugin } from 'rollup';
|
||||
export declare const createBuildManifestPlugin: () => Plugin;
|
||||
26
node_modules/vite/dist/node/build/buildPluginManifest.js
generated
vendored
26
node_modules/vite/dist/node/build/buildPluginManifest.js
generated
vendored
@@ -1,26 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createBuildManifestPlugin = void 0;
|
||||
exports.createBuildManifestPlugin = () => {
|
||||
const manifest = {};
|
||||
return {
|
||||
name: 'vite:manifest',
|
||||
generateBundle(_options, bundle) {
|
||||
for (const name in bundle) {
|
||||
const chunk = bundle[name];
|
||||
if (chunk.type === 'chunk') {
|
||||
manifest[chunk.name + '.js'] = chunk.fileName;
|
||||
}
|
||||
else {
|
||||
manifest[chunk.name] = chunk.fileName;
|
||||
}
|
||||
}
|
||||
this.emitFile({
|
||||
fileName: 'manifest.json',
|
||||
type: 'asset',
|
||||
source: JSON.stringify(manifest, null, 2)
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
//# sourceMappingURL=buildPluginManifest.js.map
|
||||
1
node_modules/vite/dist/node/build/buildPluginManifest.js.map
generated
vendored
1
node_modules/vite/dist/node/build/buildPluginManifest.js.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"buildPluginManifest.js","sourceRoot":"","sources":["../../../src/node/build/buildPluginManifest.ts"],"names":[],"mappings":";;;AAEa,QAAA,yBAAyB,GAAG,GAAW,EAAE;IACpD,MAAM,QAAQ,GAA2B,EAAE,CAAA;IAC3C,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,cAAc,CAAC,QAAQ,EAAE,MAAM;YAC7B,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE;gBACzB,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;gBAC1B,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE;oBAC1B,QAAQ,CAAC,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAA;iBAC9C;qBAAM;oBACL,QAAQ,CAAC,KAAK,CAAC,IAAK,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAA;iBACvC;aACF;YACD,IAAI,CAAC,QAAQ,CAAC;gBACZ,QAAQ,EAAE,eAAe;gBACzB,IAAI,EAAE,OAAO;gBACb,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;aAC1C,CAAC,CAAA;QACJ,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
|
||||
2
node_modules/vite/dist/node/build/buildPluginReplace.d.ts
generated
vendored
2
node_modules/vite/dist/node/build/buildPluginReplace.d.ts
generated
vendored
@@ -1,2 +0,0 @@
|
||||
import { Plugin } from 'rollup';
|
||||
export declare const createReplacePlugin: (test: (id: string) => boolean, replacements: Record<string, any>, sourcemap: boolean) => Plugin;
|
||||
42
node_modules/vite/dist/node/build/buildPluginReplace.js
generated
vendored
42
node_modules/vite/dist/node/build/buildPluginReplace.js
generated
vendored
@@ -1,42 +0,0 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createReplacePlugin = void 0;
|
||||
const magic_string_1 = __importDefault(require("magic-string"));
|
||||
exports.createReplacePlugin = (test, replacements, sourcemap) => {
|
||||
const pattern = new RegExp('\\b(' +
|
||||
Object.keys(replacements)
|
||||
.map((str) => {
|
||||
return str.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&');
|
||||
})
|
||||
.join('|') +
|
||||
')\\b', 'g');
|
||||
return {
|
||||
name: 'vite:replace',
|
||||
transform(code, id) {
|
||||
if (test(id)) {
|
||||
const s = new magic_string_1.default(code);
|
||||
let hasReplaced = false;
|
||||
let match;
|
||||
while ((match = pattern.exec(code))) {
|
||||
hasReplaced = true;
|
||||
const start = match.index;
|
||||
const end = start + match[0].length;
|
||||
const replacement = '' + replacements[match[1]];
|
||||
s.overwrite(start, end, replacement);
|
||||
}
|
||||
if (!hasReplaced) {
|
||||
return null;
|
||||
}
|
||||
const result = { code: s.toString() };
|
||||
if (sourcemap) {
|
||||
result.map = s.generateMap({ hires: true });
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
//# sourceMappingURL=buildPluginReplace.js.map
|
||||
1
node_modules/vite/dist/node/build/buildPluginReplace.js.map
generated
vendored
1
node_modules/vite/dist/node/build/buildPluginReplace.js.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"buildPluginReplace.js","sourceRoot":"","sources":["../../../src/node/build/buildPluginReplace.ts"],"names":[],"mappings":";;;;;;AACA,gEAAsC;AAEzB,QAAA,mBAAmB,GAAG,CACjC,IAA6B,EAC7B,YAAiC,EACjC,SAAkB,EACV,EAAE;IACV,MAAM,OAAO,GAAG,IAAI,MAAM,CACxB,MAAM;QACJ,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC;aACtB,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;YACX,OAAO,GAAG,CAAC,OAAO,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAA;QACrD,CAAC,CAAC;aACD,IAAI,CAAC,GAAG,CAAC;QACZ,MAAM,EACR,GAAG,CACJ,CAAA;IAED,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,SAAS,CAAC,IAAI,EAAE,EAAE;YAChB,IAAI,IAAI,CAAC,EAAE,CAAC,EAAE;gBACZ,MAAM,CAAC,GAAG,IAAI,sBAAW,CAAC,IAAI,CAAC,CAAA;gBAC/B,IAAI,WAAW,GAAG,KAAK,CAAA;gBACvB,IAAI,KAAK,CAAA;gBAET,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE;oBACnC,WAAW,GAAG,IAAI,CAAA;oBAClB,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;oBACzB,MAAM,GAAG,GAAG,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;oBACnC,MAAM,WAAW,GAAG,EAAE,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;oBAC/C,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,WAAW,CAAC,CAAA;iBACrC;gBAED,IAAI,CAAC,WAAW,EAAE;oBAChB,OAAO,IAAI,CAAA;iBACZ;gBAED,MAAM,MAAM,GAAoB,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAA;gBACtD,IAAI,SAAS,EAAE;oBACb,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;iBAC5C;gBACD,OAAO,MAAM,CAAA;aACd;QACH,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
|
||||
3
node_modules/vite/dist/node/build/buildPluginResolve.d.ts
generated
vendored
3
node_modules/vite/dist/node/build/buildPluginResolve.d.ts
generated
vendored
@@ -1,3 +0,0 @@
|
||||
import { Plugin } from 'rollup';
|
||||
import { InternalResolver } from '../resolver';
|
||||
export declare const createBuildResolvePlugin: (root: string, resolver: InternalResolver) => Plugin;
|
||||
41
node_modules/vite/dist/node/build/buildPluginResolve.js
generated
vendored
41
node_modules/vite/dist/node/build/buildPluginResolve.js
generated
vendored
@@ -1,41 +0,0 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createBuildResolvePlugin = void 0;
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const resolveVue_1 = require("../utils/resolveVue");
|
||||
const utils_1 = require("../utils");
|
||||
const debug = require('debug')('vite:build:resolve');
|
||||
exports.createBuildResolvePlugin = (root, resolver) => {
|
||||
return {
|
||||
name: 'vite:resolve',
|
||||
async resolveId(id, importer) {
|
||||
const original = id;
|
||||
id = resolver.alias(id) || id;
|
||||
if (id === 'vue' || id.startsWith('@vue/')) {
|
||||
const vuePaths = resolveVue_1.resolveVue(root);
|
||||
if (id in vuePaths) {
|
||||
return vuePaths[id];
|
||||
}
|
||||
}
|
||||
if (utils_1.isExternalUrl(id)) {
|
||||
return { id, external: true };
|
||||
}
|
||||
if (id.startsWith('/') && !id.startsWith(root)) {
|
||||
const resolved = resolver.requestToFile(id);
|
||||
if (fs_extra_1.default.existsSync(resolved)) {
|
||||
debug(id, `-->`, resolved);
|
||||
return resolved;
|
||||
}
|
||||
}
|
||||
// fallback to node-resolve because alias
|
||||
if (id !== original) {
|
||||
const resolved = await this.resolve(id, importer, { skipSelf: true });
|
||||
return resolved || { id };
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
//# sourceMappingURL=buildPluginResolve.js.map
|
||||
1
node_modules/vite/dist/node/build/buildPluginResolve.js.map
generated
vendored
1
node_modules/vite/dist/node/build/buildPluginResolve.js.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"buildPluginResolve.js","sourceRoot":"","sources":["../../../src/node/build/buildPluginResolve.ts"],"names":[],"mappings":";;;;;;AACA,wDAAyB;AACzB,oDAAgD;AAEhD,oCAAwC;AAExC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,oBAAoB,CAAC,CAAA;AAEvC,QAAA,wBAAwB,GAAG,CACtC,IAAY,EACZ,QAA0B,EAClB,EAAE;IACV,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,KAAK,CAAC,SAAS,CAAC,EAAE,EAAE,QAAQ;YAC1B,MAAM,QAAQ,GAAG,EAAE,CAAA;YACnB,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,CAAA;YAC7B,IAAI,EAAE,KAAK,KAAK,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;gBAC1C,MAAM,QAAQ,GAAG,uBAAU,CAAC,IAAI,CAAC,CAAA;gBACjC,IAAI,EAAE,IAAI,QAAQ,EAAE;oBAClB,OAAQ,QAAgB,CAAC,EAAE,CAAC,CAAA;iBAC7B;aACF;YACD,IAAI,qBAAa,CAAC,EAAE,CAAC,EAAE;gBACrB,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;aAC9B;YACD,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;gBAC9C,MAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,CAAA;gBAC3C,IAAI,kBAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;oBAC3B,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAA;oBAC1B,OAAO,QAAQ,CAAA;iBAChB;aACF;YACD,yCAAyC;YACzC,IAAI,EAAE,KAAK,QAAQ,EAAE;gBACnB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;gBACrE,OAAO,QAAQ,IAAI,EAAE,EAAE,EAAE,CAAA;aAC1B;QACH,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
|
||||
2
node_modules/vite/dist/node/build/buildPluginWasm.d.ts
generated
vendored
2
node_modules/vite/dist/node/build/buildPluginWasm.d.ts
generated
vendored
@@ -1,2 +0,0 @@
|
||||
import { Plugin } from 'rollup';
|
||||
export declare const createBuildWasmPlugin: (root: string, publicBase: string, assetsDir: string, inlineLimit: number) => Plugin;
|
||||
65
node_modules/vite/dist/node/build/buildPluginWasm.js
generated
vendored
65
node_modules/vite/dist/node/build/buildPluginWasm.js
generated
vendored
@@ -1,65 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createBuildWasmPlugin = void 0;
|
||||
const buildPluginAsset_1 = require("./buildPluginAsset");
|
||||
const wasmHelperId = 'vite/wasm-helper';
|
||||
const wasmHelper = (opts = {}, url) => {
|
||||
let instance;
|
||||
if (url.startsWith('data:')) {
|
||||
// @ts-ignore
|
||||
const binaryString = atob(url.replace(/^data:.*?base64,/, ''));
|
||||
const bytes = new Uint8Array(binaryString.length);
|
||||
for (let i = 0; i < binaryString.length; i++) {
|
||||
bytes[i] = binaryString.charCodeAt(i);
|
||||
}
|
||||
// @ts-ignore
|
||||
instance = WebAssembly.instantiate(bytes.buffer, opts);
|
||||
}
|
||||
else {
|
||||
// https://github.com/mdn/webassembly-examples/issues/5
|
||||
// WebAssembly.instantiateStreaming requires the server to provide the
|
||||
// correct MIME type for .wasm files, which unfortunately doesn't work for
|
||||
// a lot of static file servers, so we just work around it by getting the
|
||||
// raw buffer.
|
||||
// @ts-ignore
|
||||
instance = fetch(url)
|
||||
// @ts-ignore
|
||||
.then((r) => r.arrayBuffer())
|
||||
// @ts-ignore
|
||||
.then((bytes) => WebAssembly.instantiate(bytes, opts));
|
||||
}
|
||||
return instance.then((i) => i.instance.exports);
|
||||
};
|
||||
const wasmHelperCode = wasmHelper.toString();
|
||||
exports.createBuildWasmPlugin = (root, publicBase, assetsDir, inlineLimit) => {
|
||||
return {
|
||||
name: 'vite:wasm',
|
||||
resolveId(id) {
|
||||
if (id === wasmHelperId) {
|
||||
return id;
|
||||
}
|
||||
},
|
||||
async load(id) {
|
||||
if (id === wasmHelperId) {
|
||||
return `export default ${wasmHelperCode}`;
|
||||
}
|
||||
if (id.endsWith('.wasm')) {
|
||||
let { fileName, content, url } = await buildPluginAsset_1.resolveAsset(id, root, publicBase, assetsDir, inlineLimit);
|
||||
if (!url && fileName && content) {
|
||||
url =
|
||||
'import.meta.ROLLUP_FILE_URL_' +
|
||||
this.emitFile({
|
||||
name: fileName,
|
||||
type: 'asset',
|
||||
source: content
|
||||
});
|
||||
}
|
||||
return `
|
||||
import initWasm from "${wasmHelperId}"
|
||||
export default opts => initWasm(opts, ${JSON.stringify(url)})
|
||||
`;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
//# sourceMappingURL=buildPluginWasm.js.map
|
||||
1
node_modules/vite/dist/node/build/buildPluginWasm.js.map
generated
vendored
1
node_modules/vite/dist/node/build/buildPluginWasm.js.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"buildPluginWasm.js","sourceRoot":"","sources":["../../../src/node/build/buildPluginWasm.ts"],"names":[],"mappings":";;;AACA,yDAAiD;AAEjD,MAAM,YAAY,GAAG,kBAAkB,CAAA;AAEvC,MAAM,UAAU,GAAG,CAAC,IAAI,GAAG,EAAE,EAAE,GAAW,EAAE,EAAE;IAC5C,IAAI,QAAQ,CAAA;IACZ,IAAI,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;QAC3B,aAAa;QACb,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC,CAAA;QAC9D,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC,CAAA;QACjD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC5C,KAAK,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;SACtC;QACD,aAAa;QACb,QAAQ,GAAG,WAAW,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;KACvD;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AAO;gCACb,MAAM,EAAE,OAAO;6BAChB,CAAC,CAAA;iBACL;gBAED,OAAO;wBACS,YAAY;wCACI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC;CAC1D,CAAA;aACM;QACH,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
|
||||
39
node_modules/vite/dist/node/build/index.d.ts
generated
vendored
39
node_modules/vite/dist/node/build/index.d.ts
generated
vendored
@@ -1,39 +0,0 @@
|
||||
import { Ora } from 'ora';
|
||||
import { Plugin, InputOption, InputOptions, OutputOptions, RollupOutput } from 'rollup';
|
||||
import { InternalResolver } from '../resolver';
|
||||
import { BuildConfig } from '../config';
|
||||
interface Build extends InputOptions {
|
||||
input: InputOption;
|
||||
output: OutputOptions;
|
||||
/** Runs before global post-build hooks. */
|
||||
onResult?: PostBuildHook;
|
||||
}
|
||||
export interface BuildResult {
|
||||
build: Build;
|
||||
html: string;
|
||||
assets: RollupOutput['output'];
|
||||
}
|
||||
/** For adding Rollup builds and mutating the Vite config. */
|
||||
export declare type BuildPlugin = (config: BuildConfig, builds: Build[]) => PostBuildHook | void;
|
||||
/** Returned by `configureBuild` hook to mutate a build's output. */
|
||||
export declare type PostBuildHook = (result: BuildResult) => Promise<void> | void;
|
||||
export declare function onRollupWarning(spinner: Ora | undefined, options: BuildConfig['optimizeDeps']): InputOptions['onwarn'];
|
||||
/**
|
||||
* Creates non-application specific plugins that are shared between the main
|
||||
* app and the dependencies. This is used by the `optimize` command to
|
||||
* pre-bundle dependencies.
|
||||
*/
|
||||
export declare function createBaseRollupPlugins(root: string, resolver: InternalResolver, options: Partial<BuildConfig>): Promise<Plugin[]>;
|
||||
/**
|
||||
* Bundles the app for production.
|
||||
* Returns a Promise containing the build result.
|
||||
*/
|
||||
export declare function build(options: Partial<BuildConfig>): Promise<BuildResult[]>;
|
||||
/**
|
||||
* Bundles the app in SSR mode.
|
||||
* - All Vue dependencies are automatically externalized
|
||||
* - Imports to dependencies are compiled into require() calls
|
||||
* - Templates are compiled with SSR specific optimizations.
|
||||
*/
|
||||
export declare function ssrBuild(options: Partial<BuildConfig>): Promise<BuildResult[]>;
|
||||
export {};
|
||||
530
node_modules/vite/dist/node/build/index.js
generated
vendored
530
node_modules/vite/dist/node/build/index.js
generated
vendored
@@ -1,530 +0,0 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ssrBuild = exports.build = exports.createBaseRollupPlugins = exports.onRollupWarning = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const chalk_1 = __importDefault(require("chalk"));
|
||||
const p_map_series_1 = __importDefault(require("p-map-series"));
|
||||
const json_1 = require("klona/json");
|
||||
const utils_1 = require("../utils");
|
||||
const resolver_1 = require("../resolver");
|
||||
const buildPluginResolve_1 = require("./buildPluginResolve");
|
||||
const buildPluginHtml_1 = require("./buildPluginHtml");
|
||||
const buildPluginCss_1 = require("./buildPluginCss");
|
||||
const buildPluginAsset_1 = require("./buildPluginAsset");
|
||||
const buildPluginEsbuild_1 = require("./buildPluginEsbuild");
|
||||
const buildPluginReplace_1 = require("./buildPluginReplace");
|
||||
const esbuildService_1 = require("../esbuildService");
|
||||
const config_1 = require("../config");
|
||||
const transform_1 = require("../transform");
|
||||
const hash_sum_1 = __importDefault(require("hash-sum"));
|
||||
const cssUtils_1 = require("../utils/cssUtils");
|
||||
const buildPluginWasm_1 = require("./buildPluginWasm");
|
||||
const buildPluginManifest_1 = require("./buildPluginManifest");
|
||||
const writeColors = {
|
||||
[0 /* JS */]: chalk_1.default.cyan,
|
||||
[1 /* CSS */]: chalk_1.default.magenta,
|
||||
[2 /* ASSET */]: chalk_1.default.green,
|
||||
[3 /* HTML */]: chalk_1.default.blue,
|
||||
[4 /* SOURCE_MAP */]: chalk_1.default.gray
|
||||
};
|
||||
const warningIgnoreList = [`CIRCULAR_DEPENDENCY`, `THIS_IS_UNDEFINED`];
|
||||
const dynamicImportWarningIgnoreList = [
|
||||
`Unsupported expression`,
|
||||
`statically analyzed`
|
||||
];
|
||||
const isBuiltin = require('isbuiltin');
|
||||
function onRollupWarning(spinner, options) {
|
||||
return (warning, warn) => {
|
||||
if (warning.code === 'UNRESOLVED_IMPORT') {
|
||||
let message;
|
||||
const id = warning.source;
|
||||
const importer = warning.importer;
|
||||
if (isBuiltin(id)) {
|
||||
let importingDep;
|
||||
if (importer) {
|
||||
const pkg = JSON.parse(utils_1.lookupFile(importer, ['package.json']) || `{}`);
|
||||
if (pkg.name) {
|
||||
importingDep = pkg.name;
|
||||
}
|
||||
}
|
||||
const allowList = options.allowNodeBuiltins;
|
||||
if (importingDep && allowList && allowList.includes(importingDep)) {
|
||||
return;
|
||||
}
|
||||
const dep = importingDep
|
||||
? `Dependency ${chalk_1.default.yellow(importingDep)}`
|
||||
: `A dependency`;
|
||||
message =
|
||||
`${dep} is attempting to import Node built-in module ${chalk_1.default.yellow(id)}.\n` +
|
||||
`This will not work in a browser environment.\n` +
|
||||
`Imported by: ${chalk_1.default.gray(importer)}`;
|
||||
}
|
||||
else {
|
||||
message =
|
||||
`[vite]: Rollup failed to resolve import "${warning.source}" from "${warning.importer}".\n` +
|
||||
`This is most likely unintended because it can break your application at runtime.\n` +
|
||||
`If you do want to externalize this module explicitly add it to\n` +
|
||||
`\`rollupInputOptions.external\``;
|
||||
}
|
||||
if (spinner) {
|
||||
spinner.stop();
|
||||
}
|
||||
throw new Error(message);
|
||||
}
|
||||
if (warning.plugin === 'rollup-plugin-dynamic-import-variables' &&
|
||||
dynamicImportWarningIgnoreList.some((msg) => warning.message.includes(msg))) {
|
||||
return;
|
||||
}
|
||||
if (!warningIgnoreList.includes(warning.code)) {
|
||||
// ora would swallow the console.warn if we let it keep running
|
||||
// https://github.com/sindresorhus/ora/issues/90
|
||||
if (spinner) {
|
||||
spinner.stop();
|
||||
}
|
||||
warn(warning);
|
||||
if (spinner) {
|
||||
spinner.start();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
exports.onRollupWarning = onRollupWarning;
|
||||
/**
|
||||
* Creates non-application specific plugins that are shared between the main
|
||||
* app and the dependencies. This is used by the `optimize` command to
|
||||
* pre-bundle dependencies.
|
||||
*/
|
||||
async function createBaseRollupPlugins(root, resolver, options) {
|
||||
const { transforms = [], vueCustomBlockTransforms = {}, enableEsbuild = true, enableRollupPluginVue = true } = options;
|
||||
const { nodeResolve } = require('@rollup/plugin-node-resolve');
|
||||
const dynamicImport = require('rollup-plugin-dynamic-import-variables');
|
||||
return [
|
||||
// vite:resolve
|
||||
buildPluginResolve_1.createBuildResolvePlugin(root, resolver),
|
||||
// vite:esbuild
|
||||
enableEsbuild ? await buildPluginEsbuild_1.createEsbuildPlugin(options.jsx) : null,
|
||||
// vue
|
||||
enableRollupPluginVue ? await createVuePlugin(root, options) : null,
|
||||
require('@rollup/plugin-json')({
|
||||
preferConst: true,
|
||||
indent: ' ',
|
||||
compact: false,
|
||||
namedExports: true
|
||||
}),
|
||||
// user transforms
|
||||
...(transforms.length || Object.keys(vueCustomBlockTransforms).length
|
||||
? [transform_1.createBuildJsTransformPlugin(transforms, vueCustomBlockTransforms)]
|
||||
: []),
|
||||
nodeResolve({
|
||||
rootDir: root,
|
||||
extensions: resolver_1.supportedExts,
|
||||
preferBuiltins: false,
|
||||
dedupe: options.rollupDedupe || [],
|
||||
mainFields: resolver_1.mainFields
|
||||
}),
|
||||
require('@rollup/plugin-commonjs')({
|
||||
extensions: ['.js', '.cjs']
|
||||
}),
|
||||
dynamicImport({
|
||||
warnOnError: true,
|
||||
include: [/\.js$/],
|
||||
exclude: [/node_modules/]
|
||||
})
|
||||
].filter(Boolean);
|
||||
}
|
||||
exports.createBaseRollupPlugins = createBaseRollupPlugins;
|
||||
async function createVuePlugin(root, { vueCustomBlockTransforms = {}, rollupPluginVueOptions, cssPreprocessOptions, cssModuleOptions, vueCompilerOptions, vueTransformAssetUrls = {}, vueTemplatePreprocessOptions = {} }) {
|
||||
const { options: postcssOptions, plugins: postcssPlugins } = await cssUtils_1.resolvePostcssOptions(root, true);
|
||||
if (typeof vueTransformAssetUrls === 'object') {
|
||||
vueTransformAssetUrls = {
|
||||
includeAbsolute: true,
|
||||
...vueTransformAssetUrls
|
||||
};
|
||||
}
|
||||
return require('rollup-plugin-vue')({
|
||||
...rollupPluginVueOptions,
|
||||
templatePreprocessOptions: {
|
||||
...vueTemplatePreprocessOptions,
|
||||
pug: {
|
||||
doctype: 'html',
|
||||
...(vueTemplatePreprocessOptions && vueTemplatePreprocessOptions.pug)
|
||||
}
|
||||
},
|
||||
transformAssetUrls: vueTransformAssetUrls,
|
||||
postcssOptions,
|
||||
postcssPlugins,
|
||||
preprocessStyles: true,
|
||||
preprocessOptions: cssPreprocessOptions,
|
||||
preprocessCustomRequire: (id) => require(utils_1.resolveFrom(root, id)),
|
||||
compilerOptions: vueCompilerOptions,
|
||||
cssModulesOptions: {
|
||||
localsConvention: 'camelCase',
|
||||
generateScopedName: (local, filename) => `${local}_${hash_sum_1.default(filename)}`,
|
||||
...cssModuleOptions,
|
||||
...(rollupPluginVueOptions && rollupPluginVueOptions.cssModulesOptions)
|
||||
},
|
||||
customBlocks: Object.keys(vueCustomBlockTransforms)
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Clone the given config object and fill it with default values.
|
||||
*/
|
||||
function prepareConfig(config) {
|
||||
const { alias = {}, assetsDir = '_assets', assetsInclude = utils_1.isStaticAsset, assetsInlineLimit = 4096, base = '/', cssCodeSplit = true, cssModuleOptions = {}, cssPreprocessOptions = {}, define = {}, emitAssets = true, emitIndex = true, enableEsbuild = true, enableRollupPluginVue = true, entry = 'index.html', env = {}, esbuildTarget = 'es2020', indexHtmlTransforms = [], jsx = 'vue', minify = true, mode = 'production', optimizeDeps = {}, outDir = 'dist', resolvers = [], rollupDedupe = [], rollupInputOptions = {}, rollupOutputOptions = {}, rollupPluginVueOptions = {}, root = process.cwd(), shouldPreload = null, silent = false, sourcemap = false, terserOptions = {}, transforms = [], vueCompilerOptions = {}, vueCustomBlockTransforms = {}, vueTransformAssetUrls = {}, vueTemplatePreprocessOptions = {}, write = true } = json_1.klona(config);
|
||||
return {
|
||||
...config,
|
||||
alias,
|
||||
assetsDir,
|
||||
assetsInclude,
|
||||
assetsInlineLimit,
|
||||
base,
|
||||
cssCodeSplit,
|
||||
cssModuleOptions,
|
||||
cssPreprocessOptions,
|
||||
define,
|
||||
emitAssets,
|
||||
emitIndex,
|
||||
enableEsbuild,
|
||||
enableRollupPluginVue,
|
||||
entry,
|
||||
env,
|
||||
esbuildTarget,
|
||||
indexHtmlTransforms,
|
||||
jsx,
|
||||
minify,
|
||||
mode,
|
||||
optimizeDeps,
|
||||
outDir,
|
||||
resolvers,
|
||||
rollupDedupe,
|
||||
rollupInputOptions,
|
||||
rollupOutputOptions,
|
||||
rollupPluginVueOptions,
|
||||
root,
|
||||
shouldPreload,
|
||||
silent,
|
||||
sourcemap,
|
||||
terserOptions,
|
||||
transforms,
|
||||
vueCompilerOptions,
|
||||
vueCustomBlockTransforms,
|
||||
vueTransformAssetUrls,
|
||||
vueTemplatePreprocessOptions,
|
||||
write
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Bundles the app for production.
|
||||
* Returns a Promise containing the build result.
|
||||
*/
|
||||
async function build(options) {
|
||||
const builds = [];
|
||||
const config = prepareConfig(options);
|
||||
const postBuildHooks = utils_1.toArray(config.configureBuild)
|
||||
.map((configureBuild) => configureBuild(config, builds))
|
||||
.filter(Boolean);
|
||||
const { root, assetsDir, assetsInlineLimit, emitAssets, minify, silent, sourcemap, shouldPreload, env, mode: configMode, define: userDefineReplacements, write } = config;
|
||||
const isTest = process.env.NODE_ENV === 'test';
|
||||
const resolvedMode = process.env.VITE_ENV || configMode;
|
||||
const start = Date.now();
|
||||
let spinner;
|
||||
const msg = `Building ${configMode} bundle...`;
|
||||
if (!silent) {
|
||||
if (process.env.DEBUG || isTest) {
|
||||
console.log(msg);
|
||||
}
|
||||
else {
|
||||
spinner = require('ora')(msg + '\n').start();
|
||||
}
|
||||
}
|
||||
const outDir = path_1.default.resolve(root, config.outDir);
|
||||
const indexPath = path_1.default.resolve(root, 'index.html');
|
||||
const publicDir = path_1.default.join(root, 'public');
|
||||
const publicBasePath = config.base.replace(/([^/])$/, '$1/'); // ensure ending slash
|
||||
const resolvedAssetsPath = path_1.default.join(outDir, assetsDir);
|
||||
const resolver = resolver_1.createResolver(root, config.resolvers, config.alias, config.assetsInclude);
|
||||
const { htmlPlugin, renderIndex } = await buildPluginHtml_1.createBuildHtmlPlugin(root, indexPath, publicBasePath, assetsDir, assetsInlineLimit, resolver, shouldPreload, options);
|
||||
const basePlugins = await createBaseRollupPlugins(root, resolver, config);
|
||||
// https://github.com/darionco/rollup-plugin-web-worker-loader
|
||||
// configured to support `import Worker from './my-worker?worker'`
|
||||
// this plugin relies on resolveId and must be placed before node-resolve
|
||||
// since the latter somehow swallows ids with query strings since 8.x
|
||||
basePlugins.splice(basePlugins.findIndex((p) => p.name.includes('node-resolve')), 0, require('rollup-plugin-web-worker-loader')({
|
||||
targetPlatform: 'browser',
|
||||
pattern: /(.+)\?worker$/,
|
||||
extensions: resolver_1.supportedExts,
|
||||
sourcemap: false // it's inlined so it bloats the bundle
|
||||
}));
|
||||
// user env variables loaded from .env files.
|
||||
// only those prefixed with VITE_ are exposed.
|
||||
const userClientEnv = {};
|
||||
const userEnvReplacements = {};
|
||||
Object.keys(env).forEach((key) => {
|
||||
if (key.startsWith(`VITE_`)) {
|
||||
userEnvReplacements[`import.meta.env.${key}`] = JSON.stringify(env[key]);
|
||||
userClientEnv[key] = env[key];
|
||||
}
|
||||
});
|
||||
const builtInClientEnv = {
|
||||
BASE_URL: publicBasePath,
|
||||
MODE: configMode,
|
||||
DEV: resolvedMode !== 'production',
|
||||
PROD: resolvedMode === 'production'
|
||||
};
|
||||
const builtInEnvReplacements = {};
|
||||
Object.keys(builtInClientEnv).forEach((key) => {
|
||||
builtInEnvReplacements[`import.meta.env.${key}`] = JSON.stringify(builtInClientEnv[key]);
|
||||
});
|
||||
Object.keys(userDefineReplacements).forEach((key) => {
|
||||
userDefineReplacements[key] = JSON.stringify(userDefineReplacements[key]);
|
||||
});
|
||||
const { pluginsPreBuild = [], plugins = [], pluginsPostBuild = [], pluginsOptimizer, ...rollupInputOptions } = config.rollupInputOptions;
|
||||
builds.unshift({
|
||||
input: config.entry,
|
||||
preserveEntrySignatures: false,
|
||||
treeshake: { moduleSideEffects: 'no-external' },
|
||||
...rollupInputOptions,
|
||||
output: config.rollupOutputOptions,
|
||||
plugins: [
|
||||
...plugins,
|
||||
...pluginsPreBuild,
|
||||
...basePlugins,
|
||||
// vite:html
|
||||
htmlPlugin,
|
||||
// we use a custom replacement plugin because @rollup/plugin-replace
|
||||
// performs replacements twice, once at transform and once at renderChunk
|
||||
// - which makes it impossible to exclude Vue templates from it since
|
||||
// Vue templates are compiled into js and included in chunks.
|
||||
buildPluginReplace_1.createReplacePlugin((id) => !/\?vue&type=template/.test(id) &&
|
||||
// also exclude css and static assets for performance
|
||||
!cssUtils_1.isCSSRequest(id) &&
|
||||
!resolver.isAssetRequest(id), {
|
||||
...config_1.defaultDefines,
|
||||
...userDefineReplacements,
|
||||
...userEnvReplacements,
|
||||
...builtInEnvReplacements,
|
||||
'import.meta.env.': `({}).`,
|
||||
'import.meta.env': JSON.stringify({
|
||||
...userClientEnv,
|
||||
...builtInClientEnv
|
||||
}),
|
||||
'process.env.NODE_ENV': JSON.stringify(resolvedMode),
|
||||
'process.env.': `({}).`,
|
||||
'process.env': JSON.stringify({ NODE_ENV: resolvedMode }),
|
||||
'import.meta.hot': `false`
|
||||
}, !!sourcemap),
|
||||
// vite:css
|
||||
buildPluginCss_1.createBuildCssPlugin({
|
||||
root,
|
||||
publicBase: publicBasePath,
|
||||
assetsDir,
|
||||
minify,
|
||||
inlineLimit: assetsInlineLimit,
|
||||
cssCodeSplit: config.cssCodeSplit,
|
||||
preprocessOptions: config.cssPreprocessOptions,
|
||||
modulesOptions: config.cssModuleOptions
|
||||
}),
|
||||
// vite:wasm
|
||||
buildPluginWasm_1.createBuildWasmPlugin(root, publicBasePath, assetsDir, assetsInlineLimit),
|
||||
// vite:asset
|
||||
buildPluginAsset_1.createBuildAssetPlugin(root, resolver, publicBasePath, assetsDir, assetsInlineLimit),
|
||||
config.enableEsbuild &&
|
||||
buildPluginEsbuild_1.createEsbuildRenderChunkPlugin(config.esbuildTarget, minify === 'esbuild'),
|
||||
// minify with terser
|
||||
// this is the default which has better compression, but slow
|
||||
// the user can opt-in to use esbuild which is much faster but results
|
||||
// in ~8-10% larger file size.
|
||||
minify && minify !== 'esbuild'
|
||||
? require('rollup-plugin-terser').terser(config.terserOptions)
|
||||
: undefined,
|
||||
// #728 user plugins should apply after `@rollup/plugin-commonjs`
|
||||
// #471#issuecomment-683318951 user plugin after internal plugin
|
||||
...pluginsPostBuild,
|
||||
// vite:manifest
|
||||
config.emitManifest ? buildPluginManifest_1.createBuildManifestPlugin() : undefined
|
||||
].filter(Boolean)
|
||||
});
|
||||
// lazy require rollup so that we don't load it when only using the dev server
|
||||
// importing it just for the types
|
||||
const rollup = require('rollup').rollup;
|
||||
// multiple builds are processed sequentially, in case a build
|
||||
// depends on the output of a preceding build.
|
||||
const results = await p_map_series_1.default(builds, async (build, i) => {
|
||||
const { output: outputOptions, onResult, ...inputOptions } = build;
|
||||
let result;
|
||||
let indexHtml;
|
||||
let indexHtmlPath = getIndexHtmlOutputPath(build);
|
||||
const emitIndex = config.emitIndex && indexHtmlPath !== null;
|
||||
try {
|
||||
const bundle = await rollup({
|
||||
onwarn: onRollupWarning(spinner, config.optimizeDeps),
|
||||
...inputOptions,
|
||||
plugins: [
|
||||
...(inputOptions.plugins || []).filter(
|
||||
// remove vite:emit in case this build copied another build's plugins
|
||||
(plugin) => plugin.name !== 'vite:emit'),
|
||||
// vite:emit
|
||||
createEmitPlugin(emitAssets, async (assets) => {
|
||||
indexHtml = emitIndex ? await renderIndex(assets) : '';
|
||||
result = { build, assets, html: indexHtml };
|
||||
if (onResult) {
|
||||
await onResult(result);
|
||||
}
|
||||
// run post-build hooks sequentially
|
||||
await postBuildHooks.reduce((queue, hook) => queue.then(() => hook(result)), Promise.resolve());
|
||||
if (write) {
|
||||
if (i === 0) {
|
||||
await fs_extra_1.default.emptyDir(outDir);
|
||||
}
|
||||
if (emitIndex) {
|
||||
indexHtmlPath = path_1.default.join(outDir, indexHtmlPath);
|
||||
await fs_extra_1.default.writeFile(indexHtmlPath, indexHtml);
|
||||
}
|
||||
}
|
||||
})
|
||||
]
|
||||
});
|
||||
await bundle[write ? 'write' : 'generate']({
|
||||
dir: resolvedAssetsPath,
|
||||
format: 'es',
|
||||
sourcemap,
|
||||
entryFileNames: `[name].[hash].js`,
|
||||
chunkFileNames: `[name].[hash].js`,
|
||||
assetFileNames: `[name].[hash].[ext]`,
|
||||
...outputOptions
|
||||
});
|
||||
}
|
||||
finally {
|
||||
spinner && spinner.stop();
|
||||
}
|
||||
if (write && !silent) {
|
||||
if (emitIndex) {
|
||||
printFileInfo(indexHtmlPath, indexHtml, 3 /* HTML */);
|
||||
}
|
||||
for (const chunk of result.assets) {
|
||||
if (chunk.type === 'chunk') {
|
||||
const filePath = path_1.default.join(resolvedAssetsPath, chunk.fileName);
|
||||
printFileInfo(filePath, chunk.code, 0 /* JS */);
|
||||
if (chunk.map) {
|
||||
printFileInfo(filePath + '.map', chunk.map.toString(), 4 /* SOURCE_MAP */);
|
||||
}
|
||||
}
|
||||
else if (emitAssets && chunk.source)
|
||||
printFileInfo(path_1.default.join(resolvedAssetsPath, chunk.fileName), chunk.source, chunk.fileName.endsWith('.css') ? 1 /* CSS */ : 2 /* ASSET */);
|
||||
}
|
||||
}
|
||||
spinner && spinner.start();
|
||||
return result;
|
||||
});
|
||||
// copy over /public if it exists
|
||||
if (write && emitAssets && fs_extra_1.default.existsSync(publicDir)) {
|
||||
for (const file of await fs_extra_1.default.readdir(publicDir)) {
|
||||
await fs_extra_1.default.copy(path_1.default.join(publicDir, file), path_1.default.resolve(outDir, file));
|
||||
}
|
||||
}
|
||||
spinner && spinner.stop();
|
||||
if (!silent) {
|
||||
console.log(`Build completed in ${((Date.now() - start) / 1000).toFixed(2)}s.\n`);
|
||||
}
|
||||
// stop the esbuild service after each build
|
||||
await esbuildService_1.stopService();
|
||||
return results;
|
||||
}
|
||||
exports.build = build;
|
||||
/**
|
||||
* Bundles the app in SSR mode.
|
||||
* - All Vue dependencies are automatically externalized
|
||||
* - Imports to dependencies are compiled into require() calls
|
||||
* - Templates are compiled with SSR specific optimizations.
|
||||
*/
|
||||
async function ssrBuild(options) {
|
||||
const { rollupInputOptions, rollupOutputOptions, rollupPluginVueOptions } = options;
|
||||
return build({
|
||||
outDir: 'dist-ssr',
|
||||
...options,
|
||||
rollupPluginVueOptions: {
|
||||
...rollupPluginVueOptions,
|
||||
target: 'node'
|
||||
},
|
||||
rollupInputOptions: {
|
||||
...rollupInputOptions,
|
||||
external: resolveExternal(rollupInputOptions && rollupInputOptions.external)
|
||||
},
|
||||
rollupOutputOptions: {
|
||||
...rollupOutputOptions,
|
||||
format: 'cjs',
|
||||
exports: 'named',
|
||||
entryFileNames: '[name].js',
|
||||
// 764 add `Symbol.toStringTag` when build es module into cjs chunk
|
||||
namespaceToStringTag: true
|
||||
},
|
||||
emitIndex: false,
|
||||
emitAssets: false,
|
||||
cssCodeSplit: false,
|
||||
minify: false
|
||||
});
|
||||
}
|
||||
exports.ssrBuild = ssrBuild;
|
||||
function createEmitPlugin(emitAssets, emit) {
|
||||
return {
|
||||
name: 'vite:emit',
|
||||
async generateBundle(_, output) {
|
||||
// assume the first asset in `output` is an entry chunk
|
||||
const assets = Object.values(output);
|
||||
// process the output before writing
|
||||
await emit(assets);
|
||||
// write any assets injected by post-build hooks
|
||||
for (const asset of assets) {
|
||||
output[asset.fileName] = asset;
|
||||
}
|
||||
// remove assets from bundle if emitAssets is false
|
||||
if (!emitAssets) {
|
||||
for (const name in output) {
|
||||
if (output[name].type === 'asset') {
|
||||
delete output[name];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Resolve the output path of `index.html` for the given build (relative to
|
||||
* `outDir` in Vite config).
|
||||
*/
|
||||
function getIndexHtmlOutputPath(build) {
|
||||
const { input, output } = build;
|
||||
return input === 'index.html' ? output.file || input : null;
|
||||
}
|
||||
function resolveExternal(userExternal) {
|
||||
const required = ['vue', /^@vue\//];
|
||||
if (!userExternal) {
|
||||
return required;
|
||||
}
|
||||
if (Array.isArray(userExternal)) {
|
||||
return [...required, ...userExternal];
|
||||
}
|
||||
else if (typeof userExternal === 'function') {
|
||||
return (src, importer, isResolved) => {
|
||||
if (src === 'vue' || /^@vue\//.test(src)) {
|
||||
return true;
|
||||
}
|
||||
return userExternal(src, importer, isResolved);
|
||||
};
|
||||
}
|
||||
else {
|
||||
return [...required, userExternal];
|
||||
}
|
||||
}
|
||||
function printFileInfo(filePath, content, type) {
|
||||
const needCompression = type === 0 /* JS */ || type === 1 /* CSS */ || type === 3 /* HTML */;
|
||||
const compressed = needCompression
|
||||
? `, brotli: ${(require('brotli-size').sync(content) / 1024).toFixed(2)}kb`
|
||||
: ``;
|
||||
console.log(`${chalk_1.default.gray(`[write]`)} ${writeColors[type](path_1.default.relative(process.cwd(), filePath))} ${(content.length / 1024).toFixed(2)}kb${compressed}`);
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/vite/dist/node/build/index.js.map
generated
vendored
1
node_modules/vite/dist/node/build/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
1
node_modules/vite/dist/node/cli.d.ts
generated
vendored
1
node_modules/vite/dist/node/cli.d.ts
generated
vendored
@@ -1 +0,0 @@
|
||||
export {};
|
||||
14287
node_modules/vite/dist/node/cli.js
generated
vendored
14287
node_modules/vite/dist/node/cli.js
generated
vendored
File diff suppressed because it is too large
Load Diff
1
node_modules/vite/dist/node/cli.js.map
generated
vendored
1
node_modules/vite/dist/node/cli.js.map
generated
vendored
File diff suppressed because one or more lines are too long
410
node_modules/vite/dist/node/config.d.ts
generated
vendored
410
node_modules/vite/dist/node/config.d.ts
generated
vendored
@@ -1,410 +0,0 @@
|
||||
/// <reference types="node" />
|
||||
import { DotenvParseOutput } from 'dotenv';
|
||||
import { Options as RollupPluginVueOptions } from 'rollup-plugin-vue';
|
||||
import { CompilerOptions, SFCStyleCompileOptions, SFCAsyncStyleCompileOptions, SFCTemplateCompileOptions } from '@vue/compiler-sfc';
|
||||
import { InputOptions as RollupInputOptions, OutputOptions as RollupOutputOptions, Plugin as RollupPlugin, OutputChunk } from 'rollup';
|
||||
import { BuildPlugin } from './build';
|
||||
import { Context, ServerPlugin } from './server';
|
||||
import { Resolver } from './resolver';
|
||||
import { Transform, CustomBlockTransform, IndexHtmlTransform } from './transform';
|
||||
import { DepOptimizationOptions } from './optimizer';
|
||||
import { ServerOptions } from 'https';
|
||||
import { Options as RollupTerserOptions } from 'rollup-plugin-terser';
|
||||
import { ProxiesOptions } from './server/serverPluginProxy';
|
||||
export declare type PreprocessLang = NonNullable<SFCStyleCompileOptions['preprocessLang']>;
|
||||
export declare type PreprocessOptions = SFCStyleCompileOptions['preprocessOptions'];
|
||||
export declare type CssPreprocessOptions = Partial<Record<PreprocessLang, PreprocessOptions>>;
|
||||
/**
|
||||
* https://github.com/koajs/cors#corsoptions
|
||||
*/
|
||||
export interface CorsOptions {
|
||||
/**
|
||||
* `Access-Control-Allow-Origin`, default is request Origin header
|
||||
*/
|
||||
origin?: string | ((ctx: Context) => string);
|
||||
/**
|
||||
* `Access-Control-Allow-Methods`, default is 'GET,HEAD,PUT,POST,DELETE,PATCH'
|
||||
*/
|
||||
allowMethods?: string | string[];
|
||||
/**
|
||||
* `Access-Control-Expose-Headers`
|
||||
*/
|
||||
exposeHeaders?: string | string[];
|
||||
/**
|
||||
* `Access-Control-Allow-Headers`
|
||||
*/
|
||||
allowHeaders?: string | string[];
|
||||
/**
|
||||
* `Access-Control-Max-Age` in seconds
|
||||
*/
|
||||
maxAge?: string | number;
|
||||
/**
|
||||
* `Access-Control-Allow-Credentials`, default is false
|
||||
*/
|
||||
credentials?: boolean | ((ctx: Context) => boolean);
|
||||
/**
|
||||
* Add set headers to `err.header` if an error is thrown
|
||||
*/
|
||||
keepHeadersOnError?: boolean;
|
||||
}
|
||||
export { Resolver, Transform };
|
||||
/**
|
||||
* Options shared between server and build.
|
||||
*/
|
||||
export interface SharedConfig {
|
||||
/**
|
||||
* Project root directory. Can be an absolute path, or a path relative from
|
||||
* the location of the config file itself.
|
||||
* @default process.cwd()
|
||||
*/
|
||||
root?: string;
|
||||
/**
|
||||
* Import alias. The entries can either be exact request -> request mappings
|
||||
* (exact, no wildcard syntax), or request path -> fs directory mappings.
|
||||
* When using directory mappings, the key **must start and end with a slash**.
|
||||
*
|
||||
* Example `vite.config.js`:
|
||||
* ``` js
|
||||
* module.exports = {
|
||||
* alias: {
|
||||
* // alias package names
|
||||
* 'react': '@pika/react',
|
||||
* 'react-dom': '@pika/react-dom'
|
||||
*
|
||||
* // alias a path to a fs directory
|
||||
* // the key must start and end with a slash
|
||||
* '/@foo/': path.resolve(__dirname, 'some-special-dir')
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
alias?: Record<string, string>;
|
||||
/**
|
||||
* Function that tests a file path for inclusion as a static asset.
|
||||
*/
|
||||
assetsInclude?: (file: string) => boolean;
|
||||
/**
|
||||
* Custom file transforms.
|
||||
*/
|
||||
transforms?: Transform[];
|
||||
/**
|
||||
* Custom index.html transforms.
|
||||
*/
|
||||
indexHtmlTransforms?: IndexHtmlTransform[];
|
||||
/**
|
||||
* Define global variable replacements.
|
||||
* Entries will be defined on `window` during dev and replaced during build.
|
||||
*/
|
||||
define?: Record<string, any>;
|
||||
/**
|
||||
* Resolvers to map dev server public path requests to/from file system paths,
|
||||
* and optionally map module ids to public path requests.
|
||||
*/
|
||||
resolvers?: Resolver[];
|
||||
/**
|
||||
* Configure dep optimization behavior.
|
||||
*
|
||||
* Example `vite.config.js`:
|
||||
* ``` js
|
||||
* module.exports = {
|
||||
* optimizeDeps: {
|
||||
* exclude: ['dep-a', 'dep-b']
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
optimizeDeps?: DepOptimizationOptions;
|
||||
/**
|
||||
* Options to pass to `@vue/compiler-dom`
|
||||
*
|
||||
* https://github.com/vuejs/vue-next/blob/master/packages/compiler-core/src/options.ts
|
||||
*/
|
||||
vueCompilerOptions?: CompilerOptions;
|
||||
/**
|
||||
* Configure what tags/attributes to trasnform into asset url imports,
|
||||
* or disable the transform altogether with `false`.
|
||||
*/
|
||||
vueTransformAssetUrls?: SFCTemplateCompileOptions['transformAssetUrls'];
|
||||
/**
|
||||
* The options for template block preprocessor render.
|
||||
*/
|
||||
vueTemplatePreprocessOptions?: Record<string, SFCTemplateCompileOptions['preprocessOptions']>;
|
||||
/**
|
||||
* Transform functions for Vue custom blocks.
|
||||
*
|
||||
* Example `vue.config.js`:
|
||||
* ``` js
|
||||
* module.exports = {
|
||||
* vueCustomBlockTransforms: {
|
||||
* i18n: src => `export default Comp => { ... }`
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
vueCustomBlockTransforms?: Record<string, CustomBlockTransform>;
|
||||
/**
|
||||
* Configure what to use for jsx factory and fragment.
|
||||
* @default 'vue'
|
||||
*/
|
||||
jsx?: 'vue' | 'preact' | 'react' | {
|
||||
factory?: string;
|
||||
fragment?: string;
|
||||
};
|
||||
/**
|
||||
* Environment mode
|
||||
*/
|
||||
mode?: string;
|
||||
/**
|
||||
* CSS preprocess options
|
||||
*/
|
||||
cssPreprocessOptions?: CssPreprocessOptions;
|
||||
/**
|
||||
* CSS modules options
|
||||
*/
|
||||
cssModuleOptions?: SFCAsyncStyleCompileOptions['modulesOptions'];
|
||||
/**
|
||||
* Enable esbuild
|
||||
* @default true
|
||||
*/
|
||||
enableEsbuild?: boolean;
|
||||
/**
|
||||
* Environment variables parsed from .env files
|
||||
* only ones starting with VITE_ are exposed on `import.meta.env`
|
||||
* @internal
|
||||
*/
|
||||
env?: DotenvParseOutput;
|
||||
}
|
||||
export interface HmrConfig {
|
||||
protocol?: string;
|
||||
hostname?: string;
|
||||
port?: number;
|
||||
path?: string;
|
||||
}
|
||||
export interface ServerConfig extends SharedConfig {
|
||||
/**
|
||||
* Configure hmr websocket connection.
|
||||
*/
|
||||
hmr?: HmrConfig | boolean;
|
||||
/**
|
||||
* Configure dev server hostname.
|
||||
*/
|
||||
hostname?: string;
|
||||
port?: number;
|
||||
open?: boolean;
|
||||
/**
|
||||
* Configure https.
|
||||
*/
|
||||
https?: boolean;
|
||||
httpsOptions?: ServerOptions;
|
||||
/**
|
||||
* Configure custom proxy rules for the dev server. Uses
|
||||
* [`koa-proxies`](https://github.com/vagusX/koa-proxies) which in turn uses
|
||||
* [`http-proxy`](https://github.com/http-party/node-http-proxy). Each key can
|
||||
* be a path Full options
|
||||
* [here](https://github.com/http-party/node-http-proxy#options).
|
||||
*
|
||||
* Example `vite.config.js`:
|
||||
* ``` js
|
||||
* module.exports = {
|
||||
* proxy: {
|
||||
* // string shorthand
|
||||
* '/foo': 'http://localhost:4567/foo',
|
||||
* // with options
|
||||
* '/api': {
|
||||
* target: 'http://jsonplaceholder.typicode.com',
|
||||
* changeOrigin: true,
|
||||
* rewrite: path => path.replace(/^\/api/, '')
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
proxy?: Record<string, string | ProxiesOptions>;
|
||||
/**
|
||||
* Configure CORS for the dev server.
|
||||
* Uses [@koa/cors](https://github.com/koajs/cors).
|
||||
* Set to `true` to allow all methods from any origin, or configure separately
|
||||
* using an object.
|
||||
*/
|
||||
cors?: CorsOptions | boolean;
|
||||
/**
|
||||
* A plugin function that configures the dev server. Receives a server plugin
|
||||
* context object just like the internal server plugins. Can also be an array
|
||||
* of multiple server plugin functions.
|
||||
*/
|
||||
configureServer?: ServerPlugin | ServerPlugin[];
|
||||
}
|
||||
export interface BuildConfig extends Required<SharedConfig> {
|
||||
/**
|
||||
* Entry. Use this to specify a js entry file in use cases where an
|
||||
* `index.html` does not exist (e.g. serving vite assets from a different host)
|
||||
* @default 'index.html'
|
||||
*/
|
||||
entry: string;
|
||||
/**
|
||||
* Base public path when served in production.
|
||||
* @default '/'
|
||||
*/
|
||||
base: string;
|
||||
/**
|
||||
* Directory relative from `root` where build output will be placed. If the
|
||||
* directory exists, it will be removed before the build.
|
||||
* @default 'dist'
|
||||
*/
|
||||
outDir: string;
|
||||
/**
|
||||
* Directory relative from `outDir` where the built js/css/image assets will
|
||||
* be placed.
|
||||
* @default '_assets'
|
||||
*/
|
||||
assetsDir: string;
|
||||
/**
|
||||
* Static asset files smaller than this number (in bytes) will be inlined as
|
||||
* base64 strings. Default limit is `4096` (4kb). Set to `0` to disable.
|
||||
* @default 4096
|
||||
*/
|
||||
assetsInlineLimit: number;
|
||||
/**
|
||||
* Whether to code-split CSS. When enabled, CSS in async chunks will be
|
||||
* inlined as strings in the chunk and inserted via dynamically created
|
||||
* style tags when the chunk is loaded.
|
||||
* @default true
|
||||
*/
|
||||
cssCodeSplit: boolean;
|
||||
/**
|
||||
* Whether to generate sourcemap
|
||||
* @default false
|
||||
*/
|
||||
sourcemap: boolean | 'inline';
|
||||
/**
|
||||
* Set to `false` to disable minification, or specify the minifier to use.
|
||||
* Available options are 'terser' or 'esbuild'.
|
||||
* @default 'terser'
|
||||
*/
|
||||
minify: boolean | 'terser' | 'esbuild';
|
||||
/**
|
||||
* The option for `terser`
|
||||
*/
|
||||
terserOptions: RollupTerserOptions;
|
||||
/**
|
||||
* Transpile target for esbuild.
|
||||
* @default 'es2020'
|
||||
*/
|
||||
esbuildTarget: string;
|
||||
/**
|
||||
* Build for server-side rendering, only as a CLI flag
|
||||
* for programmatic usage, use `ssrBuild` directly.
|
||||
* @internal
|
||||
*/
|
||||
ssr?: boolean;
|
||||
/**
|
||||
* Will be passed to rollup.rollup()
|
||||
*
|
||||
* https://rollupjs.org/guide/en/#big-list-of-options
|
||||
*/
|
||||
rollupInputOptions: ViteRollupInputOptions;
|
||||
/**
|
||||
* Will be passed to bundle.generate()
|
||||
*
|
||||
* https://rollupjs.org/guide/en/#big-list-of-options
|
||||
*/
|
||||
rollupOutputOptions: RollupOutputOptions;
|
||||
/**
|
||||
* Will be passed to rollup-plugin-vue
|
||||
*
|
||||
* https://github.com/vuejs/rollup-plugin-vue/blob/next/src/index.ts
|
||||
*/
|
||||
rollupPluginVueOptions: Partial<RollupPluginVueOptions>;
|
||||
/**
|
||||
* Will be passed to @rollup/plugin-node-resolve
|
||||
* https://github.com/rollup/plugins/tree/master/packages/node-resolve#dedupe
|
||||
*/
|
||||
rollupDedupe: string[];
|
||||
/**
|
||||
* Whether to log asset info to console
|
||||
* @default false
|
||||
*/
|
||||
silent: boolean;
|
||||
/**
|
||||
* Whether to write bundle to disk
|
||||
* @default true
|
||||
*/
|
||||
write: boolean;
|
||||
/**
|
||||
* Whether to emit index.html
|
||||
* @default true
|
||||
*/
|
||||
emitIndex: boolean;
|
||||
/**
|
||||
* Whether to emit assets other than JavaScript
|
||||
* @default true
|
||||
*/
|
||||
emitAssets: boolean;
|
||||
/**
|
||||
* Whether to emit a manifest.json under assets dir to map hash-less filenames
|
||||
* to their hashed versions. Useful when you want to generate your own HTML
|
||||
* instead of using the one generated by Vite.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```json
|
||||
* {
|
||||
* "main.js": "main.68fe3fad.js",
|
||||
* "style.css": "style.e6b63442.css"
|
||||
* }
|
||||
* ```
|
||||
* @default false
|
||||
*/
|
||||
emitManifest?: boolean;
|
||||
/**
|
||||
* Predicate function that determines whether a link rel=modulepreload shall be
|
||||
* added to the index.html for the chunk passed in
|
||||
*/
|
||||
shouldPreload: ((chunk: OutputChunk) => boolean) | null;
|
||||
/**
|
||||
* Enable 'rollup-plugin-vue'
|
||||
* @default true
|
||||
*/
|
||||
enableRollupPluginVue?: boolean;
|
||||
/**
|
||||
* Plugin functions that mutate the Vite build config. The `builds` array can
|
||||
* be added to if the plugin wants to add another Rollup build that Vite writes
|
||||
* to disk. Return a function to gain access to each build's output.
|
||||
* @internal
|
||||
*/
|
||||
configureBuild?: BuildPlugin | BuildPlugin[];
|
||||
}
|
||||
export interface ViteRollupInputOptions extends RollupInputOptions {
|
||||
/**
|
||||
* @deprecated use `pluginsPreBuild` or `pluginsPostBuild` instead
|
||||
*/
|
||||
plugins?: RollupPlugin[];
|
||||
/**
|
||||
* Rollup plugins that passed before Vite's transform plugins
|
||||
*/
|
||||
pluginsPreBuild?: RollupPlugin[];
|
||||
/**
|
||||
* Rollup plugins that passed after Vite's transform plugins
|
||||
*/
|
||||
pluginsPostBuild?: RollupPlugin[];
|
||||
/**
|
||||
* Rollup plugins for optimizer
|
||||
*/
|
||||
pluginsOptimizer?: RollupPlugin[];
|
||||
}
|
||||
export interface UserConfig extends Partial<BuildConfig>, ServerConfig {
|
||||
plugins?: Plugin[];
|
||||
}
|
||||
export interface Plugin extends Pick<UserConfig, 'alias' | 'transforms' | 'indexHtmlTransforms' | 'define' | 'resolvers' | 'configureBuild' | 'configureServer' | 'vueCompilerOptions' | 'vueTransformAssetUrls' | 'vueTemplatePreprocessOptions' | 'vueCustomBlockTransforms' | 'rollupInputOptions' | 'rollupOutputOptions' | 'enableRollupPluginVue'> {
|
||||
}
|
||||
export declare type ResolvedConfig = UserConfig & {
|
||||
/**
|
||||
* Path of config file.
|
||||
*/
|
||||
__path?: string;
|
||||
};
|
||||
export declare function resolveConfig(mode: string, configPath?: string): Promise<ResolvedConfig | undefined>;
|
||||
export declare const defaultDefines: {
|
||||
__VUE_OPTIONS_API__: boolean;
|
||||
__VUE_PROD_DEVTOOLS__: boolean;
|
||||
};
|
||||
257
node_modules/vite/dist/node/config.js
generated
vendored
257
node_modules/vite/dist/node/config.js
generated
vendored
@@ -1,257 +0,0 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.defaultDefines = exports.resolveConfig = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const chalk_1 = __importDefault(require("chalk"));
|
||||
const dotenv_1 = __importDefault(require("dotenv"));
|
||||
const dotenv_expand_1 = __importDefault(require("dotenv-expand"));
|
||||
const buildPluginEsbuild_1 = require("./build/buildPluginEsbuild");
|
||||
const resolver_1 = require("./resolver");
|
||||
const utils_1 = require("./utils");
|
||||
const debug = require('debug')('vite:config');
|
||||
async function resolveConfig(mode, configPath) {
|
||||
const start = Date.now();
|
||||
const cwd = process.cwd();
|
||||
let config;
|
||||
let resolvedPath;
|
||||
let isTS = false;
|
||||
if (configPath) {
|
||||
resolvedPath = path_1.default.resolve(cwd, configPath);
|
||||
}
|
||||
else {
|
||||
const jsConfigPath = path_1.default.resolve(cwd, 'vite.config.js');
|
||||
if (fs_extra_1.default.existsSync(jsConfigPath)) {
|
||||
resolvedPath = jsConfigPath;
|
||||
}
|
||||
else {
|
||||
const tsConfigPath = path_1.default.resolve(cwd, 'vite.config.ts');
|
||||
if (fs_extra_1.default.existsSync(tsConfigPath)) {
|
||||
isTS = true;
|
||||
resolvedPath = tsConfigPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!resolvedPath) {
|
||||
// load environment variables
|
||||
return {
|
||||
env: loadEnv(mode, cwd)
|
||||
};
|
||||
}
|
||||
try {
|
||||
if (!isTS) {
|
||||
try {
|
||||
config = require(resolvedPath);
|
||||
}
|
||||
catch (e) {
|
||||
if (!/Cannot use import statement|Unexpected token 'export'|Must use import to load ES Module/.test(e.message)) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!config) {
|
||||
// 2. if we reach here, the file is ts or using es import syntax, or
|
||||
// the user has type: "module" in their package.json (#917)
|
||||
// transpile es import syntax to require syntax using rollup.
|
||||
const rollup = require('rollup');
|
||||
const esbuildPlugin = await buildPluginEsbuild_1.createEsbuildPlugin({});
|
||||
const esbuildRenderChunkPlugin = buildPluginEsbuild_1.createEsbuildRenderChunkPlugin('es2019', false);
|
||||
// use node-resolve to support .ts files
|
||||
const nodeResolve = require('@rollup/plugin-node-resolve').nodeResolve({
|
||||
extensions: resolver_1.supportedExts
|
||||
});
|
||||
const bundle = await rollup.rollup({
|
||||
external: (id) => (id[0] !== '.' && !path_1.default.isAbsolute(id)) ||
|
||||
id.slice(-5, id.length) === '.json',
|
||||
input: resolvedPath,
|
||||
treeshake: false,
|
||||
plugins: [esbuildPlugin, nodeResolve, esbuildRenderChunkPlugin]
|
||||
});
|
||||
const { output: [{ code }] } = await bundle.generate({
|
||||
exports: 'named',
|
||||
format: 'cjs'
|
||||
});
|
||||
config = await loadConfigFromBundledFile(resolvedPath, code);
|
||||
}
|
||||
if (typeof config === 'function') {
|
||||
config = config(mode);
|
||||
}
|
||||
// normalize config root to absolute
|
||||
if (config.root && !path_1.default.isAbsolute(config.root)) {
|
||||
config.root = path_1.default.resolve(path_1.default.dirname(resolvedPath), config.root);
|
||||
}
|
||||
if (typeof config.vueTransformAssetUrls === 'object') {
|
||||
config.vueTransformAssetUrls = normalizeAssetUrlOptions(config.vueTransformAssetUrls);
|
||||
}
|
||||
// resolve plugins
|
||||
if (config.plugins) {
|
||||
for (const plugin of config.plugins) {
|
||||
config = resolvePlugin(config, plugin);
|
||||
}
|
||||
}
|
||||
config.env = {
|
||||
...config.env,
|
||||
...loadEnv(mode, config.root || cwd)
|
||||
};
|
||||
debug(`config resolved in ${Date.now() - start}ms`);
|
||||
config.__path = resolvedPath;
|
||||
return config;
|
||||
}
|
||||
catch (e) {
|
||||
console.error(chalk_1.default.red(`[vite] failed to load config from ${resolvedPath}:`));
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
exports.resolveConfig = resolveConfig;
|
||||
async function loadConfigFromBundledFile(fileName, bundledCode) {
|
||||
const extension = path_1.default.extname(fileName);
|
||||
const defaultLoader = require.extensions[extension];
|
||||
require.extensions[extension] = (module, filename) => {
|
||||
if (filename === fileName) {
|
||||
;
|
||||
module._compile(bundledCode, filename);
|
||||
}
|
||||
else {
|
||||
defaultLoader(module, filename);
|
||||
}
|
||||
};
|
||||
delete require.cache[fileName];
|
||||
const raw = require(fileName);
|
||||
const config = raw.__esModule ? raw.default : raw;
|
||||
require.extensions[extension] = defaultLoader;
|
||||
return config;
|
||||
}
|
||||
function resolvePlugin(config, plugin) {
|
||||
return {
|
||||
...config,
|
||||
...plugin,
|
||||
alias: {
|
||||
...plugin.alias,
|
||||
...config.alias
|
||||
},
|
||||
define: {
|
||||
...plugin.define,
|
||||
...config.define
|
||||
},
|
||||
transforms: [...(config.transforms || []), ...(plugin.transforms || [])],
|
||||
indexHtmlTransforms: [
|
||||
...(config.indexHtmlTransforms || []),
|
||||
...(plugin.indexHtmlTransforms || [])
|
||||
],
|
||||
resolvers: [...(config.resolvers || []), ...(plugin.resolvers || [])],
|
||||
configureServer: [].concat(config.configureServer || [], plugin.configureServer || []),
|
||||
configureBuild: [].concat(config.configureBuild || [], plugin.configureBuild || []),
|
||||
vueCompilerOptions: {
|
||||
...config.vueCompilerOptions,
|
||||
...plugin.vueCompilerOptions
|
||||
},
|
||||
vueTransformAssetUrls: mergeAssetUrlOptions(config.vueTransformAssetUrls, plugin.vueTransformAssetUrls),
|
||||
vueTemplatePreprocessOptions: {
|
||||
...config.vueTemplatePreprocessOptions,
|
||||
...plugin.vueTemplatePreprocessOptions
|
||||
},
|
||||
vueCustomBlockTransforms: {
|
||||
...config.vueCustomBlockTransforms,
|
||||
...plugin.vueCustomBlockTransforms
|
||||
},
|
||||
rollupInputOptions: mergeObjectOptions(config.rollupInputOptions, plugin.rollupInputOptions),
|
||||
rollupOutputOptions: mergeObjectOptions(config.rollupOutputOptions, plugin.rollupOutputOptions),
|
||||
enableRollupPluginVue: config.enableRollupPluginVue || plugin.enableRollupPluginVue
|
||||
};
|
||||
}
|
||||
function mergeAssetUrlOptions(to, from) {
|
||||
if (from === true) {
|
||||
return to;
|
||||
}
|
||||
if (from === false) {
|
||||
return from;
|
||||
}
|
||||
if (typeof to === 'boolean') {
|
||||
return from || to;
|
||||
}
|
||||
return {
|
||||
...normalizeAssetUrlOptions(to),
|
||||
...normalizeAssetUrlOptions(from)
|
||||
};
|
||||
}
|
||||
function normalizeAssetUrlOptions(o) {
|
||||
if (o && Object.keys(o).some((key) => Array.isArray(o[key]))) {
|
||||
return {
|
||||
tags: o
|
||||
};
|
||||
}
|
||||
else {
|
||||
return o;
|
||||
}
|
||||
}
|
||||
function mergeObjectOptions(to, from) {
|
||||
if (!to)
|
||||
return from;
|
||||
if (!from)
|
||||
return to;
|
||||
const res = { ...to };
|
||||
for (const key in from) {
|
||||
const existing = res[key];
|
||||
const toMerge = from[key];
|
||||
if (Array.isArray(existing) || Array.isArray(toMerge)) {
|
||||
res[key] = [].concat(existing, toMerge).filter(Boolean);
|
||||
}
|
||||
else {
|
||||
res[key] = toMerge;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
function loadEnv(mode, root) {
|
||||
if (mode === 'local') {
|
||||
throw new Error(`"local" cannot be used as a mode name because it conflicts with ` +
|
||||
`the .local postfix for .env files.`);
|
||||
}
|
||||
debug(`env mode: ${mode}`);
|
||||
const clientEnv = {};
|
||||
const envFiles = [
|
||||
/** mode local file */ `.env.${mode}.local`,
|
||||
/** mode file */ `.env.${mode}`,
|
||||
/** local file */ `.env.local`,
|
||||
/** default file */ `.env`
|
||||
];
|
||||
for (const file of envFiles) {
|
||||
const path = utils_1.lookupFile(root, [file], true);
|
||||
if (path) {
|
||||
// NOTE: this mutates process.env
|
||||
const { parsed, error } = dotenv_1.default.config({
|
||||
debug: !!process.env.DEBUG || undefined,
|
||||
path
|
||||
});
|
||||
if (!parsed) {
|
||||
throw error;
|
||||
}
|
||||
// NOTE: this mutates process.env
|
||||
dotenv_expand_1.default({ parsed });
|
||||
// set NODE_ENV under a different key so that we know this is set from
|
||||
// vite-loaded .env files. Some users may have default NODE_ENV set in
|
||||
// their system.
|
||||
if (parsed.NODE_ENV) {
|
||||
process.env.VITE_ENV = parsed.NODE_ENV;
|
||||
}
|
||||
// only keys that start with VITE_ are exposed.
|
||||
for (const [key, value] of Object.entries(parsed)) {
|
||||
if (key.startsWith(`VITE_`)) {
|
||||
clientEnv[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
debug(`env: %O`, clientEnv);
|
||||
return clientEnv;
|
||||
}
|
||||
// TODO move this into Vue plugin when we extract it
|
||||
exports.defaultDefines = {
|
||||
__VUE_OPTIONS_API__: true,
|
||||
__VUE_PROD_DEVTOOLS__: false
|
||||
};
|
||||
//# sourceMappingURL=config.js.map
|
||||
1
node_modules/vite/dist/node/config.js.map
generated
vendored
1
node_modules/vite/dist/node/config.js.map
generated
vendored
File diff suppressed because one or more lines are too long
14
node_modules/vite/dist/node/esbuildService.d.ts
generated
vendored
14
node_modules/vite/dist/node/esbuildService.d.ts
generated
vendored
@@ -1,14 +0,0 @@
|
||||
import { TransformOptions } from 'esbuild';
|
||||
import { SharedConfig } from './config';
|
||||
export declare const tjsxRE: RegExp;
|
||||
export declare const vueJsxPublicPath = "/vite/jsx";
|
||||
export declare const vueJsxFilePath: string;
|
||||
export declare function resolveJsxOptions(options?: SharedConfig['jsx']): Pick<TransformOptions, "jsxFactory" | "jsxFragment"> | undefined;
|
||||
export declare const stopService: () => Promise<void>;
|
||||
export declare const transform: (src: string, request: string, options?: TransformOptions, jsxOption?: SharedConfig['jsx']) => Promise<{
|
||||
code: string;
|
||||
map: string;
|
||||
} | {
|
||||
code: string;
|
||||
map: undefined;
|
||||
}>;
|
||||
114
node_modules/vite/dist/node/esbuildService.js
generated
vendored
114
node_modules/vite/dist/node/esbuildService.js
generated
vendored
@@ -1,114 +0,0 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.transform = exports.stopService = exports.resolveJsxOptions = exports.vueJsxFilePath = exports.vueJsxPublicPath = exports.tjsxRE = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const chalk_1 = __importDefault(require("chalk"));
|
||||
const esbuild_1 = require("esbuild");
|
||||
const utils_1 = require("./utils");
|
||||
const debug = require('debug')('vite:esbuild');
|
||||
exports.tjsxRE = /\.(tsx?|jsx)$/;
|
||||
exports.vueJsxPublicPath = '/vite/jsx';
|
||||
exports.vueJsxFilePath = path_1.default.resolve(__dirname, '../client/vueJsxCompat.js');
|
||||
const JsxPresets = {
|
||||
vue: { jsxFactory: 'jsx', jsxFragment: 'Fragment' },
|
||||
preact: { jsxFactory: 'h', jsxFragment: 'Fragment' },
|
||||
react: {} // use esbuild default
|
||||
};
|
||||
function resolveJsxOptions(options = 'vue') {
|
||||
if (typeof options === 'string') {
|
||||
if (!(options in JsxPresets)) {
|
||||
console.error(`[vite] unknown jsx preset: '${options}'.`);
|
||||
}
|
||||
return JsxPresets[options] || {};
|
||||
}
|
||||
else if (options) {
|
||||
return {
|
||||
jsxFactory: options.factory,
|
||||
jsxFragment: options.fragment
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.resolveJsxOptions = resolveJsxOptions;
|
||||
// lazy start the service
|
||||
let _servicePromise;
|
||||
const ensureService = async () => {
|
||||
if (!_servicePromise) {
|
||||
_servicePromise = esbuild_1.startService();
|
||||
}
|
||||
return _servicePromise;
|
||||
};
|
||||
exports.stopService = async () => {
|
||||
if (_servicePromise) {
|
||||
const service = await _servicePromise;
|
||||
service.stop();
|
||||
_servicePromise = undefined;
|
||||
}
|
||||
};
|
||||
// transform used in server plugins with a more friendly API
|
||||
exports.transform = async (src, request, options = {}, jsxOption) => {
|
||||
const service = await ensureService();
|
||||
const file = utils_1.cleanUrl(request);
|
||||
options = {
|
||||
loader: options.loader || path_1.default.extname(file).slice(1),
|
||||
sourcemap: true,
|
||||
// ensure source file name contains full query
|
||||
sourcefile: request,
|
||||
target: 'es2020',
|
||||
...options
|
||||
};
|
||||
try {
|
||||
const result = await service.transform(src, options);
|
||||
if (result.warnings.length) {
|
||||
console.error(`[vite] warnings while transforming ${file} with esbuild:`);
|
||||
result.warnings.forEach((m) => printMessage(m, src));
|
||||
}
|
||||
let code = result.js;
|
||||
// if transpiling (j|t)sx file, inject the imports for the jsx helper and
|
||||
// Fragment.
|
||||
if (file.endsWith('x')) {
|
||||
if (!jsxOption || jsxOption === 'vue') {
|
||||
code +=
|
||||
`\nimport { jsx } from '${exports.vueJsxPublicPath}'` +
|
||||
`\nimport { Fragment } from 'vue'`;
|
||||
}
|
||||
if (jsxOption === 'preact') {
|
||||
code += `\nimport { h, Fragment } from 'preact'`;
|
||||
}
|
||||
}
|
||||
return {
|
||||
code,
|
||||
map: result.jsSourceMap
|
||||
};
|
||||
}
|
||||
catch (e) {
|
||||
console.error(chalk_1.default.red(`[vite] error while transforming ${file} with esbuild:`));
|
||||
if (e.errors) {
|
||||
e.errors.forEach((m) => printMessage(m, src));
|
||||
}
|
||||
else {
|
||||
console.error(e);
|
||||
}
|
||||
debug(`options used: `, options);
|
||||
return {
|
||||
code: '',
|
||||
map: undefined
|
||||
};
|
||||
}
|
||||
};
|
||||
function printMessage(m, code) {
|
||||
console.error(chalk_1.default.yellow(m.text));
|
||||
if (m.location) {
|
||||
const lines = code.split(/\r?\n/g);
|
||||
const line = Number(m.location.line);
|
||||
const column = Number(m.location.column);
|
||||
const offset = lines
|
||||
.slice(0, line - 1)
|
||||
.map((l) => l.length)
|
||||
.reduce((total, l) => total + l + 1, 0) + column;
|
||||
console.error(require('@vue/compiler-dom').generateCodeFrame(code, offset, offset + 1));
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=esbuildService.js.map
|
||||
1
node_modules/vite/dist/node/esbuildService.js.map
generated
vendored
1
node_modules/vite/dist/node/esbuildService.js.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"esbuildService.js","sourceRoot":"","sources":["../../src/node/esbuildService.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AACvB,kDAAyB;AACzB,qCAMgB;AAEhB,mCAAkC;AAElC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,CAAA;AAEjC,QAAA,MAAM,GAAG,eAAe,CAAA;AAExB,QAAA,gBAAgB,GAAG,WAAW,CAAA;AAE9B,QAAA,cAAc,GAAG,cAAI,CAAC,OAAO,CACxC,SAAS,EACT,2BAA2B,CAC5B,CAAA;AAED,MAAM,UAAU,GAGZ;IACF,GAAG,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE;IACnD,MAAM,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE,UAAU,EAAE;IACpD,KAAK,EAAE,EAAE,CAAC,sBAAsB;CACjC,CAAA;AAED,SAAgB,iBAAiB,CAAC,UAA+B,KAAK;IACpE,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QAC/B,IAAI,CAAC,CAAC,OAAO,IAAI,UAAU,CAAC,EAAE;YAC5B,OAAO,CAAC,KAAK,CAAC,+BAA+B,OAAO,IAAI,CAAC,CAAA;SAC1D;QACD,OAAO,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,CAAA;KACjC;SAAM,IAAI,OAAO,EAAE;QAClB,OAAO;YACL,UAAU,EAAE,OAAO,CAAC,OAAO;YAC3B,WAAW,EAAE,OAAO,CAAC,QAAQ;SAC9B,CAAA;KACF;AACH,CAAC;AAZD,8CAYC;AAED,yBAAyB;AACzB,IAAI,eAA6C,CAAA;AAEjD,MAAM,aAAa,GAAG,KAAK,IAAI,EAAE;IAC/B,IAAI,CAAC,eAAe,EAAE;QACpB,eAAe,GA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EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;aACpB,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAA;QACpD,OAAO,CAAC,KAAK,CACX,OAAO,CAAC,mBAAmB,CAAC,CAAC,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,CACzE,CAAA;KACF;AACH,CAAC"}
|
||||
2417
node_modules/vite/dist/node/index.d.ts
generated
vendored
2417
node_modules/vite/dist/node/index.d.ts
generated
vendored
File diff suppressed because it is too large
Load Diff
68
node_modules/vite/dist/node/index.js
generated
vendored
68
node_modules/vite/dist/node/index.js
generated
vendored
@@ -1,24 +1,44 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.injectScriptToHtml = exports.isImportRequest = exports.isStaticAsset = exports.cachedRead = exports.readBody = void 0;
|
||||
__exportStar(require("./server"), exports);
|
||||
__exportStar(require("./build"), exports);
|
||||
__exportStar(require("./optimizer"), exports);
|
||||
__exportStar(require("./config"), exports);
|
||||
var utils_1 = require("./utils");
|
||||
Object.defineProperty(exports, "readBody", { enumerable: true, get: function () { return utils_1.readBody; } });
|
||||
Object.defineProperty(exports, "cachedRead", { enumerable: true, get: function () { return utils_1.cachedRead; } });
|
||||
Object.defineProperty(exports, "isStaticAsset", { enumerable: true, get: function () { return utils_1.isStaticAsset; } });
|
||||
Object.defineProperty(exports, "isImportRequest", { enumerable: true, get: function () { return utils_1.isImportRequest; } });
|
||||
Object.defineProperty(exports, "injectScriptToHtml", { enumerable: true, get: function () { return utils_1.injectScriptToHtml; } });
|
||||
//# sourceMappingURL=index.js.map
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var build = require('./chunks/dep-1bdbec90.js');
|
||||
require('os');
|
||||
require('fs');
|
||||
require('path');
|
||||
require('tty');
|
||||
require('util');
|
||||
require('net');
|
||||
require('events');
|
||||
require('url');
|
||||
require('http');
|
||||
require('stream');
|
||||
require('zlib');
|
||||
require('resolve');
|
||||
require('module');
|
||||
require('readline');
|
||||
require('crypto');
|
||||
require('worker_threads');
|
||||
require('assert');
|
||||
require('https');
|
||||
require('tls');
|
||||
require('buffer');
|
||||
require('child_process');
|
||||
require('querystring');
|
||||
|
||||
|
||||
|
||||
exports.build = build.build;
|
||||
exports.createLogger = build.createLogger;
|
||||
exports.createServer = build.createServer;
|
||||
exports.defineConfig = build.defineConfig;
|
||||
exports.loadConfigFromFile = build.loadConfigFromFile;
|
||||
exports.loadEnv = build.loadEnv;
|
||||
exports.mergeConfig = build.mergeConfig;
|
||||
exports.normalizePath = build.normalizePath;
|
||||
exports.optimizeDeps = build.optimizeDeps;
|
||||
exports.resolveConfig = build.resolveConfig;
|
||||
exports.resolvePackageData = build.resolvePackageData;
|
||||
exports.resolvePackageEntry = build.resolvePackageEntry;
|
||||
exports.send = build.send;
|
||||
exports.sortUserPlugins = build.sortUserPlugins;
|
||||
|
||||
1
node_modules/vite/dist/node/index.js.map
generated
vendored
1
node_modules/vite/dist/node/index.js.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAwB;AACxB,0CAAuB;AACvB,8CAA2B;AAC3B,2CAAwB;AACxB,iCAMgB;AALd,iGAAA,QAAQ,OAAA;AACR,mGAAA,UAAU,OAAA;AACV,sGAAA,aAAa,OAAA;AACb,wGAAA,eAAe,OAAA;AACf,2GAAA,kBAAkB,OAAA"}
|
||||
33
node_modules/vite/dist/node/optimizer/index.d.ts
generated
vendored
33
node_modules/vite/dist/node/optimizer/index.d.ts
generated
vendored
@@ -1,33 +0,0 @@
|
||||
import { ResolvedConfig } from '../config';
|
||||
export interface DepOptimizationOptions {
|
||||
/**
|
||||
* Force optimize listed dependencies (supports deep paths).
|
||||
*/
|
||||
include?: string[];
|
||||
/**
|
||||
* Do not optimize these dependencies.
|
||||
*/
|
||||
exclude?: string[];
|
||||
/**
|
||||
* A list of linked dependencies that should be treated as source code.
|
||||
* Use this to list linked packages in a monorepo so that their dependencies
|
||||
* are also included for optimization.
|
||||
*/
|
||||
link?: string[];
|
||||
/**
|
||||
* A list of depdendencies that imports Node built-ins, but do not actually
|
||||
* use them in browsers.
|
||||
*/
|
||||
allowNodeBuiltins?: string[];
|
||||
/**
|
||||
* Automatically run `vite optimize` on server start?
|
||||
* @default true
|
||||
*/
|
||||
auto?: boolean;
|
||||
}
|
||||
export declare const OPTIMIZE_CACHE_DIR = "node_modules/.vite_opt_cache";
|
||||
export declare function optimizeDeps(config: ResolvedConfig & {
|
||||
force?: boolean;
|
||||
}, asCommand?: boolean): Promise<void>;
|
||||
export declare function getDepHash(root: string, configPath: string | undefined): string;
|
||||
export declare function resolveOptimizedCacheDir(root: string, pkgPath?: string): string | null;
|
||||
306
node_modules/vite/dist/node/optimizer/index.js
generated
vendored
306
node_modules/vite/dist/node/optimizer/index.js
generated
vendored
@@ -1,306 +0,0 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.resolveOptimizedCacheDir = exports.getDepHash = exports.optimizeDeps = exports.OPTIMIZE_CACHE_DIR = void 0;
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const crypto_1 = require("crypto");
|
||||
const resolver_1 = require("../resolver");
|
||||
const build_1 = require("../build");
|
||||
const utils_1 = require("../utils");
|
||||
const es_module_lexer_1 = require("es-module-lexer");
|
||||
const chalk_1 = __importDefault(require("chalk"));
|
||||
const pluginAssets_1 = require("./pluginAssets");
|
||||
const debug = require('debug')('vite:optimize');
|
||||
const KNOWN_IGNORE_LIST = new Set([
|
||||
'vite',
|
||||
'vitepress',
|
||||
'tailwindcss',
|
||||
'@tailwindcss/ui',
|
||||
'@pika/react',
|
||||
'@pika/react-dom'
|
||||
]);
|
||||
exports.OPTIMIZE_CACHE_DIR = `node_modules/.vite_opt_cache`;
|
||||
async function optimizeDeps(config, asCommand = false) {
|
||||
const log = asCommand ? console.log : debug;
|
||||
const root = config.root || process.cwd();
|
||||
// warn presence of web_modules
|
||||
if (fs_extra_1.default.existsSync(path_1.default.join(root, 'web_modules'))) {
|
||||
console.warn(chalk_1.default.yellow(`[vite] vite 0.15 has built-in dependency pre-bundling and resolving ` +
|
||||
`from web_modules is no longer supported.`));
|
||||
}
|
||||
const pkgPath = utils_1.lookupFile(root, [`package.json`], true /* pathOnly */);
|
||||
if (!pkgPath) {
|
||||
log(`package.json not found. Skipping.`);
|
||||
return;
|
||||
}
|
||||
const cacheDir = resolveOptimizedCacheDir(root, pkgPath);
|
||||
const hashPath = path_1.default.join(cacheDir, 'hash');
|
||||
const depHash = getDepHash(root, config.__path);
|
||||
if (!config.force) {
|
||||
let prevhash;
|
||||
try {
|
||||
prevhash = await fs_extra_1.default.readFile(hashPath, 'utf-8');
|
||||
}
|
||||
catch (e) { }
|
||||
// hash is consistent, no need to re-bundle
|
||||
if (prevhash === depHash) {
|
||||
log('Hash is consistent. Skipping. Use --force to override.');
|
||||
return;
|
||||
}
|
||||
}
|
||||
await fs_extra_1.default.remove(cacheDir);
|
||||
await fs_extra_1.default.ensureDir(cacheDir);
|
||||
const options = config.optimizeDeps || {};
|
||||
const resolver = resolver_1.createResolver(root, config.resolvers, config.alias, config.assetsInclude);
|
||||
// Determine deps to optimize. The goal is to only pre-bundle deps that falls
|
||||
// under one of the following categories:
|
||||
// 1. Has imports to relative files (e.g. lodash-es, lit-html)
|
||||
// 2. Has imports to bare modules that are not in the project's own deps
|
||||
// (i.e. esm that imports its own dependencies, e.g. styled-components)
|
||||
await es_module_lexer_1.init;
|
||||
const { qualified, external } = resolveQualifiedDeps(root, options, resolver);
|
||||
// Resolve deps from linked packages in a monorepo
|
||||
if (options.link) {
|
||||
options.link.forEach((linkedDep) => {
|
||||
const depRoot = path_1.default.dirname(utils_1.resolveFrom(root, `${linkedDep}/package.json`));
|
||||
const { qualified: q, external: e } = resolveQualifiedDeps(depRoot, options, resolver);
|
||||
Object.keys(q).forEach((id) => {
|
||||
if (!qualified[id]) {
|
||||
qualified[id] = q[id];
|
||||
}
|
||||
});
|
||||
e.forEach((id) => {
|
||||
if (!external.includes(id)) {
|
||||
external.push(id);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
// Force included deps - these can also be deep paths
|
||||
if (options.include) {
|
||||
options.include.forEach((id) => {
|
||||
const pkg = resolver_1.resolveNodeModule(root, id, resolver);
|
||||
if (pkg && pkg.entryFilePath) {
|
||||
qualified[id] = pkg.entryFilePath;
|
||||
}
|
||||
else {
|
||||
const filePath = resolver_1.resolveNodeModuleFile(root, id);
|
||||
if (filePath) {
|
||||
qualified[id] = filePath;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!Object.keys(qualified).length) {
|
||||
await fs_extra_1.default.writeFile(hashPath, depHash);
|
||||
log(`No listed dependency requires optimization. Skipping.`);
|
||||
return;
|
||||
}
|
||||
if (!asCommand) {
|
||||
// This is auto run on server start - let the user know that we are
|
||||
// pre-optimizing deps
|
||||
console.log(chalk_1.default.greenBright(`[vite] Optimizable dependencies detected:`));
|
||||
console.log(Object.keys(qualified)
|
||||
.map((id) => chalk_1.default.yellow(id))
|
||||
.join(`, `));
|
||||
}
|
||||
let spinner;
|
||||
const msg = asCommand
|
||||
? `Pre-bundling dependencies to speed up dev server page load...`
|
||||
: `Pre-bundling them to speed up dev server page load...\n` +
|
||||
`(this will be run only when your dependencies have changed)`;
|
||||
if (process.env.DEBUG || process.env.NODE_ENV === 'test') {
|
||||
console.log(msg);
|
||||
}
|
||||
else {
|
||||
spinner = require('ora')(msg + '\n').start();
|
||||
}
|
||||
try {
|
||||
const rollup = require('rollup');
|
||||
const bundle = await rollup.rollup({
|
||||
input: qualified,
|
||||
external,
|
||||
// treeshake: { moduleSideEffects: 'no-external' },
|
||||
onwarn: build_1.onRollupWarning(spinner, options),
|
||||
...config.rollupInputOptions,
|
||||
plugins: [
|
||||
pluginAssets_1.createDepAssetExternalPlugin(resolver),
|
||||
...(await build_1.createBaseRollupPlugins(root, resolver, config)),
|
||||
pluginAssets_1.createDepAssetPlugin(resolver, root),
|
||||
...((config.rollupInputOptions &&
|
||||
config.rollupInputOptions.pluginsOptimizer) ||
|
||||
[])
|
||||
]
|
||||
});
|
||||
const { output } = await bundle.generate({
|
||||
...config.rollupOutputOptions,
|
||||
format: 'es',
|
||||
exports: 'named',
|
||||
entryFileNames: '[name].js',
|
||||
chunkFileNames: 'common/[name]-[hash].js'
|
||||
});
|
||||
spinner && spinner.stop();
|
||||
for (const chunk of output) {
|
||||
if (chunk.type === 'chunk') {
|
||||
const fileName = chunk.fileName;
|
||||
const filePath = path_1.default.join(cacheDir, fileName);
|
||||
await fs_extra_1.default.ensureDir(path_1.default.dirname(filePath));
|
||||
await fs_extra_1.default.writeFile(filePath, chunk.code);
|
||||
}
|
||||
}
|
||||
await fs_extra_1.default.writeFile(hashPath, depHash);
|
||||
}
|
||||
catch (e) {
|
||||
spinner && spinner.stop();
|
||||
if (asCommand) {
|
||||
throw e;
|
||||
}
|
||||
else {
|
||||
console.error(chalk_1.default.red(`\n[vite] Dep optimization failed with error:`));
|
||||
console.error(chalk_1.default.red(e.message));
|
||||
if (e.code === 'PARSE_ERROR') {
|
||||
console.error(chalk_1.default.cyan(path_1.default.relative(root, e.loc.file)));
|
||||
console.error(chalk_1.default.dim(e.frame));
|
||||
}
|
||||
else if (e.message.match('Node built-in')) {
|
||||
console.log();
|
||||
console.log(chalk_1.default.yellow(`Tip:\nMake sure your "dependencies" only include packages that you\n` +
|
||||
`intend to use in the browser. If it's a Node.js package, it\n` +
|
||||
`should be in "devDependencies".\n\n` +
|
||||
`If you do intend to use this dependency in the browser and the\n` +
|
||||
`dependency does not actually use these Node built-ins in the\n` +
|
||||
`browser, you can add the dependency (not the built-in) to the\n` +
|
||||
`"optimizeDeps.allowNodeBuiltins" option in vite.config.js.\n\n` +
|
||||
`If that results in a runtime error, then unfortunately the\n` +
|
||||
`package is not distributed in a web-friendly format. You should\n` +
|
||||
`open an issue in its repo, or look for a modern alternative.`)
|
||||
// TODO link to docs once we have it
|
||||
);
|
||||
}
|
||||
else {
|
||||
console.error(e);
|
||||
}
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.optimizeDeps = optimizeDeps;
|
||||
function resolveQualifiedDeps(root, options, resolver) {
|
||||
const { include, exclude, link } = options;
|
||||
const pkgContent = utils_1.lookupFile(root, ['package.json']);
|
||||
if (!pkgContent) {
|
||||
return {
|
||||
qualified: {},
|
||||
external: []
|
||||
};
|
||||
}
|
||||
const pkg = JSON.parse(pkgContent);
|
||||
const deps = Object.keys(pkg.dependencies || {});
|
||||
const qualifiedDeps = deps.filter((id) => {
|
||||
if (include && include.includes(id)) {
|
||||
// already force included
|
||||
return false;
|
||||
}
|
||||
if (exclude && exclude.includes(id)) {
|
||||
debug(`skipping ${id} (excluded)`);
|
||||
return false;
|
||||
}
|
||||
if (link && link.includes(id)) {
|
||||
debug(`skipping ${id} (link)`);
|
||||
return false;
|
||||
}
|
||||
if (KNOWN_IGNORE_LIST.has(id)) {
|
||||
debug(`skipping ${id} (internal excluded)`);
|
||||
return false;
|
||||
}
|
||||
// #804
|
||||
if (id.startsWith('@types/')) {
|
||||
debug(`skipping ${id} (ts declaration)`);
|
||||
return false;
|
||||
}
|
||||
const pkgInfo = resolver_1.resolveNodeModule(root, id, resolver);
|
||||
if (!pkgInfo || !pkgInfo.entryFilePath) {
|
||||
debug(`skipping ${id} (cannot resolve entry)`);
|
||||
console.log(root, id);
|
||||
console.error(chalk_1.default.yellow(`[vite] cannot resolve entry for dependency ${chalk_1.default.cyan(id)}.`));
|
||||
return false;
|
||||
}
|
||||
const { entryFilePath } = pkgInfo;
|
||||
if (!resolver_1.supportedExts.includes(path_1.default.extname(entryFilePath))) {
|
||||
debug(`skipping ${id} (entry is not js)`);
|
||||
return false;
|
||||
}
|
||||
if (!fs_extra_1.default.existsSync(entryFilePath)) {
|
||||
debug(`skipping ${id} (entry file does not exist)`);
|
||||
console.error(chalk_1.default.yellow(`[vite] dependency ${id} declares non-existent entry file ${entryFilePath}.`));
|
||||
return false;
|
||||
}
|
||||
const content = fs_extra_1.default.readFileSync(entryFilePath, 'utf-8');
|
||||
const [imports, exports] = es_module_lexer_1.parse(content);
|
||||
if (!exports.length && !/export\s+\*\s+from/.test(content)) {
|
||||
debug(`optimizing ${id} (no exports, likely commonjs)`);
|
||||
return true;
|
||||
}
|
||||
for (const { s, e } of imports) {
|
||||
let i = content.slice(s, e).trim();
|
||||
i = resolver.alias(i) || i;
|
||||
if (i.startsWith('.')) {
|
||||
debug(`optimizing ${id} (contains relative imports)`);
|
||||
return true;
|
||||
}
|
||||
if (!deps.includes(i)) {
|
||||
debug(`optimizing ${id} (imports sub dependencies)`);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
debug(`skipping ${id} (single esm file, doesn't need optimization)`);
|
||||
});
|
||||
const qualified = {};
|
||||
qualifiedDeps.forEach((id) => {
|
||||
qualified[id] = resolver_1.resolveNodeModule(root, id, resolver).entryFilePath;
|
||||
});
|
||||
// mark non-optimized deps as external
|
||||
const external = deps
|
||||
.filter((id) => !qualifiedDeps.includes(id))
|
||||
// make sure aliased deps are external
|
||||
// https://github.com/vitejs/vite-plugin-react/issues/4
|
||||
.map((id) => resolver.alias(id) || id);
|
||||
return {
|
||||
qualified,
|
||||
external
|
||||
};
|
||||
}
|
||||
const lockfileFormats = ['package-lock.json', 'yarn.lock', 'pnpm-lock.yaml'];
|
||||
let cachedHash;
|
||||
function getDepHash(root, configPath) {
|
||||
if (cachedHash) {
|
||||
return cachedHash;
|
||||
}
|
||||
let content = utils_1.lookupFile(root, lockfileFormats) || '';
|
||||
const pkg = JSON.parse(utils_1.lookupFile(root, [`package.json`]) || '{}');
|
||||
content += JSON.stringify(pkg.dependencies);
|
||||
// also take config into account
|
||||
if (configPath) {
|
||||
content += fs_extra_1.default.readFileSync(configPath, 'utf-8');
|
||||
}
|
||||
return crypto_1.createHash('sha1').update(content).digest('base64');
|
||||
}
|
||||
exports.getDepHash = getDepHash;
|
||||
const cacheDirCache = new Map();
|
||||
function resolveOptimizedCacheDir(root, pkgPath) {
|
||||
const cached = cacheDirCache.get(root);
|
||||
if (cached !== undefined)
|
||||
return cached;
|
||||
pkgPath = pkgPath || utils_1.lookupFile(root, [`package.json`], true /* pathOnly */);
|
||||
if (!pkgPath) {
|
||||
return null;
|
||||
}
|
||||
const cacheDir = path_1.default.join(path_1.default.dirname(pkgPath), exports.OPTIMIZE_CACHE_DIR);
|
||||
cacheDirCache.set(root, cacheDir);
|
||||
return cacheDir;
|
||||
}
|
||||
exports.resolveOptimizedCacheDir = resolveOptimizedCacheDir;
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/vite/dist/node/optimizer/index.js.map
generated
vendored
1
node_modules/vite/dist/node/optimizer/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
4
node_modules/vite/dist/node/optimizer/pluginAssets.d.ts
generated
vendored
4
node_modules/vite/dist/node/optimizer/pluginAssets.d.ts
generated
vendored
@@ -1,4 +0,0 @@
|
||||
import { Plugin } from 'rollup';
|
||||
import { InternalResolver } from '../resolver';
|
||||
export declare const createDepAssetExternalPlugin: (resolver: InternalResolver) => Plugin;
|
||||
export declare const createDepAssetPlugin: (resolver: InternalResolver, root: string) => Plugin;
|
||||
64
node_modules/vite/dist/node/optimizer/pluginAssets.js
generated
vendored
64
node_modules/vite/dist/node/optimizer/pluginAssets.js
generated
vendored
@@ -1,64 +0,0 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createDepAssetPlugin = exports.createDepAssetExternalPlugin = void 0;
|
||||
const es_module_lexer_1 = require("es-module-lexer");
|
||||
const cssUtils_1 = require("../utils/cssUtils");
|
||||
const magic_string_1 = __importDefault(require("magic-string"));
|
||||
const utils_1 = require("../utils");
|
||||
const path_1 = __importDefault(require("path"));
|
||||
exports.createDepAssetExternalPlugin = (resolver) => ({
|
||||
name: 'vite:optimize-dep-assets-external',
|
||||
resolveId(id) {
|
||||
if (cssUtils_1.isCSSRequest(id) || resolver.isAssetRequest(id)) {
|
||||
return {
|
||||
id,
|
||||
external: true
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
exports.createDepAssetPlugin = (resolver, root) => {
|
||||
return {
|
||||
name: 'vite:optimize-dep-assets',
|
||||
async transform(code, id) {
|
||||
if (id.endsWith('.js')) {
|
||||
await es_module_lexer_1.init;
|
||||
const [imports] = es_module_lexer_1.parse(code);
|
||||
if (imports.length) {
|
||||
let s;
|
||||
for (let i = 0; i < imports.length; i++) {
|
||||
const { s: start, e: end, d: dynamicIndex, ss: statementStart, se: statementEnd } = imports[i];
|
||||
if (dynamicIndex === -1) {
|
||||
const importee = code.slice(start, end);
|
||||
if (cssUtils_1.isCSSRequest(importee) || resolver.isAssetRequest(importee)) {
|
||||
// replace css/asset imports to deep imports to their original
|
||||
// location
|
||||
s = s || new magic_string_1.default(code);
|
||||
// #903 rollup-plugin-commonjs will inject proxy helper, it is unnecessary for assets
|
||||
if (importee.endsWith('?commonjs-proxy')) {
|
||||
s.remove(statementStart, statementEnd);
|
||||
continue;
|
||||
}
|
||||
const deepPath = resolver.fileToRequest(utils_1.bareImportRE.test(importee)
|
||||
? utils_1.resolveFrom(root, importee)
|
||||
: path_1.default.resolve(path_1.default.dirname(id), importee));
|
||||
s.overwrite(start, end, deepPath);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// ignore dynamic import
|
||||
}
|
||||
}
|
||||
if (s) {
|
||||
return s.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
};
|
||||
//# sourceMappingURL=pluginAssets.js.map
|
||||
1
node_modules/vite/dist/node/optimizer/pluginAssets.js.map
generated
vendored
1
node_modules/vite/dist/node/optimizer/pluginAssets.js.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"pluginAssets.js","sourceRoot":"","sources":["../../../src/node/optimizer/pluginAssets.ts"],"names":[],"mappings":";;;;;;AACA,qDAA6C;AAC7C,gDAAgD;AAChD,gEAAsC;AACtC,oCAAoD;AACpD,gDAAuB;AAGV,QAAA,4BAA4B,GAAG,CAC1C,QAA0B,EAClB,EAAE,CAAC,CAAC;IACZ,IAAI,EAAE,mCAAmC;IACzC,SAAS,CAAC,EAAE;QACV,IAAI,uBAAY,CAAC,EAAE,CAAC,IAAI,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE;YACnD,OAAO;gBACL,EAAE;gBACF,QAAQ,EAAE,IAAI;aACf,CAAA;SACF;IACH,CAAC;CACF,CAAC,CAAA;AAEW,QAAA,oBAAoB,GAAG,CAClC,QAA0B,EAC1B,IAAY,EACJ,EAAE;IACV,OAAO;QACL,IAAI,EAAE,0BAA0B;QAChC,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE;YACtB,IAAI,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EA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AAA;6BAClC;yBACF;6BAAM;4BACL,wBAAwB;yBACzB;qBACF;oBACD,IAAI,CAAC,EAAE;wBACL,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAA;qBACpB;iBACF;aACF;YACD,OAAO,IAAI,CAAA;QACb,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
|
||||
39
node_modules/vite/dist/node/resolver.d.ts
generated
vendored
39
node_modules/vite/dist/node/resolver.d.ts
generated
vendored
@@ -1,39 +0,0 @@
|
||||
export interface Resolver {
|
||||
requestToFile?(publicPath: string, root: string): string | undefined;
|
||||
fileToRequest?(filePath: string, root: string): string | undefined;
|
||||
alias?: ((id: string) => string | undefined) | Record<string, string>;
|
||||
}
|
||||
export interface InternalResolver {
|
||||
requestToFile(publicPath: string): string;
|
||||
fileToRequest(filePath: string): string;
|
||||
normalizePublicPath(publicPath: string): string;
|
||||
alias(id: string): string | undefined;
|
||||
resolveRelativeRequest(publicPath: string, relativePublicPath: string): {
|
||||
pathname: string;
|
||||
query: string;
|
||||
};
|
||||
isPublicRequest(publicPath: string): boolean;
|
||||
isAssetRequest(filePath: string): boolean;
|
||||
}
|
||||
export declare const supportedExts: string[];
|
||||
export declare const mainFields: string[];
|
||||
export declare function createResolver(root: string, resolvers?: Resolver[], userAlias?: Record<string, string>, assetsInclude?: (file: string) => boolean): InternalResolver;
|
||||
export declare const jsSrcRE: RegExp;
|
||||
/**
|
||||
* Redirects a bare module request to a full path under /@modules/
|
||||
* It resolves a bare node module id to its full entry path so that relative
|
||||
* imports from the entry can be correctly resolved.
|
||||
* e.g.:
|
||||
* - `import 'foo'` -> `import '/@modules/foo/dist/index.js'`
|
||||
* - `import 'foo/bar/baz'` -> `import '/@modules/foo/bar/baz.js'`
|
||||
*/
|
||||
export declare function resolveBareModuleRequest(root: string, id: string, importer: string, resolver: InternalResolver): string;
|
||||
export declare function resolveOptimizedModule(root: string, id: string): string | undefined;
|
||||
interface NodeModuleInfo {
|
||||
entry: string | undefined;
|
||||
entryFilePath: string | undefined;
|
||||
pkg: any;
|
||||
}
|
||||
export declare function resolveNodeModule(root: string, id: string, resolver: InternalResolver): NodeModuleInfo | undefined;
|
||||
export declare function resolveNodeModuleFile(root: string, id: string): string | undefined;
|
||||
export {};
|
||||
484
node_modules/vite/dist/node/resolver.js
generated
vendored
484
node_modules/vite/dist/node/resolver.js
generated
vendored
@@ -1,484 +0,0 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.resolveNodeModuleFile = exports.resolveNodeModule = exports.resolveOptimizedModule = exports.resolveBareModuleRequest = exports.jsSrcRE = exports.createResolver = exports.mainFields = exports.supportedExts = void 0;
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const slash_1 = __importDefault(require("slash"));
|
||||
const utils_1 = require("./utils");
|
||||
const serverPluginModuleResolve_1 = require("./server/serverPluginModuleResolve");
|
||||
const optimizer_1 = require("./optimizer");
|
||||
const serverPluginClient_1 = require("./server/serverPluginClient");
|
||||
const cssUtils_1 = require("./utils/cssUtils");
|
||||
const pathUtils_1 = require("./utils/pathUtils");
|
||||
const chalk_1 = __importDefault(require("chalk"));
|
||||
const debug = require('debug')('vite:resolve');
|
||||
const isWin = require('os').platform() === 'win32';
|
||||
const pathSeparator = isWin ? '\\' : '/';
|
||||
exports.supportedExts = ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json'];
|
||||
exports.mainFields = ['module', 'jsnext', 'jsnext:main', 'browser', 'main'];
|
||||
const defaultRequestToFile = (publicPath, root) => {
|
||||
if (serverPluginModuleResolve_1.moduleRE.test(publicPath)) {
|
||||
const id = publicPath.replace(serverPluginModuleResolve_1.moduleRE, '');
|
||||
const cachedNodeModule = serverPluginModuleResolve_1.moduleIdToFileMap.get(id);
|
||||
if (cachedNodeModule) {
|
||||
return cachedNodeModule;
|
||||
}
|
||||
// try to resolve from optimized modules
|
||||
const optimizedModule = resolveOptimizedModule(root, id);
|
||||
if (optimizedModule) {
|
||||
return optimizedModule;
|
||||
}
|
||||
// try to resolve from normal node_modules
|
||||
const nodeModule = resolveNodeModuleFile(root, id);
|
||||
if (nodeModule) {
|
||||
serverPluginModuleResolve_1.moduleIdToFileMap.set(id, nodeModule);
|
||||
return nodeModule;
|
||||
}
|
||||
}
|
||||
const publicDirPath = path_1.default.join(root, 'public', publicPath.slice(1));
|
||||
if (fs_extra_1.default.existsSync(publicDirPath)) {
|
||||
return publicDirPath;
|
||||
}
|
||||
return path_1.default.join(root, publicPath.slice(1));
|
||||
};
|
||||
const defaultFileToRequest = (filePath, root) => serverPluginModuleResolve_1.moduleFileToIdMap.get(filePath) ||
|
||||
'/' + slash_1.default(path_1.default.relative(root, filePath)).replace(/^public\//, '');
|
||||
const isFile = (file) => {
|
||||
try {
|
||||
return fs_extra_1.default.statSync(file).isFile();
|
||||
}
|
||||
catch (e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* this function resolve fuzzy file path. examples:
|
||||
* /path/file is a fuzzy file path for /path/file.tsx
|
||||
* /path/dir is a fuzzy file path for /path/dir/index.js
|
||||
*
|
||||
* returning undefined indicates the filePath is not fuzzy:
|
||||
* it is already an exact file path, or it can't match any file
|
||||
*/
|
||||
const resolveFilePathPostfix = (filePath) => {
|
||||
const cleanPath = utils_1.cleanUrl(filePath);
|
||||
if (!isFile(cleanPath)) {
|
||||
let postfix = '';
|
||||
for (const ext of exports.supportedExts) {
|
||||
if (isFile(cleanPath + ext)) {
|
||||
postfix = ext;
|
||||
break;
|
||||
}
|
||||
const defaultFilePath = `/index${ext}`;
|
||||
if (isFile(path_1.default.join(cleanPath, defaultFilePath))) {
|
||||
postfix = defaultFilePath;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const queryMatch = filePath.match(/\?.*$/);
|
||||
const query = queryMatch ? queryMatch[0] : '';
|
||||
const resolved = cleanPath + postfix + query;
|
||||
if (resolved !== filePath) {
|
||||
debug(`(postfix) ${filePath} -> ${resolved}`);
|
||||
return postfix;
|
||||
}
|
||||
}
|
||||
};
|
||||
const isDir = (p) => fs_extra_1.default.existsSync(p) && fs_extra_1.default.statSync(p).isDirectory();
|
||||
function createResolver(root, resolvers = [], userAlias = {}, assetsInclude) {
|
||||
resolvers = [...resolvers];
|
||||
const literalAlias = {};
|
||||
const literalDirAlias = {};
|
||||
const resolveAlias = (alias) => {
|
||||
for (const key in alias) {
|
||||
let target = alias[key];
|
||||
// aliasing a directory
|
||||
if (key.startsWith('/') && key.endsWith('/') && path_1.default.isAbsolute(target)) {
|
||||
// check first if this is aliasing to a path from root
|
||||
const fromRoot = path_1.default.join(root, target);
|
||||
if (isDir(fromRoot)) {
|
||||
target = fromRoot;
|
||||
}
|
||||
else if (!isDir(target)) {
|
||||
continue;
|
||||
}
|
||||
resolvers.push({
|
||||
requestToFile(publicPath) {
|
||||
if (publicPath.startsWith(key)) {
|
||||
return path_1.default.join(target, publicPath.slice(key.length));
|
||||
}
|
||||
},
|
||||
fileToRequest(filePath) {
|
||||
if (filePath.startsWith(target + pathSeparator)) {
|
||||
return slash_1.default(key + path_1.default.relative(target, filePath));
|
||||
}
|
||||
}
|
||||
});
|
||||
literalDirAlias[key] = target;
|
||||
}
|
||||
else {
|
||||
literalAlias[key] = target;
|
||||
}
|
||||
}
|
||||
};
|
||||
resolvers.forEach(({ alias }) => {
|
||||
if (alias && typeof alias === 'object') {
|
||||
resolveAlias(alias);
|
||||
}
|
||||
});
|
||||
resolveAlias(userAlias);
|
||||
const requestToFileCache = new Map();
|
||||
const fileToRequestCache = new Map();
|
||||
const resolver = {
|
||||
requestToFile(publicPath) {
|
||||
publicPath = decodeURIComponent(publicPath);
|
||||
if (requestToFileCache.has(publicPath)) {
|
||||
return requestToFileCache.get(publicPath);
|
||||
}
|
||||
let resolved;
|
||||
for (const r of resolvers) {
|
||||
const filepath = r.requestToFile && r.requestToFile(publicPath, root);
|
||||
if (filepath) {
|
||||
resolved = filepath;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!resolved) {
|
||||
resolved = defaultRequestToFile(publicPath, root);
|
||||
}
|
||||
const postfix = resolveFilePathPostfix(resolved);
|
||||
if (postfix) {
|
||||
if (postfix[0] === '/') {
|
||||
resolved = path_1.default.join(resolved, postfix);
|
||||
}
|
||||
else {
|
||||
resolved += postfix;
|
||||
}
|
||||
}
|
||||
requestToFileCache.set(publicPath, resolved);
|
||||
return resolved;
|
||||
},
|
||||
fileToRequest(filePath) {
|
||||
if (fileToRequestCache.has(filePath)) {
|
||||
return fileToRequestCache.get(filePath);
|
||||
}
|
||||
for (const r of resolvers) {
|
||||
const request = r.fileToRequest && r.fileToRequest(filePath, root);
|
||||
if (request)
|
||||
return request;
|
||||
}
|
||||
const res = defaultFileToRequest(filePath, root);
|
||||
fileToRequestCache.set(filePath, res);
|
||||
return res;
|
||||
},
|
||||
/**
|
||||
* Given a fuzzy public path, resolve missing extensions and /index.xxx
|
||||
*/
|
||||
normalizePublicPath(publicPath) {
|
||||
if (publicPath === serverPluginClient_1.clientPublicPath) {
|
||||
return publicPath;
|
||||
}
|
||||
// preserve query
|
||||
const queryMatch = publicPath.match(/\?.*$/);
|
||||
const query = queryMatch ? queryMatch[0] : '';
|
||||
const cleanPublicPath = utils_1.cleanUrl(publicPath);
|
||||
const finalize = (result) => {
|
||||
result += query;
|
||||
if (resolver.requestToFile(result) !== resolver.requestToFile(publicPath)) {
|
||||
throw new Error(`[vite] normalizePublicPath check fail. please report to vite.`);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
if (!serverPluginModuleResolve_1.moduleRE.test(cleanPublicPath)) {
|
||||
return finalize(resolver.fileToRequest(resolver.requestToFile(cleanPublicPath)));
|
||||
}
|
||||
const filePath = resolver.requestToFile(cleanPublicPath);
|
||||
const cacheDir = optimizer_1.resolveOptimizedCacheDir(root);
|
||||
if (cacheDir) {
|
||||
const relative = path_1.default.relative(cacheDir, filePath);
|
||||
if (!relative.startsWith('..')) {
|
||||
return finalize(path_1.default.posix.join('/@modules/', slash_1.default(relative)));
|
||||
}
|
||||
}
|
||||
// fileToRequest doesn't work with files in node_modules
|
||||
// because of edge cases like symlinks or yarn-aliased-install
|
||||
// or even aliased-symlinks
|
||||
// example id: "@babel/runtime/helpers/esm/slicedToArray"
|
||||
// see the test case: /playground/TestNormalizePublicPath.vue
|
||||
const id = cleanPublicPath.replace(serverPluginModuleResolve_1.moduleRE, '');
|
||||
const { scope, name, inPkgPath } = utils_1.parseNodeModuleId(id);
|
||||
if (!inPkgPath)
|
||||
return publicPath;
|
||||
let filePathPostFix = '';
|
||||
let findPkgFrom = filePath;
|
||||
while (!filePathPostFix.startsWith(inPkgPath)) {
|
||||
// some package contains multi package.json...
|
||||
// for example: @babel/runtime@7.10.2/helpers/esm/package.json
|
||||
const pkgPath = utils_1.lookupFile(findPkgFrom, ['package.json'], true);
|
||||
if (!pkgPath) {
|
||||
throw new Error(`[vite] can't find package.json for a node_module file: ` +
|
||||
`"${publicPath}". something is wrong.`);
|
||||
}
|
||||
filePathPostFix = slash_1.default(path_1.default.relative(path_1.default.dirname(pkgPath), filePath));
|
||||
findPkgFrom = path_1.default.join(path_1.default.dirname(pkgPath), '../');
|
||||
}
|
||||
return finalize(['/@modules', scope, name, filePathPostFix].filter(Boolean).join('/'));
|
||||
},
|
||||
alias(id) {
|
||||
let aliased = literalAlias[id];
|
||||
if (aliased) {
|
||||
return aliased;
|
||||
}
|
||||
for (const { alias } of resolvers) {
|
||||
aliased = alias && typeof alias === 'function' ? alias(id) : undefined;
|
||||
if (aliased) {
|
||||
return aliased;
|
||||
}
|
||||
}
|
||||
},
|
||||
resolveRelativeRequest(importer, importee) {
|
||||
const queryMatch = importee.match(utils_1.queryRE);
|
||||
let resolved = importee;
|
||||
if (importee.startsWith('.')) {
|
||||
resolved = path_1.default.posix.resolve(path_1.default.posix.dirname(importer), importee);
|
||||
for (const alias in literalDirAlias) {
|
||||
if (importer.startsWith(alias)) {
|
||||
if (!resolved.startsWith(alias)) {
|
||||
// resolved path is outside of alias directory, we need to use
|
||||
// its full path instead
|
||||
const importerFilePath = resolver.requestToFile(importer);
|
||||
const importeeFilePath = path_1.default.resolve(path_1.default.dirname(importerFilePath), importee);
|
||||
resolved = resolver.fileToRequest(importeeFilePath);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
pathname: utils_1.cleanUrl(resolved) +
|
||||
// path resolve strips ending / which should be preserved
|
||||
(importee.endsWith('/') && !resolved.endsWith('/') ? '/' : ''),
|
||||
query: queryMatch ? queryMatch[0] : ''
|
||||
};
|
||||
},
|
||||
isPublicRequest(publicPath) {
|
||||
return resolver
|
||||
.requestToFile(publicPath)
|
||||
.startsWith(path_1.default.resolve(root, 'public'));
|
||||
},
|
||||
isAssetRequest(filePath) {
|
||||
return ((assetsInclude && assetsInclude(filePath)) || pathUtils_1.isStaticAsset(filePath));
|
||||
}
|
||||
};
|
||||
return resolver;
|
||||
}
|
||||
exports.createResolver = createResolver;
|
||||
exports.jsSrcRE = /\.(?:(?:j|t)sx?|vue)$|\.mjs$/;
|
||||
const deepImportRE = /^([^@][^/]*)\/|^(@[^/]+\/[^/]+)\//;
|
||||
/**
|
||||
* Redirects a bare module request to a full path under /@modules/
|
||||
* It resolves a bare node module id to its full entry path so that relative
|
||||
* imports from the entry can be correctly resolved.
|
||||
* e.g.:
|
||||
* - `import 'foo'` -> `import '/@modules/foo/dist/index.js'`
|
||||
* - `import 'foo/bar/baz'` -> `import '/@modules/foo/bar/baz.js'`
|
||||
*/
|
||||
function resolveBareModuleRequest(root, id, importer, resolver) {
|
||||
const optimized = resolveOptimizedModule(root, id);
|
||||
if (optimized) {
|
||||
// ensure optimized module requests always ends with `.js` - this is because
|
||||
// optimized deps may import one another and in the built bundle their
|
||||
// relative import paths ends with `.js`. If we don't append `.js` during
|
||||
// rewrites, it may result in duplicated copies of the same dep.
|
||||
return path_1.default.extname(id) === '.js' ? id : id + '.js';
|
||||
}
|
||||
let isEntry = false;
|
||||
const basedir = path_1.default.dirname(resolver.requestToFile(importer));
|
||||
const pkgInfo = resolveNodeModule(basedir, id, resolver);
|
||||
if (pkgInfo) {
|
||||
if (!pkgInfo.entry) {
|
||||
console.error(chalk_1.default.yellow(`[vite] dependency ${id} does not have default entry defined in package.json.`));
|
||||
}
|
||||
else {
|
||||
isEntry = true;
|
||||
id = pkgInfo.entry;
|
||||
}
|
||||
}
|
||||
if (!isEntry) {
|
||||
const deepMatch = !isEntry && id.match(deepImportRE);
|
||||
if (deepMatch) {
|
||||
// deep import
|
||||
const depId = deepMatch[1] || deepMatch[2];
|
||||
// check if this is a deep import to an optimized dep.
|
||||
if (resolveOptimizedModule(root, depId)) {
|
||||
if (resolver.alias(depId) === id) {
|
||||
// this is a deep import but aliased from a bare module id.
|
||||
// redirect it the optimized copy.
|
||||
return resolveBareModuleRequest(root, depId, importer, resolver);
|
||||
}
|
||||
if (!cssUtils_1.isCSSRequest(id) && !resolver.isAssetRequest(id)) {
|
||||
// warn against deep imports to optimized dep
|
||||
console.error(chalk_1.default.yellow(`\n[vite] Avoid deep import "${id}" (imported by ${importer})\n` +
|
||||
`because "${depId}" has been pre-optimized by vite into a single file.\n` +
|
||||
`Prefer importing directly from the module entry:\n` +
|
||||
chalk_1.default.cyan(`\n import { ... } from "${depId}" \n\n`) +
|
||||
`If the dependency requires deep import to function properly, \n` +
|
||||
`add the deep path to ${chalk_1.default.cyan(`optimizeDeps.include`)} in vite.config.js.\n`));
|
||||
}
|
||||
}
|
||||
// resolve ext for deepImport
|
||||
const filePath = resolveNodeModuleFile(root, id);
|
||||
if (filePath) {
|
||||
const deepPath = id.replace(deepImportRE, '');
|
||||
const normalizedFilePath = slash_1.default(filePath);
|
||||
const postfix = normalizedFilePath.slice(normalizedFilePath.lastIndexOf(deepPath) + deepPath.length);
|
||||
id += postfix;
|
||||
}
|
||||
}
|
||||
}
|
||||
// check and warn deep imports on optimized modules
|
||||
const ext = path_1.default.extname(id);
|
||||
if (!exports.jsSrcRE.test(ext)) {
|
||||
// append import query for non-js deep imports
|
||||
return id + (utils_1.queryRE.test(id) ? '&import' : '?import');
|
||||
}
|
||||
else {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
exports.resolveBareModuleRequest = resolveBareModuleRequest;
|
||||
const viteOptimizedMap = new Map();
|
||||
function resolveOptimizedModule(root, id) {
|
||||
const cacheKey = `${root}#${id}`;
|
||||
const cached = viteOptimizedMap.get(cacheKey);
|
||||
if (cached) {
|
||||
return cached;
|
||||
}
|
||||
const cacheDir = optimizer_1.resolveOptimizedCacheDir(root);
|
||||
if (!cacheDir)
|
||||
return;
|
||||
const tryResolve = (file) => {
|
||||
file = path_1.default.join(cacheDir, file);
|
||||
if (fs_extra_1.default.existsSync(file) && fs_extra_1.default.statSync(file).isFile()) {
|
||||
viteOptimizedMap.set(cacheKey, file);
|
||||
return file;
|
||||
}
|
||||
};
|
||||
return tryResolve(id) || tryResolve(id + '.js');
|
||||
}
|
||||
exports.resolveOptimizedModule = resolveOptimizedModule;
|
||||
const nodeModulesInfoMap = new Map();
|
||||
const nodeModulesFileMap = new Map();
|
||||
function resolveNodeModule(root, id, resolver) {
|
||||
const cacheKey = `${root}#${id}`;
|
||||
const cached = nodeModulesInfoMap.get(cacheKey);
|
||||
if (cached) {
|
||||
return cached;
|
||||
}
|
||||
let pkgPath;
|
||||
try {
|
||||
// see if the id is a valid package name
|
||||
pkgPath = utils_1.resolveFrom(root, `${id}/package.json`);
|
||||
}
|
||||
catch (e) {
|
||||
debug(`failed to resolve package.json for ${id}`);
|
||||
}
|
||||
if (pkgPath) {
|
||||
// if yes, this is a entry import. resolve entry file
|
||||
let pkg;
|
||||
try {
|
||||
pkg = fs_extra_1.default.readJSONSync(pkgPath);
|
||||
}
|
||||
catch (e) {
|
||||
return;
|
||||
}
|
||||
let entryPoint;
|
||||
// TODO properly support conditional exports
|
||||
// https://nodejs.org/api/esm.html#esm_conditional_exports
|
||||
// Note: this would require @rollup/plugin-node-resolve to support it too
|
||||
// or we will have to implement that logic in vite's own resolve plugin.
|
||||
if (!entryPoint) {
|
||||
for (const field of exports.mainFields) {
|
||||
if (typeof pkg[field] === 'string') {
|
||||
entryPoint = pkg[field];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!entryPoint) {
|
||||
entryPoint = 'index.js';
|
||||
}
|
||||
// resolve object browser field in package.json
|
||||
// https://github.com/defunctzombie/package-browser-field-spec
|
||||
const { browser: browserField } = pkg;
|
||||
if (entryPoint && browserField && typeof browserField === 'object') {
|
||||
entryPoint = mapWithBrowserField(entryPoint, browserField);
|
||||
}
|
||||
debug(`(node_module entry) ${id} -> ${entryPoint}`);
|
||||
// save resolved entry file path using the deep import path as key
|
||||
// e.g. foo/dist/foo.js
|
||||
// this is the path raw imports will be rewritten to, and is what will
|
||||
// be passed to resolveNodeModuleFile().
|
||||
let entryFilePath;
|
||||
// respect user manual alias
|
||||
const aliased = resolver.alias(id);
|
||||
if (aliased && aliased !== id) {
|
||||
entryFilePath = resolveNodeModuleFile(root, aliased);
|
||||
}
|
||||
if (!entryFilePath && entryPoint) {
|
||||
// #284 some packages specify entry without extension...
|
||||
entryFilePath = path_1.default.join(path_1.default.dirname(pkgPath), entryPoint);
|
||||
const postfix = resolveFilePathPostfix(entryFilePath);
|
||||
if (postfix) {
|
||||
entryPoint += postfix;
|
||||
entryFilePath += postfix;
|
||||
}
|
||||
entryPoint = path_1.default.posix.join(id, entryPoint);
|
||||
// save the resolved file path now so we don't need to do it again in
|
||||
// resolveNodeModuleFile()
|
||||
nodeModulesFileMap.set(entryPoint, entryFilePath);
|
||||
}
|
||||
const result = {
|
||||
entry: entryPoint,
|
||||
entryFilePath,
|
||||
pkg
|
||||
};
|
||||
nodeModulesInfoMap.set(cacheKey, result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
exports.resolveNodeModule = resolveNodeModule;
|
||||
function resolveNodeModuleFile(root, id) {
|
||||
const cacheKey = `${root}#${id}`;
|
||||
const cached = nodeModulesFileMap.get(cacheKey);
|
||||
if (cached) {
|
||||
return cached;
|
||||
}
|
||||
try {
|
||||
const resolved = utils_1.resolveFrom(root, id);
|
||||
nodeModulesFileMap.set(cacheKey, resolved);
|
||||
return resolved;
|
||||
}
|
||||
catch (e) {
|
||||
// error will be reported downstream
|
||||
}
|
||||
}
|
||||
exports.resolveNodeModuleFile = resolveNodeModuleFile;
|
||||
const normalize = path_1.default.posix.normalize;
|
||||
/**
|
||||
* given a relative path in pkg dir,
|
||||
* return a relative path in pkg dir,
|
||||
* mapped with the "map" object
|
||||
*/
|
||||
function mapWithBrowserField(relativePathInPkgDir, map) {
|
||||
const normalized = normalize(relativePathInPkgDir);
|
||||
const foundEntry = Object.entries(map).find(([from]) => normalize(from) === normalized);
|
||||
if (!foundEntry) {
|
||||
return normalized;
|
||||
}
|
||||
const [, to] = foundEntry;
|
||||
return normalize(to);
|
||||
}
|
||||
//# sourceMappingURL=resolver.js.map
|
||||
1
node_modules/vite/dist/node/resolver.js.map
generated
vendored
1
node_modules/vite/dist/node/resolver.js.map
generated
vendored
File diff suppressed because one or more lines are too long
27
node_modules/vite/dist/node/server/index.d.ts
generated
vendored
27
node_modules/vite/dist/node/server/index.d.ts
generated
vendored
@@ -1,27 +0,0 @@
|
||||
/// <reference types="node" />
|
||||
import { Server } from 'http';
|
||||
import Koa, { DefaultState, DefaultContext } from 'koa';
|
||||
import { InternalResolver } from '../resolver';
|
||||
import { HMRWatcher } from './serverPluginHmr';
|
||||
import { ServerConfig } from '../config';
|
||||
export { rewriteImports } from './serverPluginModuleRewrite';
|
||||
import { SourceMap } from './serverPluginSourceMap';
|
||||
export declare type ServerPlugin = (ctx: ServerPluginContext) => void;
|
||||
export interface ServerPluginContext {
|
||||
root: string;
|
||||
app: Koa<State, Context>;
|
||||
server: Server;
|
||||
watcher: HMRWatcher;
|
||||
resolver: InternalResolver;
|
||||
config: ServerConfig & {
|
||||
__path?: string;
|
||||
};
|
||||
port: number;
|
||||
}
|
||||
export interface State extends DefaultState {
|
||||
}
|
||||
export declare type Context = DefaultContext & ServerPluginContext & {
|
||||
read: (filePath: string) => Promise<Buffer | string>;
|
||||
map?: SourceMap | null;
|
||||
};
|
||||
export declare function createServer(config: ServerConfig): Server;
|
||||
149
node_modules/vite/dist/node/server/index.js
generated
vendored
149
node_modules/vite/dist/node/server/index.js
generated
vendored
@@ -1,149 +0,0 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createServer = exports.rewriteImports = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const koa_1 = __importDefault(require("koa"));
|
||||
const chokidar_1 = __importDefault(require("chokidar"));
|
||||
const resolver_1 = require("../resolver");
|
||||
const serverPluginModuleRewrite_1 = require("./serverPluginModuleRewrite");
|
||||
const serverPluginModuleResolve_1 = require("./serverPluginModuleResolve");
|
||||
const serverPluginVue_1 = require("./serverPluginVue");
|
||||
const serverPluginHmr_1 = require("./serverPluginHmr");
|
||||
const serverPluginServeStatic_1 = require("./serverPluginServeStatic");
|
||||
const serverPluginJson_1 = require("./serverPluginJson");
|
||||
const serverPluginCss_1 = require("./serverPluginCss");
|
||||
const serverPluginAssets_1 = require("./serverPluginAssets");
|
||||
const serverPluginEsbuild_1 = require("./serverPluginEsbuild");
|
||||
const transform_1 = require("../transform");
|
||||
const serverPluginHtml_1 = require("./serverPluginHtml");
|
||||
const serverPluginProxy_1 = require("./serverPluginProxy");
|
||||
const createCertificate_1 = require("../utils/createCertificate");
|
||||
const utils_1 = require("../utils");
|
||||
const serverPluginEnv_1 = require("./serverPluginEnv");
|
||||
var serverPluginModuleRewrite_2 = require("./serverPluginModuleRewrite");
|
||||
Object.defineProperty(exports, "rewriteImports", { enumerable: true, get: function () { return serverPluginModuleRewrite_2.rewriteImports; } });
|
||||
const serverPluginSourceMap_1 = require("./serverPluginSourceMap");
|
||||
const serverPluginWebWorker_1 = require("./serverPluginWebWorker");
|
||||
const serverPluginWasm_1 = require("./serverPluginWasm");
|
||||
const serverPluginClient_1 = require("./serverPluginClient");
|
||||
function createServer(config) {
|
||||
const { root = process.cwd(), configureServer = [], resolvers = [], alias = {}, transforms = [], vueCustomBlockTransforms = {}, optimizeDeps = {}, enableEsbuild = true, assetsInclude } = config;
|
||||
const app = new koa_1.default();
|
||||
const server = resolveServer(config, app.callback());
|
||||
const watcher = chokidar_1.default.watch(root, {
|
||||
ignored: [/node_modules/, /\.git/],
|
||||
// #610
|
||||
awaitWriteFinish: {
|
||||
stabilityThreshold: 100,
|
||||
pollInterval: 10
|
||||
}
|
||||
});
|
||||
const resolver = resolver_1.createResolver(root, resolvers, alias, assetsInclude);
|
||||
const context = {
|
||||
root,
|
||||
app,
|
||||
server,
|
||||
watcher,
|
||||
resolver,
|
||||
config,
|
||||
// port is exposed on the context for hmr client connection
|
||||
// in case the files are served under a different port
|
||||
port: config.port || 3000
|
||||
};
|
||||
// attach server context to koa context
|
||||
app.use((ctx, next) => {
|
||||
Object.assign(ctx, context);
|
||||
ctx.read = utils_1.cachedRead.bind(null, ctx);
|
||||
return next();
|
||||
});
|
||||
// cors
|
||||
if (config.cors) {
|
||||
app.use(require('@koa/cors')(typeof config.cors === 'boolean' ? {} : config.cors));
|
||||
}
|
||||
const resolvedPlugins = [
|
||||
// rewrite and source map plugins take highest priority and should be run
|
||||
// after all other middlewares have finished
|
||||
serverPluginSourceMap_1.sourceMapPlugin,
|
||||
serverPluginModuleRewrite_1.moduleRewritePlugin,
|
||||
serverPluginHtml_1.htmlRewritePlugin,
|
||||
// user plugins
|
||||
...utils_1.toArray(configureServer),
|
||||
serverPluginEnv_1.envPlugin,
|
||||
serverPluginModuleResolve_1.moduleResolvePlugin,
|
||||
serverPluginProxy_1.proxyPlugin,
|
||||
serverPluginClient_1.clientPlugin,
|
||||
serverPluginHmr_1.hmrPlugin,
|
||||
...(transforms.length || Object.keys(vueCustomBlockTransforms).length
|
||||
? [
|
||||
transform_1.createServerTransformPlugin(transforms, vueCustomBlockTransforms, resolver)
|
||||
]
|
||||
: []),
|
||||
serverPluginVue_1.vuePlugin,
|
||||
serverPluginCss_1.cssPlugin,
|
||||
enableEsbuild ? serverPluginEsbuild_1.esbuildPlugin : null,
|
||||
serverPluginJson_1.jsonPlugin,
|
||||
serverPluginAssets_1.assetPathPlugin,
|
||||
serverPluginWebWorker_1.webWorkerPlugin,
|
||||
serverPluginWasm_1.wasmPlugin,
|
||||
serverPluginServeStatic_1.serveStaticPlugin
|
||||
];
|
||||
resolvedPlugins.forEach((m) => m && m(context));
|
||||
const listen = server.listen.bind(server);
|
||||
server.listen = (async (port, ...args) => {
|
||||
if (optimizeDeps.auto !== false) {
|
||||
await require('../optimizer').optimizeDeps(config);
|
||||
}
|
||||
return listen(port, ...args);
|
||||
});
|
||||
server.once('listening', () => {
|
||||
context.port = server.address().port;
|
||||
});
|
||||
return server;
|
||||
}
|
||||
exports.createServer = createServer;
|
||||
function resolveServer({ https = false, httpsOptions = {}, proxy }, requestListener) {
|
||||
if (https) {
|
||||
if (proxy) {
|
||||
// #484 fallback to http1 when proxy is needed.
|
||||
return require('https').createServer(resolveHttpsConfig(httpsOptions), requestListener);
|
||||
}
|
||||
else {
|
||||
return require('http2').createSecureServer({
|
||||
...resolveHttpsConfig(httpsOptions),
|
||||
allowHTTP1: true
|
||||
}, requestListener);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return require('http').createServer(requestListener);
|
||||
}
|
||||
}
|
||||
function resolveHttpsConfig(httpsOption) {
|
||||
const { ca, cert, key, pfx } = httpsOption;
|
||||
Object.assign(httpsOption, {
|
||||
ca: readFileIfExists(ca),
|
||||
cert: readFileIfExists(cert),
|
||||
key: readFileIfExists(key),
|
||||
pfx: readFileIfExists(pfx)
|
||||
});
|
||||
if (!httpsOption.key || !httpsOption.cert) {
|
||||
httpsOption.cert = httpsOption.key = createCertificate_1.createCertificate();
|
||||
}
|
||||
return httpsOption;
|
||||
}
|
||||
function readFileIfExists(value) {
|
||||
if (value && !Buffer.isBuffer(value)) {
|
||||
try {
|
||||
return fs_extra_1.default.readFileSync(path_1.default.resolve(value));
|
||||
}
|
||||
catch (e) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/vite/dist/node/server/index.js.map
generated
vendored
1
node_modules/vite/dist/node/server/index.js.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/server/index.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AACvB,wDAAyB;AAGzB,8CAAuD;AACvD,wDAA+B;AAC/B,0CAA8D;AAC9D,2EAAiE;AACjE,2EAAiE;AACjE,uDAA6C;AAC7C,uDAAyD;AACzD,uEAA6D;AAC7D,yDAA+C;AAC/C,uDAA6C;AAC7C,6DAAsD;AACtD,+DAAqD;AAErD,4CAA0D;AAC1D,yDAAsD;AACtD,2DAAiD;AACjD,kEAA8D;AAC9D,oCAA8C;AAC9C,uDAA6C;AAC7C,yEAA4D;AAAnD,2HAAA,cAAc,OAAA;AACvB,mEAAoE;AACpE,mEAAyD;AACzD,yDAA+C;AAC/C,6DAAmD;AAuBnD,SAAgB,YAAY,CAAC,MAAoB;IAC/C,MAAM,EACJ,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,EACpB,eAAe,GAAG,EAAE,EACpB,SAAS,GAAG,EAAE,EACd,KAAK,GAAG,EAAE,EACV,UAAU,GAAG,EAAE,EACf,wBAAwB,GAAG,EAAE,EAC7B,YAAY,GAAG,EAAE,EACjB,aAAa,GAAG,IAAI,EACpB,aAAa,EACd,GAAG,MAAM,CAAA;IAEV,MAAM,GAAG,GAAG,IAAI,aAAG,EAAk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O,KAAK,CAAA;AACd,CAAC"}
|
||||
2
node_modules/vite/dist/node/server/serverPluginAssets.d.ts
generated
vendored
2
node_modules/vite/dist/node/server/serverPluginAssets.d.ts
generated
vendored
@@ -1,2 +0,0 @@
|
||||
import { ServerPlugin } from '.';
|
||||
export declare const assetPathPlugin: ServerPlugin;
|
||||
15
node_modules/vite/dist/node/server/serverPluginAssets.js
generated
vendored
15
node_modules/vite/dist/node/server/serverPluginAssets.js
generated
vendored
@@ -1,15 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.assetPathPlugin = void 0;
|
||||
const utils_1 = require("../utils");
|
||||
exports.assetPathPlugin = ({ app, resolver }) => {
|
||||
app.use(async (ctx, next) => {
|
||||
if (resolver.isAssetRequest(ctx.path) && utils_1.isImportRequest(ctx)) {
|
||||
ctx.type = 'js';
|
||||
ctx.body = `export default ${JSON.stringify(ctx.path)}`;
|
||||
return;
|
||||
}
|
||||
return next();
|
||||
});
|
||||
};
|
||||
//# sourceMappingURL=serverPluginAssets.js.map
|
||||
1
node_modules/vite/dist/node/server/serverPluginAssets.js.map
generated
vendored
1
node_modules/vite/dist/node/server/serverPluginAssets.js.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"serverPluginAssets.js","sourceRoot":"","sources":["../../../src/node/server/serverPluginAssets.ts"],"names":[],"mappings":";;;AACA,oCAA0C;AAE7B,QAAA,eAAe,GAAiB,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE;IACjE,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QAC1B,IAAI,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,uBAAe,CAAC,GAAG,CAAC,EAAE;YAC7D,GAAG,CAAC,IAAI,GAAG,IAAI,CAAA;YACf,GAAG,CAAC,IAAI,GAAG,kBAAkB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAA;YACvD,OAAM;SACP;QACD,OAAO,IAAI,EAAE,CAAA;IACf,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
||||
4
node_modules/vite/dist/node/server/serverPluginClient.d.ts
generated
vendored
4
node_modules/vite/dist/node/server/serverPluginClient.d.ts
generated
vendored
@@ -1,4 +0,0 @@
|
||||
import { ServerPlugin } from '.';
|
||||
export declare const clientFilePath: string;
|
||||
export declare const clientPublicPath = "/vite/client";
|
||||
export declare const clientPlugin: ServerPlugin;
|
||||
53
node_modules/vite/dist/node/server/serverPluginClient.js
generated
vendored
53
node_modules/vite/dist/node/server/serverPluginClient.js
generated
vendored
@@ -1,53 +0,0 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.clientPlugin = exports.clientPublicPath = exports.clientFilePath = void 0;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const chalk_1 = __importDefault(require("chalk"));
|
||||
const config_1 = require("../config");
|
||||
exports.clientFilePath = path_1.default.resolve(__dirname, '../../client/client.js');
|
||||
exports.clientPublicPath = `/vite/client`;
|
||||
const legacyPublicPath = '/vite/hmr';
|
||||
exports.clientPlugin = ({ app, config }) => {
|
||||
const clientCode = fs_1.default
|
||||
.readFileSync(exports.clientFilePath, 'utf-8')
|
||||
.replace(`__MODE__`, JSON.stringify(config.mode || 'development'))
|
||||
.replace(`__DEFINES__`, JSON.stringify({
|
||||
...config_1.defaultDefines,
|
||||
...config.define
|
||||
}));
|
||||
app.use(async (ctx, next) => {
|
||||
if (ctx.path === exports.clientPublicPath) {
|
||||
let socketPort = ctx.port;
|
||||
// infer on client by default
|
||||
let socketProtocol = null;
|
||||
let socketHostname = null;
|
||||
if (config.hmr && typeof config.hmr === 'object') {
|
||||
// hmr option has highest priory
|
||||
socketProtocol = config.hmr.protocol || null;
|
||||
socketHostname = config.hmr.hostname || null;
|
||||
socketPort = config.hmr.port || ctx.port;
|
||||
if (config.hmr.path) {
|
||||
socketPort = `${socketPort}/${config.hmr.path}`;
|
||||
}
|
||||
}
|
||||
ctx.type = 'js';
|
||||
ctx.status = 200;
|
||||
ctx.body = clientCode
|
||||
.replace(`__HMR_PROTOCOL__`, JSON.stringify(socketProtocol))
|
||||
.replace(`__HMR_HOSTNAME__`, JSON.stringify(socketHostname))
|
||||
.replace(`__HMR_PORT__`, JSON.stringify(socketPort));
|
||||
}
|
||||
else {
|
||||
if (ctx.path === legacyPublicPath) {
|
||||
console.error(chalk_1.default.red(`[vite] client import path has changed from "/vite/hmr" to "/vite/client". ` +
|
||||
`please update your code accordingly.`));
|
||||
}
|
||||
return next();
|
||||
}
|
||||
});
|
||||
};
|
||||
//# sourceMappingURL=serverPluginClient.js.map
|
||||
1
node_modules/vite/dist/node/server/serverPluginClient.js.map
generated
vendored
1
node_modules/vite/dist/node/server/serverPluginClient.js.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"serverPluginClient.js","sourceRoot":"","sources":["../../../src/node/server/serverPluginClient.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAmB;AACnB,gDAAuB;AACvB,kDAAyB;AAEzB,sCAA0C;AAE7B,QAAA,cAAc,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,wBAAwB,CAAC,CAAA;AAElE,QAAA,gBAAgB,GAAG,cAAc,CAAA;AAE9C,MAAM,gBAAgB,GAAG,WAAW,CAAA;AAEvB,QAAA,YAAY,GAAiB,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE;IAC5D,MAAM,UAAU,GAAG,YAAE;SAClB,YAAY,CAAC,sBAAc,EAAE,OAAO,CAAC;SACrC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,IAAI,aAAa,C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AAC,IAAI,KAAK,gBAAgB,EAAE;gBACjC,OAAO,CAAC,KAAK,CACX,eAAK,CAAC,GAAG,CACP,4EAA4E;oBAC1E,sCAAsC,CACzC,CACF,CAAA;aACF;YACD,OAAO,IAAI,EAAE,CAAA;SACd;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
||||
4
node_modules/vite/dist/node/server/serverPluginCss.d.ts
generated
vendored
4
node_modules/vite/dist/node/server/serverPluginCss.d.ts
generated
vendored
@@ -1,4 +0,0 @@
|
||||
import { ServerPlugin } from '.';
|
||||
export declare const debugCSS: any;
|
||||
export declare const cssPlugin: ServerPlugin;
|
||||
export declare function codegenCss(id: string, css: string, modules?: Record<string, string>): string;
|
||||
165
node_modules/vite/dist/node/server/serverPluginCss.js
generated
vendored
165
node_modules/vite/dist/node/server/serverPluginCss.js
generated
vendored
@@ -1,165 +0,0 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.codegenCss = exports.cssPlugin = exports.debugCSS = void 0;
|
||||
const path_1 = require("path");
|
||||
const hash_sum_1 = __importDefault(require("hash-sum"));
|
||||
const utils_1 = require("../utils");
|
||||
const serverPluginVue_1 = require("./serverPluginVue");
|
||||
const cssUtils_1 = require("../utils/cssUtils");
|
||||
const querystring_1 = __importDefault(require("querystring"));
|
||||
const chalk_1 = __importDefault(require("chalk"));
|
||||
const serverPluginClient_1 = require("./serverPluginClient");
|
||||
const pluginutils_1 = require("@rollup/pluginutils");
|
||||
exports.debugCSS = require('debug')('vite:css');
|
||||
exports.cssPlugin = ({ root, app, watcher, resolver }) => {
|
||||
app.use(async (ctx, next) => {
|
||||
await next();
|
||||
// handle .css imports
|
||||
if (cssUtils_1.isCSSRequest(ctx.path) &&
|
||||
// note ctx.body could be null if upstream set status to 304
|
||||
ctx.body) {
|
||||
const id = JSON.stringify(hash_sum_1.default(ctx.path));
|
||||
if (utils_1.isImportRequest(ctx)) {
|
||||
const { css, modules } = await processCss(root, ctx);
|
||||
ctx.type = 'js';
|
||||
// we rewrite css with `?import` to a js module that inserts a style
|
||||
// tag linking to the actual raw url
|
||||
ctx.body = codegenCss(id, css, modules);
|
||||
}
|
||||
}
|
||||
});
|
||||
watcher.on('change', (filePath) => {
|
||||
if (cssUtils_1.isCSSRequest(filePath)) {
|
||||
const publicPath = resolver.fileToRequest(filePath);
|
||||
/** filter unused files */
|
||||
if (!cssUtils_1.cssImporterMap.has(filePath) &&
|
||||
!processedCSS.has(publicPath) &&
|
||||
!serverPluginVue_1.srcImportMap.has(filePath)) {
|
||||
return exports.debugCSS(`${path_1.basename(publicPath)} has changed, but it is not currently in use`);
|
||||
}
|
||||
if (serverPluginVue_1.srcImportMap.has(filePath)) {
|
||||
// handle HMR for <style src="xxx.css">
|
||||
// it cannot be handled as simple css import because it may be scoped
|
||||
const styleImport = serverPluginVue_1.srcImportMap.get(filePath);
|
||||
serverPluginVue_1.vueCache.del(filePath);
|
||||
vueStyleUpdate(styleImport);
|
||||
return;
|
||||
}
|
||||
// handle HMR for module css
|
||||
// it cannot be handled as normal css because the js exports may change
|
||||
if (filePath.includes('.module')) {
|
||||
moduleCssUpdate(filePath, resolver);
|
||||
}
|
||||
const boundaries = cssUtils_1.getCssImportBoundaries(filePath);
|
||||
if (boundaries.size) {
|
||||
boundaryCssUpdate(boundaries);
|
||||
return;
|
||||
}
|
||||
// no boundaries
|
||||
normalCssUpdate(publicPath);
|
||||
}
|
||||
else if (cssUtils_1.cssImporterMap.has(filePath)) {
|
||||
const boundaries = cssUtils_1.getCssImportBoundaries(filePath);
|
||||
if (boundaries.size) {
|
||||
boundaryCssUpdate(boundaries);
|
||||
}
|
||||
}
|
||||
});
|
||||
function boundaryCssUpdate(boundaries) {
|
||||
for (let boundary of boundaries) {
|
||||
if (boundary.includes('.module')) {
|
||||
moduleCssUpdate(boundary, resolver);
|
||||
}
|
||||
else if (boundary.includes('.vue')) {
|
||||
serverPluginVue_1.vueCache.del(utils_1.cleanUrl(boundary));
|
||||
vueStyleUpdate(resolver.fileToRequest(boundary));
|
||||
}
|
||||
else {
|
||||
normalCssUpdate(resolver.fileToRequest(boundary));
|
||||
}
|
||||
}
|
||||
}
|
||||
function vueStyleUpdate(styleImport) {
|
||||
const publicPath = utils_1.cleanUrl(styleImport);
|
||||
const index = querystring_1.default.parse(styleImport.split('?', 2)[1]).index;
|
||||
const path = `${publicPath}?type=style&index=${index}`;
|
||||
console.log(chalk_1.default.green(`[vite:hmr] `) + `${publicPath} updated. (style)`);
|
||||
watcher.send({
|
||||
type: 'style-update',
|
||||
path,
|
||||
changeSrcPath: path,
|
||||
timestamp: Date.now()
|
||||
});
|
||||
}
|
||||
function moduleCssUpdate(filePath, resolver) {
|
||||
// bust process cache
|
||||
processedCSS.delete(resolver.fileToRequest(filePath));
|
||||
watcher.handleJSReload(filePath);
|
||||
}
|
||||
function normalCssUpdate(publicPath) {
|
||||
// bust process cache
|
||||
processedCSS.delete(publicPath);
|
||||
watcher.send({
|
||||
type: 'style-update',
|
||||
path: publicPath,
|
||||
changeSrcPath: publicPath,
|
||||
timestamp: Date.now()
|
||||
});
|
||||
}
|
||||
// processed CSS is cached in case the user ticks "disable cache" during dev
|
||||
// which can lead to unnecessary processing on page reload
|
||||
const processedCSS = new Map();
|
||||
async function processCss(root, ctx) {
|
||||
// source didn't change (marker added by cachedRead)
|
||||
// just use previously cached result
|
||||
if (ctx.__notModified && processedCSS.has(ctx.path)) {
|
||||
return processedCSS.get(ctx.path);
|
||||
}
|
||||
const css = (await utils_1.readBody(ctx.body));
|
||||
const filePath = resolver.requestToFile(ctx.path);
|
||||
const preprocessLang = (ctx.path.match(cssUtils_1.cssPreprocessLangRE) || [])[1];
|
||||
const result = await cssUtils_1.compileCss(root, ctx.path, {
|
||||
id: '',
|
||||
source: css,
|
||||
filename: filePath,
|
||||
scoped: false,
|
||||
modules: ctx.path.includes('.module'),
|
||||
preprocessLang,
|
||||
preprocessOptions: ctx.config.cssPreprocessOptions,
|
||||
modulesOptions: ctx.config.cssModuleOptions
|
||||
});
|
||||
if (typeof result === 'string') {
|
||||
const res = { css: await cssUtils_1.rewriteCssUrls(css, ctx.path) };
|
||||
processedCSS.set(ctx.path, res);
|
||||
return res;
|
||||
}
|
||||
cssUtils_1.recordCssImportChain(result.dependencies, filePath);
|
||||
if (result.errors.length) {
|
||||
console.error(`[vite] error applying css transforms: `);
|
||||
result.errors.forEach(console.error);
|
||||
}
|
||||
const res = {
|
||||
css: await cssUtils_1.rewriteCssUrls(result.code, ctx.path),
|
||||
modules: result.modules
|
||||
};
|
||||
processedCSS.set(ctx.path, res);
|
||||
return res;
|
||||
}
|
||||
};
|
||||
function codegenCss(id, css, modules) {
|
||||
let code = `import { updateStyle } from "${serverPluginClient_1.clientPublicPath}"\n` +
|
||||
`const css = ${JSON.stringify(css)}\n` +
|
||||
`updateStyle(${JSON.stringify(id)}, css)\n`;
|
||||
if (modules) {
|
||||
code += pluginutils_1.dataToEsm(modules, { namedExports: true });
|
||||
}
|
||||
else {
|
||||
code += `export default css`;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
exports.codegenCss = codegenCss;
|
||||
//# sourceMappingURL=serverPluginCss.js.map
|
||||
1
node_modules/vite/dist/node/server/serverPluginCss.js.map
generated
vendored
1
node_modules/vite/dist/node/server/serverPluginCss.js.map
generated
vendored
File diff suppressed because one or more lines are too long
3
node_modules/vite/dist/node/server/serverPluginEnv.d.ts
generated
vendored
3
node_modules/vite/dist/node/server/serverPluginEnv.d.ts
generated
vendored
@@ -1,3 +0,0 @@
|
||||
import { ServerPlugin } from '.';
|
||||
export declare const envPublicPath = "/vite/env";
|
||||
export declare const envPlugin: ServerPlugin;
|
||||
27
node_modules/vite/dist/node/server/serverPluginEnv.js
generated
vendored
27
node_modules/vite/dist/node/server/serverPluginEnv.js
generated
vendored
@@ -1,27 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.envPlugin = exports.envPublicPath = void 0;
|
||||
exports.envPublicPath = '/vite/env';
|
||||
exports.envPlugin = ({ app, config }) => {
|
||||
// configMode = mode of the .env{.mode} file that was loaded
|
||||
const configMode = config.mode || 'development';
|
||||
// resolvedMode = potentially overwritten by NODE_ENV inside the .env
|
||||
// (which is set as VITE_ENV to avoid system default NODE_ENV)
|
||||
const resolvedMode = process.env.VITE_ENV || configMode;
|
||||
const env = JSON.stringify({
|
||||
...config.env,
|
||||
BASE_URL: '/',
|
||||
MODE: configMode,
|
||||
DEV: resolvedMode !== 'production',
|
||||
PROD: resolvedMode === 'production'
|
||||
});
|
||||
app.use((ctx, next) => {
|
||||
if (ctx.path === exports.envPublicPath) {
|
||||
ctx.type = 'js';
|
||||
ctx.body = `export default ${env}`;
|
||||
return;
|
||||
}
|
||||
return next();
|
||||
});
|
||||
};
|
||||
//# sourceMappingURL=serverPluginEnv.js.map
|
||||
1
node_modules/vite/dist/node/server/serverPluginEnv.js.map
generated
vendored
1
node_modules/vite/dist/node/server/serverPluginEnv.js.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"serverPluginEnv.js","sourceRoot":"","sources":["../../../src/node/server/serverPluginEnv.ts"],"names":[],"mappings":";;;AAEa,QAAA,aAAa,GAAG,WAAW,CAAA;AAE3B,QAAA,SAAS,GAAiB,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE;IACzD,4DAA4D;IAC5D,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,IAAI,aAAa,CAAA;IAC/C,qEAAqE;IACrE,8DAA8D;IAC9D,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,UAAU,CAAA;IACvD,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC;QACzB,GAAG,MAAM,CAAC,GAAG;QACb,QAAQ,EAAE,GAAG;QACb,IAAI,EAAE,UAAU;QAChB,GAAG,EAAE,YAAY,KAAK,YAAY;QAClC,IAAI,EAAE,YAAY,KAAK,YAAY;KACpC,CAAC,CAAA;IAEF,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;QACpB,IAAI,GAAG,CAAC,IAAI,KAAK,qBAAa,EAAE;YAC9B,GAAG,CAAC,IAAI,GAAG,IAAI,CAAA;YACf,GAAG,CAAC,IAAI,GAAG,kBAAkB,GAAG,EAAE,CAAA;YAClC,OAAM;SACP;QACD,OAAO,IAAI,EAAE,CAAA;IACf,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
||||
2
node_modules/vite/dist/node/server/serverPluginEsbuild.d.ts
generated
vendored
2
node_modules/vite/dist/node/server/serverPluginEsbuild.d.ts
generated
vendored
@@ -1,2 +0,0 @@
|
||||
import { ServerPlugin } from '.';
|
||||
export declare const esbuildPlugin: ServerPlugin;
|
||||
29
node_modules/vite/dist/node/server/serverPluginEsbuild.js
generated
vendored
29
node_modules/vite/dist/node/server/serverPluginEsbuild.js
generated
vendored
@@ -1,29 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.esbuildPlugin = void 0;
|
||||
const esbuildService_1 = require("../esbuildService");
|
||||
const utils_1 = require("../utils");
|
||||
exports.esbuildPlugin = ({ app, config, resolver }) => {
|
||||
const jsxConfig = esbuildService_1.resolveJsxOptions(config.jsx);
|
||||
app.use(async (ctx, next) => {
|
||||
// intercept and return vue jsx helper import
|
||||
if (ctx.path === esbuildService_1.vueJsxPublicPath) {
|
||||
await ctx.read(esbuildService_1.vueJsxFilePath);
|
||||
}
|
||||
await next();
|
||||
if (!esbuildService_1.tjsxRE.test(ctx.path) ||
|
||||
!ctx.body ||
|
||||
ctx.type === 'text/html' ||
|
||||
resolver.isPublicRequest(ctx.path)) {
|
||||
return;
|
||||
}
|
||||
ctx.type = 'js';
|
||||
const src = await utils_1.readBody(ctx.body);
|
||||
const { code, map } = await esbuildService_1.transform(src, resolver.requestToFile(utils_1.cleanUrl(ctx.url)), jsxConfig, config.jsx);
|
||||
ctx.body = code;
|
||||
if (map) {
|
||||
ctx.map = JSON.parse(map);
|
||||
}
|
||||
});
|
||||
};
|
||||
//# sourceMappingURL=serverPluginEsbuild.js.map
|
||||
1
node_modules/vite/dist/node/server/serverPluginEsbuild.js.map
generated
vendored
1
node_modules/vite/dist/node/server/serverPluginEsbuild.js.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"serverPluginEsbuild.js","sourceRoot":"","sources":["../../../src/node/server/serverPluginEsbuild.ts"],"names":[],"mappings":";;;AACA,sDAM0B;AAC1B,oCAA6C;AAEhC,QAAA,aAAa,GAAiB,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE;IACvE,MAAM,SAAS,GAAG,kCAAiB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IAE/C,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QAC1B,6CAA6C;QAC7C,IAAI,GAAG,CAAC,IAAI,KAAK,iCAAgB,EAAE;YACjC,MAAM,GAAG,CAAC,IAAI,CAAC,+BAAc,CAAC,CAAA;SAC/B;QAED,MAAM,IAAI,EAAE,CAAA;QAEZ,IACE,CAAC,uBAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;YACtB,CAAC,GAAG,CAAC,IAAI;YACT,GAAG,CAAC,IAAI,KAAK,WAAW;YACxB,QAAQ,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,EAClC;YACA,OAAM;SACP;QAED,GAAG,CAAC,IAAI,GAAG,IAAI,CAAA;QACf,MAAM,GAAG,GAAG,MAAM,gBAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACpC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,0BAAS,CACnC,GAAI,EACJ,QAAQ,CAAC,aAAa,CAAC,gBAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EACzC,SAAS,EACT,MAAM,CAAC,GAAG,CACX,CAAA;QACD,GAAG,CAAC,IAAI,GAAG,IAAI,CAAA;QACf,IAAI,GAAG,EAAE;YACP,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;SAC1B;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
||||
23
node_modules/vite/dist/node/server/serverPluginHmr.d.ts
generated
vendored
23
node_modules/vite/dist/node/server/serverPluginHmr.d.ts
generated
vendored
@@ -1,23 +0,0 @@
|
||||
import { ServerPlugin } from '.';
|
||||
import { FSWatcher } from 'chokidar';
|
||||
import MagicString from 'magic-string';
|
||||
import { InternalResolver } from '../resolver';
|
||||
import LRUCache from 'lru-cache';
|
||||
import { HMRPayload } from '../../hmrPayload';
|
||||
export declare const debugHmr: any;
|
||||
export declare type HMRWatcher = FSWatcher & {
|
||||
handleVueReload: (filePath: string, timestamp?: number, content?: string) => void;
|
||||
handleJSReload: (filePath: string, timestamp?: number) => void;
|
||||
send: (payload: HMRPayload) => void;
|
||||
};
|
||||
declare type HMRStateMap = Map<string, Set<string>>;
|
||||
export declare const hmrAcceptanceMap: HMRStateMap;
|
||||
export declare const hmrDeclineSet: Set<string>;
|
||||
export declare const importerMap: HMRStateMap;
|
||||
export declare const importeeMap: HMRStateMap;
|
||||
export declare const hmrDirtyFilesMap: LRUCache<string, Set<string>>;
|
||||
export declare const latestVersionsMap: Map<string, string>;
|
||||
export declare const hmrPlugin: ServerPlugin;
|
||||
export declare function ensureMapEntry(map: HMRStateMap, key: string): Set<string>;
|
||||
export declare function rewriteFileWithHMR(root: string, source: string, importer: string, resolver: InternalResolver, s: MagicString): void;
|
||||
export {};
|
||||
296
node_modules/vite/dist/node/server/serverPluginHmr.js
generated
vendored
296
node_modules/vite/dist/node/server/serverPluginHmr.js
generated
vendored
@@ -1,296 +0,0 @@
|
||||
"use strict";
|
||||
// How HMR works
|
||||
// 1. `.vue` files are transformed into `.js` files before being served
|
||||
// 2. All `.js` files, before being served, are parsed to detect their imports
|
||||
// (this is done in `./serverPluginModuleRewrite.ts`) for module import rewriting.
|
||||
// During this we also record the importer/importee relationships which can be used for
|
||||
// HMR analysis (we do both at the same time to avoid double parse costs)
|
||||
// 3. When a file changes, it triggers an HMR graph analysis, where we try to
|
||||
// walk its importer chains and see if we reach a "HMR boundary". An HMR
|
||||
// boundary is a file that explicitly indicated that it accepts hot updates
|
||||
// (by calling `import.meta.hot` APIs)
|
||||
// 4. If any parent chain exhausts without ever running into an HMR boundary,
|
||||
// it's considered a "dead end". This causes a full page reload.
|
||||
// 5. If a boundary is encountered, we check if the boundary's current
|
||||
// child importer is in the accepted list of the boundary (recorded while
|
||||
// parsing the file for HRM rewrite). If yes, record current child importer
|
||||
// in the `hmrBoundaries` Set.
|
||||
// 6. If the graph walk finished without running into dead ends, send the
|
||||
// client to update all `hmrBoundaries`.
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.rewriteFileWithHMR = exports.ensureMapEntry = exports.hmrPlugin = exports.latestVersionsMap = exports.hmrDirtyFilesMap = exports.importeeMap = exports.importerMap = exports.hmrDeclineSet = exports.hmrAcceptanceMap = exports.debugHmr = void 0;
|
||||
const ws_1 = __importDefault(require("ws"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const chalk_1 = __importDefault(require("chalk"));
|
||||
const serverPluginVue_1 = require("./serverPluginVue");
|
||||
const serverPluginModuleRewrite_1 = require("./serverPluginModuleRewrite");
|
||||
const babelParse_1 = require("../utils/babelParse");
|
||||
const lru_cache_1 = __importDefault(require("lru-cache"));
|
||||
const slash_1 = __importDefault(require("slash"));
|
||||
const cssUtils_1 = require("../utils/cssUtils");
|
||||
const utils_1 = require("../utils");
|
||||
const serverPluginClient_1 = require("./serverPluginClient");
|
||||
exports.debugHmr = require('debug')('vite:hmr');
|
||||
exports.hmrAcceptanceMap = new Map();
|
||||
exports.hmrDeclineSet = new Set();
|
||||
exports.importerMap = new Map();
|
||||
exports.importeeMap = new Map();
|
||||
// files that are dirty (i.e. in the import chain between the accept boundary
|
||||
// and the actual changed file) for an hmr update at a given timestamp.
|
||||
exports.hmrDirtyFilesMap = new lru_cache_1.default({ max: 10 });
|
||||
exports.latestVersionsMap = new Map();
|
||||
exports.hmrPlugin = ({ root, app, server, watcher, resolver, config }) => {
|
||||
app.use((ctx, next) => {
|
||||
if (ctx.query.t) {
|
||||
exports.latestVersionsMap.set(ctx.path, ctx.query.t);
|
||||
}
|
||||
return next();
|
||||
});
|
||||
// start a websocket server to send hmr notifications to the client
|
||||
const wss = new ws_1.default.Server({ noServer: true });
|
||||
server.on('upgrade', (req, socket, head) => {
|
||||
if (req.headers['sec-websocket-protocol'] === 'vite-hmr') {
|
||||
wss.handleUpgrade(req, socket, head, (ws) => {
|
||||
wss.emit('connection', ws, req);
|
||||
});
|
||||
}
|
||||
});
|
||||
wss.on('connection', (socket) => {
|
||||
exports.debugHmr('ws client connected');
|
||||
socket.send(JSON.stringify({ type: 'connected' }));
|
||||
});
|
||||
wss.on('error', (e) => {
|
||||
if (e.code !== 'EADDRINUSE') {
|
||||
console.error(chalk_1.default.red(`[vite] WebSocket server error:`));
|
||||
console.error(e);
|
||||
}
|
||||
});
|
||||
const send = (watcher.send = (payload) => {
|
||||
const stringified = JSON.stringify(payload, null, 2);
|
||||
exports.debugHmr(`update: ${stringified}`);
|
||||
wss.clients.forEach((client) => {
|
||||
if (client.readyState === ws_1.default.OPEN) {
|
||||
client.send(stringified);
|
||||
}
|
||||
});
|
||||
});
|
||||
const handleJSReload = (watcher.handleJSReload = (filePath, timestamp = Date.now()) => {
|
||||
// normal js file, but could be compiled from anything.
|
||||
// bust the vue cache in case this is a src imported file
|
||||
if (serverPluginVue_1.srcImportMap.has(filePath)) {
|
||||
exports.debugHmr(`busting Vue cache for ${filePath}`);
|
||||
serverPluginVue_1.vueCache.del(filePath);
|
||||
}
|
||||
const publicPath = resolver.fileToRequest(filePath);
|
||||
const importers = exports.importerMap.get(publicPath);
|
||||
if (importers || isHmrAccepted(publicPath, publicPath)) {
|
||||
const hmrBoundaries = new Set();
|
||||
const dirtyFiles = new Set();
|
||||
dirtyFiles.add(publicPath);
|
||||
const hasDeadEnd = walkImportChain(publicPath, importers || new Set(), hmrBoundaries, dirtyFiles);
|
||||
// record dirty files - this is used when HMR requests coming in with
|
||||
// timestamp to determine what files need to be force re-fetched
|
||||
exports.hmrDirtyFilesMap.set(String(timestamp), dirtyFiles);
|
||||
const relativeFile = '/' + slash_1.default(path_1.default.relative(root, filePath));
|
||||
if (hasDeadEnd) {
|
||||
send({
|
||||
type: 'full-reload',
|
||||
path: publicPath
|
||||
});
|
||||
console.log(chalk_1.default.green(`[vite] `) + `page reloaded.`);
|
||||
}
|
||||
else {
|
||||
const boundaries = [...hmrBoundaries];
|
||||
const file = boundaries.length === 1 ? boundaries[0] : `${boundaries.length} files`;
|
||||
console.log(chalk_1.default.green(`[vite:hmr] `) +
|
||||
`${file} hot updated due to change in ${relativeFile}.`);
|
||||
send({
|
||||
type: 'multi',
|
||||
updates: boundaries.map((boundary) => {
|
||||
return {
|
||||
type: boundary.endsWith('vue') ? 'vue-reload' : 'js-update',
|
||||
path: boundary,
|
||||
changeSrcPath: publicPath,
|
||||
timestamp
|
||||
};
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
exports.debugHmr(`no importers for ${publicPath}.`);
|
||||
}
|
||||
});
|
||||
watcher.on('change', (file) => {
|
||||
if (!(file.endsWith('.vue') || cssUtils_1.isCSSRequest(file))) {
|
||||
// everything except plain .css are considered HMR dependencies.
|
||||
// plain css has its own HMR logic in ./serverPluginCss.ts.
|
||||
handleJSReload(file);
|
||||
}
|
||||
});
|
||||
};
|
||||
function walkImportChain(importee, importers, hmrBoundaries, dirtyFiles, currentChain = []) {
|
||||
if (exports.hmrDeclineSet.has(importee)) {
|
||||
// module explicitly declines HMR = dead end
|
||||
return true;
|
||||
}
|
||||
if (isHmrAccepted(importee, importee)) {
|
||||
// self-accepting module.
|
||||
hmrBoundaries.add(importee);
|
||||
dirtyFiles.add(importee);
|
||||
return false;
|
||||
}
|
||||
for (const importer of importers) {
|
||||
if (importer.endsWith('.vue') ||
|
||||
// explicitly accepted by this importer
|
||||
isHmrAccepted(importer, importee) ||
|
||||
// importer is a self accepting module
|
||||
isHmrAccepted(importer, importer)) {
|
||||
// vue boundaries are considered dirty for the reload
|
||||
if (importer.endsWith('.vue')) {
|
||||
dirtyFiles.add(importer);
|
||||
}
|
||||
hmrBoundaries.add(importer);
|
||||
currentChain.forEach((file) => dirtyFiles.add(file));
|
||||
}
|
||||
else {
|
||||
const parentImpoters = exports.importerMap.get(importer);
|
||||
if (!parentImpoters) {
|
||||
return true;
|
||||
}
|
||||
else if (!currentChain.includes(importer)) {
|
||||
if (walkImportChain(importer, parentImpoters, hmrBoundaries, dirtyFiles, currentChain.concat(importer))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function isHmrAccepted(importer, dep) {
|
||||
const deps = exports.hmrAcceptanceMap.get(importer);
|
||||
return deps ? deps.has(dep) : false;
|
||||
}
|
||||
function ensureMapEntry(map, key) {
|
||||
let entry = map.get(key);
|
||||
if (!entry) {
|
||||
entry = new Set();
|
||||
map.set(key, entry);
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
exports.ensureMapEntry = ensureMapEntry;
|
||||
function rewriteFileWithHMR(root, source, importer, resolver, s) {
|
||||
let hasDeclined = false;
|
||||
const registerDep = (e) => {
|
||||
const deps = ensureMapEntry(exports.hmrAcceptanceMap, importer);
|
||||
const depPublicPath = serverPluginModuleRewrite_1.resolveImport(root, importer, e.value, resolver);
|
||||
deps.add(depPublicPath);
|
||||
exports.debugHmr(` ${importer} accepts ${depPublicPath}`);
|
||||
ensureMapEntry(exports.importerMap, depPublicPath).add(importer);
|
||||
s.overwrite(e.start, e.end, JSON.stringify(depPublicPath));
|
||||
};
|
||||
const checkHotCall = (node, isTopLevel, isDevBlock) => {
|
||||
if (node.type === 'CallExpression' &&
|
||||
node.callee.type === 'MemberExpression' &&
|
||||
isMetaHot(node.callee.object)) {
|
||||
if (isTopLevel) {
|
||||
const { generateCodeFrame } = utils_1.resolveCompiler(root);
|
||||
console.warn(chalk_1.default.yellow(`[vite] HMR syntax error in ${importer}: import.meta.hot.accept() ` +
|
||||
`should be wrapped in \`if (import.meta.hot) {}\` conditional ` +
|
||||
`blocks so that they can be tree-shaken in production.`));
|
||||
console.warn(chalk_1.default.yellow(generateCodeFrame(source, node.start, node.end)));
|
||||
}
|
||||
const method = node.callee.property.type === 'Identifier' && node.callee.property.name;
|
||||
if (method === 'accept' || method === 'acceptDeps') {
|
||||
if (!isDevBlock) {
|
||||
console.error(chalk_1.default.yellow(`[vite] HMR syntax error in ${importer}: import.meta.hot.${method}() ` +
|
||||
`cannot be conditional except for \`if (import.meta.hot)\` check ` +
|
||||
`because the server relies on static analysis to construct the HMR graph.`));
|
||||
}
|
||||
// register the accepted deps
|
||||
const accepted = node.arguments[0];
|
||||
if (accepted && accepted.type === 'ArrayExpression') {
|
||||
if (method !== 'acceptDeps') {
|
||||
console.error(chalk_1.default.yellow(`[vite] HMR syntax error in ${importer}: hot.accept() only accepts ` +
|
||||
`a single callback. Use hot.acceptDeps() to handle dep updates.`));
|
||||
}
|
||||
// import.meta.hot.accept(['./foo', './bar'], () => {})
|
||||
accepted.elements.forEach((e) => {
|
||||
if (e && e.type !== 'StringLiteral') {
|
||||
console.error(chalk_1.default.yellow(`[vite] HMR syntax error in ${importer}: hot.accept() deps ` +
|
||||
`list can only contain string literals.`));
|
||||
}
|
||||
else if (e) {
|
||||
registerDep(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (accepted && accepted.type === 'StringLiteral') {
|
||||
if (method !== 'acceptDeps') {
|
||||
console.error(chalk_1.default.yellow(`[vite] HMR syntax error in ${importer}: hot.accept() only accepts ` +
|
||||
`a single callback. Use hot.acceptDeps() to handle dep updates.`));
|
||||
}
|
||||
// import.meta.hot.accept('./foo', () => {})
|
||||
registerDep(accepted);
|
||||
}
|
||||
else if (!accepted || accepted.type.endsWith('FunctionExpression')) {
|
||||
if (method !== 'accept') {
|
||||
console.error(chalk_1.default.yellow(`[vite] HMR syntax error in ${importer}: hot.acceptDeps() ` +
|
||||
`expects a dependency or an array of dependencies. ` +
|
||||
`Use hot.accept() for handling self updates.`));
|
||||
}
|
||||
// self accepting
|
||||
// import.meta.hot.accept() OR import.meta.hot.accept(() => {})
|
||||
ensureMapEntry(exports.hmrAcceptanceMap, importer).add(importer);
|
||||
exports.debugHmr(`${importer} self accepts`);
|
||||
}
|
||||
else {
|
||||
console.error(chalk_1.default.yellow(`[vite] HMR syntax error in ${importer}: ` +
|
||||
`import.meta.hot.accept() expects a dep string, an array of ` +
|
||||
`deps, or a callback.`));
|
||||
}
|
||||
}
|
||||
if (method === 'decline') {
|
||||
hasDeclined = true;
|
||||
exports.hmrDeclineSet.add(importer);
|
||||
}
|
||||
}
|
||||
};
|
||||
const checkStatements = (node, isTopLevel, isDevBlock) => {
|
||||
if (node.type === 'ExpressionStatement') {
|
||||
// top level hot.accept() call
|
||||
checkHotCall(node.expression, isTopLevel, isDevBlock);
|
||||
}
|
||||
// if (import.meta.hot) ...
|
||||
if (node.type === 'IfStatement') {
|
||||
const isDevBlock = isMetaHot(node.test);
|
||||
if (node.consequent.type === 'BlockStatement') {
|
||||
node.consequent.body.forEach((s) => checkStatements(s, false, isDevBlock));
|
||||
}
|
||||
if (node.consequent.type === 'ExpressionStatement') {
|
||||
checkHotCall(node.consequent.expression, false, isDevBlock);
|
||||
}
|
||||
}
|
||||
};
|
||||
const ast = babelParse_1.parse(source);
|
||||
ast.forEach((s) => checkStatements(s, true, false));
|
||||
// inject import.meta.hot
|
||||
s.prepend(`import { createHotContext } from "${serverPluginClient_1.clientPublicPath}"; ` +
|
||||
`import.meta.hot = createHotContext(${JSON.stringify(importer)}); `);
|
||||
// clear decline state
|
||||
if (!hasDeclined) {
|
||||
exports.hmrDeclineSet.delete(importer);
|
||||
}
|
||||
}
|
||||
exports.rewriteFileWithHMR = rewriteFileWithHMR;
|
||||
function isMetaHot(node) {
|
||||
return (node.type === 'MemberExpression' &&
|
||||
node.object.type === 'MetaProperty' &&
|
||||
node.property.type === 'Identifier' &&
|
||||
node.property.name === 'hot');
|
||||
}
|
||||
//# sourceMappingURL=serverPluginHmr.js.map
|
||||
1
node_modules/vite/dist/node/server/serverPluginHmr.js.map
generated
vendored
1
node_modules/vite/dist/node/server/serverPluginHmr.js.map
generated
vendored
File diff suppressed because one or more lines are too long
2
node_modules/vite/dist/node/server/serverPluginHtml.d.ts
generated
vendored
2
node_modules/vite/dist/node/server/serverPluginHtml.d.ts
generated
vendored
@@ -1,2 +0,0 @@
|
||||
import { ServerPlugin } from './index';
|
||||
export declare const htmlRewritePlugin: ServerPlugin;
|
||||
75
node_modules/vite/dist/node/server/serverPluginHtml.js
generated
vendored
75
node_modules/vite/dist/node/server/serverPluginHtml.js
generated
vendored
@@ -1,75 +0,0 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.htmlRewritePlugin = void 0;
|
||||
const index_1 = require("./index");
|
||||
const serverPluginHmr_1 = require("./serverPluginHmr");
|
||||
const serverPluginClient_1 = require("./serverPluginClient");
|
||||
const es_module_lexer_1 = require("es-module-lexer");
|
||||
const utils_1 = require("../utils");
|
||||
const lru_cache_1 = __importDefault(require("lru-cache"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const chalk_1 = __importDefault(require("chalk"));
|
||||
const debug = require('debug')('vite:rewrite');
|
||||
const rewriteHtmlPluginCache = new lru_cache_1.default({ max: 20 });
|
||||
exports.htmlRewritePlugin = ({ root, app, watcher, resolver, config }) => {
|
||||
const devInjectionCode = `\n<script type="module">import "${serverPluginClient_1.clientPublicPath}"</script>\n`;
|
||||
const scriptRE = /(<script\b[^>]*type\s*=\s*(?:"module"|'module')[^>]*>)([\s\S]*?)<\/script>/gm;
|
||||
const srcRE = /\bsrc=(?:"([^"]+)"|'([^']+)'|([^'"\s]+)\b)/;
|
||||
async function rewriteHtml(importer, html) {
|
||||
await es_module_lexer_1.init;
|
||||
html = await utils_1.transformIndexHtml(html, config.indexHtmlTransforms, 'pre', false);
|
||||
html = html.replace(scriptRE, (matched, openTag, script) => {
|
||||
if (script) {
|
||||
return `${openTag}${index_1.rewriteImports(root, script, importer, resolver)}</script>`;
|
||||
}
|
||||
else {
|
||||
const srcAttr = openTag.match(srcRE);
|
||||
if (srcAttr) {
|
||||
// register script as a import dep for hmr
|
||||
const importee = resolver.normalizePublicPath(utils_1.cleanUrl(path_1.default.posix.resolve('/', srcAttr[1] || srcAttr[2])));
|
||||
serverPluginHmr_1.debugHmr(` ${importer} imports ${importee}`);
|
||||
serverPluginHmr_1.ensureMapEntry(serverPluginHmr_1.importerMap, importee).add(importer);
|
||||
}
|
||||
return matched;
|
||||
}
|
||||
});
|
||||
const processedHtml = utils_1.injectScriptToHtml(html, devInjectionCode);
|
||||
return await utils_1.transformIndexHtml(processedHtml, config.indexHtmlTransforms, 'post', false);
|
||||
}
|
||||
app.use(async (ctx, next) => {
|
||||
await next();
|
||||
if (ctx.status === 304) {
|
||||
return;
|
||||
}
|
||||
if (ctx.response.is('html') && ctx.body) {
|
||||
const importer = ctx.path;
|
||||
const html = await utils_1.readBody(ctx.body);
|
||||
if (rewriteHtmlPluginCache.has(html)) {
|
||||
debug(`${ctx.path}: serving from cache`);
|
||||
ctx.body = rewriteHtmlPluginCache.get(html);
|
||||
}
|
||||
else {
|
||||
if (!html)
|
||||
return;
|
||||
ctx.body = await rewriteHtml(importer, html);
|
||||
rewriteHtmlPluginCache.set(html, ctx.body);
|
||||
}
|
||||
return;
|
||||
}
|
||||
});
|
||||
watcher.on('change', (file) => {
|
||||
const path = resolver.fileToRequest(file);
|
||||
if (path.endsWith('.html')) {
|
||||
debug(`${path}: cache busted`);
|
||||
watcher.send({
|
||||
type: 'full-reload',
|
||||
path
|
||||
});
|
||||
console.log(chalk_1.default.green(`[vite] `) + ` ${path} page reloaded.`);
|
||||
}
|
||||
});
|
||||
};
|
||||
//# sourceMappingURL=serverPluginHtml.js.map
|
||||
1
node_modules/vite/dist/node/server/serverPluginHtml.js.map
generated
vendored
1
node_modules/vite/dist/node/server/serverPluginHtml.js.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"serverPluginHtml.js","sourceRoot":"","sources":["../../../src/node/server/serverPluginHtml.ts"],"names":[],"mappings":";;;;;;AAAA,mCAAsD;AACtD,uDAAyE;AACzE,6DAAuD;AACvD,qDAAmD;AACnD,oCAKiB;AACjB,0DAAgC;AAChC,gDAAuB;AACvB,kDAAyB;AAEzB,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,CAAA;AAE9C,MAAM,sBAAsB,GAAG,IAAI,mBAAQ,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAA;AAE3C,QAAA,iBAAiB,GAAiB,CAAC,EAC9C,IAAI,EACJ,GAAG,EACH,OAAO,EACP,QAAQ,EACR,MAAM,EACP,EAAE,EAAE;IACH,MAAM,gBAAgB,GAAG,mCAAmC,qCAAgB,cAAc,CAAA;IAC1F,MAAM,QAAQ,GAAG,8EAA8E,CAAA;IAC/F,MAAM,KAAK,GAAG,4CAA4C,CAAA;IAE1D,KAAK,UAAU,WAAW,CAAC,QAAgB,EAAE,IAAY;QACvD,MAAM,sBAAS,CAAA;QACf,IAAI,GAAG,MAAM,0BAAkB,CAC7B,IAAI,EACJ,MAAM,CAAC,mBAAmB,EAC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AM,QAAQ,GAAG,GAAG,CAAC,IAAI,CAAA;YACzB,MAAM,IAAI,GAAG,MAAM,gBAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;YACrC,IAAI,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;gBACpC,KAAK,CAAC,GAAG,GAAG,CAAC,IAAI,sBAAsB,CAAC,CAAA;gBACxC,GAAG,CAAC,IAAI,GAAG,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;aAC5C;iBAAM;gBACL,IAAI,CAAC,IAAI;oBAAE,OAAM;gBACjB,GAAG,CAAC,IAAI,GAAG,MAAM,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;gBAC5C,sBAAsB,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,CAAA;aAC3C;YACD,OAAM;SACP;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE;QAC5B,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;QACzC,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YAC1B,KAAK,CAAC,GAAG,IAAI,gBAAgB,CAAC,CAAA;YAC9B,OAAO,CAAC,IAAI,CAAC;gBACX,IAAI,EAAE,aAAa;gBACnB,IAAI;aACL,CAAC,CAAA;YACF,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,IAAI,IAAI,iBAAiB,CAAC,CAAA;SAChE;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
||||
2
node_modules/vite/dist/node/server/serverPluginJson.d.ts
generated
vendored
2
node_modules/vite/dist/node/server/serverPluginJson.d.ts
generated
vendored
@@ -1,2 +0,0 @@
|
||||
import { ServerPlugin } from '.';
|
||||
export declare const jsonPlugin: ServerPlugin;
|
||||
20
node_modules/vite/dist/node/server/serverPluginJson.js
generated
vendored
20
node_modules/vite/dist/node/server/serverPluginJson.js
generated
vendored
@@ -1,20 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.jsonPlugin = void 0;
|
||||
const utils_1 = require("../utils");
|
||||
const pluginutils_1 = require("@rollup/pluginutils");
|
||||
exports.jsonPlugin = ({ app }) => {
|
||||
app.use(async (ctx, next) => {
|
||||
await next();
|
||||
// handle .json imports
|
||||
// note ctx.body could be null if upstream set status to 304
|
||||
if (ctx.path.endsWith('.json') && utils_1.isImportRequest(ctx) && ctx.body) {
|
||||
ctx.type = 'js';
|
||||
ctx.body = pluginutils_1.dataToEsm(JSON.parse((await utils_1.readBody(ctx.body))), {
|
||||
namedExports: true,
|
||||
preferConst: true
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
//# sourceMappingURL=serverPluginJson.js.map
|
||||
1
node_modules/vite/dist/node/server/serverPluginJson.js.map
generated
vendored
1
node_modules/vite/dist/node/server/serverPluginJson.js.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"serverPluginJson.js","sourceRoot":"","sources":["../../../src/node/server/serverPluginJson.ts"],"names":[],"mappings":";;;AACA,oCAAoD;AACpD,qDAA+C;AAElC,QAAA,UAAU,GAAiB,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;IAClD,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QAC1B,MAAM,IAAI,EAAE,CAAA;QACZ,uBAAuB;QACvB,4DAA4D;QAC5D,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,uBAAe,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE;YAClE,GAAG,CAAC,IAAI,GAAG,IAAI,CAAA;YACf,GAAG,CAAC,IAAI,GAAG,uBAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,gBAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAE,CAAC,EAAE;gBAC5D,YAAY,EAAE,IAAI;gBAClB,WAAW,EAAE,IAAI;aAClB,CAAC,CAAA;SACH;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
||||
5
node_modules/vite/dist/node/server/serverPluginModuleResolve.d.ts
generated
vendored
5
node_modules/vite/dist/node/server/serverPluginModuleResolve.d.ts
generated
vendored
@@ -1,5 +0,0 @@
|
||||
import { ServerPlugin } from '.';
|
||||
export declare const moduleIdToFileMap: Map<any, any>;
|
||||
export declare const moduleFileToIdMap: Map<any, any>;
|
||||
export declare const moduleRE: RegExp;
|
||||
export declare const moduleResolvePlugin: ServerPlugin;
|
||||
87
node_modules/vite/dist/node/server/serverPluginModuleResolve.js
generated
vendored
87
node_modules/vite/dist/node/server/serverPluginModuleResolve.js
generated
vendored
@@ -1,87 +0,0 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.moduleResolvePlugin = exports.moduleRE = exports.moduleFileToIdMap = exports.moduleIdToFileMap = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const chalk_1 = __importDefault(require("chalk"));
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const utils_1 = require("../utils");
|
||||
const url_1 = require("url");
|
||||
const resolver_1 = require("../resolver");
|
||||
const debug = require('debug')('vite:resolve');
|
||||
exports.moduleIdToFileMap = new Map();
|
||||
exports.moduleFileToIdMap = new Map();
|
||||
exports.moduleRE = /^\/@modules\//;
|
||||
const getDebugPath = (root, p) => {
|
||||
const relative = path_1.default.relative(root, p);
|
||||
return relative.startsWith('..') ? p : relative;
|
||||
};
|
||||
// plugin for resolving /@modules/:id requests.
|
||||
exports.moduleResolvePlugin = ({ root, app, resolver }) => {
|
||||
const vueResolved = utils_1.resolveVue(root);
|
||||
app.use(async (ctx, next) => {
|
||||
if (!exports.moduleRE.test(ctx.path)) {
|
||||
return next();
|
||||
}
|
||||
// path maybe contain encode chars
|
||||
const id = decodeURIComponent(ctx.path.replace(exports.moduleRE, ''));
|
||||
ctx.type = 'js';
|
||||
const serve = async (id, file, type) => {
|
||||
exports.moduleIdToFileMap.set(id, file);
|
||||
exports.moduleFileToIdMap.set(file, ctx.path);
|
||||
debug(`(${type}) ${id} -> ${getDebugPath(root, file)}`);
|
||||
await ctx.read(file);
|
||||
return next();
|
||||
};
|
||||
// special handling for vue runtime in case it's not installed
|
||||
if (!vueResolved.isLocal && id in vueResolved) {
|
||||
return serve(id, vueResolved[id], 'non-local vue');
|
||||
}
|
||||
// already resolved and cached
|
||||
const cachedPath = exports.moduleIdToFileMap.get(id);
|
||||
if (cachedPath) {
|
||||
return serve(id, cachedPath, 'cached');
|
||||
}
|
||||
// resolve from vite optimized modules
|
||||
const optimized = resolver_1.resolveOptimizedModule(root, id);
|
||||
if (optimized) {
|
||||
return serve(id, optimized, 'optimized');
|
||||
}
|
||||
const referer = ctx.get('referer');
|
||||
let importer;
|
||||
// this is a map file request from browser dev tool
|
||||
const isMapFile = ctx.path.endsWith('.map');
|
||||
if (referer) {
|
||||
importer = new url_1.URL(referer).pathname;
|
||||
}
|
||||
else if (isMapFile) {
|
||||
// for some reason Chrome doesn't provide referer for source map requests.
|
||||
// do our best to reverse-infer the importer.
|
||||
importer = ctx.path.replace(/\.map$/, '');
|
||||
}
|
||||
const importerFilePath = importer ? resolver.requestToFile(importer) : root;
|
||||
// #829 node package has sub-package(has package.json), should check it before `resolveNodeModuleFile`
|
||||
const nodeModuleInfo = resolver_1.resolveNodeModule(root, id, resolver);
|
||||
if (nodeModuleInfo) {
|
||||
return serve(id, nodeModuleInfo.entryFilePath, 'node_modules');
|
||||
}
|
||||
const nodeModuleFilePath = resolver_1.resolveNodeModuleFile(importerFilePath, id);
|
||||
if (nodeModuleFilePath) {
|
||||
return serve(id, nodeModuleFilePath, 'node_modules');
|
||||
}
|
||||
if (isMapFile && importer) {
|
||||
// the resolveNodeModuleFile doesn't work with linked pkg
|
||||
// our last try: infer from the dir of importer
|
||||
const inferMapPath = path_1.default.join(path_1.default.dirname(importerFilePath), path_1.default.basename(ctx.path));
|
||||
if (fs_extra_1.default.existsSync(inferMapPath)) {
|
||||
return serve(id, inferMapPath, 'map file in linked pkg');
|
||||
}
|
||||
}
|
||||
console.error(chalk_1.default.red(`[vite] Failed to resolve module import "${id}". ` +
|
||||
`(imported by ${importer || 'unknown'})`));
|
||||
ctx.status = 404;
|
||||
});
|
||||
};
|
||||
//# sourceMappingURL=serverPluginModuleResolve.js.map
|
||||
1
node_modules/vite/dist/node/server/serverPluginModuleResolve.js.map
generated
vendored
1
node_modules/vite/dist/node/server/serverPluginModuleResolve.js.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"serverPluginModuleResolve.js","sourceRoot":"","sources":["../../../src/node/server/serverPluginModuleResolve.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AACvB,kDAAyB;AACzB,wDAAyB;AAEzB,oCAAqC;AACrC,6BAAyB;AACzB,0CAIoB;AAEpB,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,CAAA;AAEjC,QAAA,iBAAiB,GAAG,IAAI,GAAG,EAAE,CAAA;AAC7B,QAAA,iBAAiB,GAAG,IAAI,GAAG,EAAE,CAAA;AAE7B,QAAA,QAAQ,GAAG,eAAe,CAAA;AAEvC,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,CAAS,EAAE,EAAE;IAC/C,MAAM,QAAQ,GAAG,cAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;IACvC,OAAO,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAA;AACjD,CAAC,CAAA;AAED,+CAA+C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YAAY,GAAG,cAAI,CAAC,IAAI,CAC5B,cAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAC9B,cAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CACxB,CAAA;YACD,IAAI,kBAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE;gBAC/B,OAAO,KAAK,CAAC,EAAE,EAAE,YAAY,EAAE,wBAAwB,CAAC,CAAA;aACzD;SACF;QAED,OAAO,CAAC,KAAK,CACX,eAAK,CAAC,GAAG,CACP,2CAA2C,EAAE,KAAK;YAChD,gBAAgB,QAAQ,IAAI,SAAS,GAAG,CAC3C,CACF,CAAA;QACD,GAAG,CAAC,MAAM,GAAG,GAAG,CAAA;IAClB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
||||
5
node_modules/vite/dist/node/server/serverPluginModuleRewrite.d.ts
generated
vendored
5
node_modules/vite/dist/node/server/serverPluginModuleRewrite.d.ts
generated
vendored
@@ -1,5 +0,0 @@
|
||||
import { ServerPlugin } from '.';
|
||||
import { InternalResolver } from '../resolver';
|
||||
export declare const moduleRewritePlugin: ServerPlugin;
|
||||
export declare function rewriteImports(root: string, source: string, importer: string, resolver: InternalResolver, timestamp?: string): string;
|
||||
export declare const resolveImport: (root: string, importer: string, id: string, resolver: InternalResolver, timestamp?: string | undefined) => string;
|
||||
220
node_modules/vite/dist/node/server/serverPluginModuleRewrite.js
generated
vendored
220
node_modules/vite/dist/node/server/serverPluginModuleRewrite.js
generated
vendored
@@ -1,220 +0,0 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.resolveImport = exports.rewriteImports = exports.moduleRewritePlugin = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const lru_cache_1 = __importDefault(require("lru-cache"));
|
||||
const magic_string_1 = __importDefault(require("magic-string"));
|
||||
const es_module_lexer_1 = require("es-module-lexer");
|
||||
const resolver_1 = require("../resolver");
|
||||
const serverPluginHmr_1 = require("./serverPluginHmr");
|
||||
const serverPluginClient_1 = require("./serverPluginClient");
|
||||
const utils_1 = require("../utils");
|
||||
const chalk_1 = __importDefault(require("chalk"));
|
||||
const cssUtils_1 = require("../utils/cssUtils");
|
||||
const serverPluginEnv_1 = require("./serverPluginEnv");
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const debug = require('debug')('vite:rewrite');
|
||||
const rewriteCache = new lru_cache_1.default({ max: 1024 });
|
||||
// Plugin for rewriting served js.
|
||||
// - Rewrites named module imports to `/@modules/:id` requests, e.g.
|
||||
// "vue" => "/@modules/vue"
|
||||
// - Rewrites files containing HMR code (reference to `import.meta.hot`) to
|
||||
// inject `import.meta.hot` and track HMR boundary accept whitelists.
|
||||
// - Also tracks importer/importee relationship graph during the rewrite.
|
||||
// The graph is used by the HMR plugin to perform analysis on file change.
|
||||
exports.moduleRewritePlugin = ({ root, app, watcher, resolver }) => {
|
||||
app.use(async (ctx, next) => {
|
||||
await next();
|
||||
if (ctx.status === 304) {
|
||||
return;
|
||||
}
|
||||
// we are doing the js rewrite after all other middlewares have finished;
|
||||
// this allows us to post-process javascript produced by user middlewares
|
||||
// regardless of the extension of the original files.
|
||||
const publicPath = ctx.path;
|
||||
if (ctx.body &&
|
||||
ctx.response.is('js') &&
|
||||
!cssUtils_1.isCSSRequest(ctx.path) &&
|
||||
!ctx.url.endsWith('.map') &&
|
||||
!resolver.isPublicRequest(ctx.path) &&
|
||||
// skip internal client
|
||||
publicPath !== serverPluginClient_1.clientPublicPath &&
|
||||
// need to rewrite for <script>\<template> part in vue files
|
||||
!((ctx.path.endsWith('.vue') || ctx.vue) && ctx.query.type === 'style')) {
|
||||
const content = await utils_1.readBody(ctx.body);
|
||||
const cacheKey = publicPath + content;
|
||||
const isHmrRequest = !!ctx.query.t;
|
||||
if (!isHmrRequest && rewriteCache.has(cacheKey)) {
|
||||
debug(`(cached) ${ctx.url}`);
|
||||
ctx.body = rewriteCache.get(cacheKey);
|
||||
}
|
||||
else {
|
||||
await es_module_lexer_1.init;
|
||||
// dynamic import may contain extension-less path,
|
||||
// (.e.g import(runtimePathString))
|
||||
// so we need to normalize importer to ensure it contains extension
|
||||
// before we perform hmr analysis.
|
||||
// on the other hand, static import is guaranteed to have extension
|
||||
// because they must all have gone through module rewrite.
|
||||
const importer = utils_1.removeUnRelatedHmrQuery(resolver.normalizePublicPath(ctx.url));
|
||||
ctx.body = rewriteImports(root, content, importer, resolver, ctx.query.t);
|
||||
if (!isHmrRequest) {
|
||||
rewriteCache.set(cacheKey, ctx.body);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
debug(`(skipped) ${ctx.url}`);
|
||||
}
|
||||
});
|
||||
// bust module rewrite cache on file change
|
||||
watcher.on('change', async (filePath) => {
|
||||
const publicPath = resolver.fileToRequest(filePath);
|
||||
// #662 use fs.read instead of cacheRead, avoid cache hit when request file
|
||||
// and caused pass `notModified` into transform is always true
|
||||
const cacheKey = publicPath + (await fs_extra_1.default.readFile(filePath)).toString();
|
||||
debug(`${publicPath}: cache busted`);
|
||||
rewriteCache.del(cacheKey);
|
||||
});
|
||||
};
|
||||
function rewriteImports(root, source, importer, resolver, timestamp) {
|
||||
// #806 strip UTF-8 BOM
|
||||
if (source.charCodeAt(0) === 0xfeff) {
|
||||
source = source.slice(1);
|
||||
}
|
||||
try {
|
||||
let imports = [];
|
||||
try {
|
||||
imports = es_module_lexer_1.parse(source)[0];
|
||||
}
|
||||
catch (e) {
|
||||
console.error(chalk_1.default.yellow(`[vite] failed to parse ${chalk_1.default.cyan(importer)} for import rewrite.\nIf you are using ` +
|
||||
`JSX, make sure to named the file with the .jsx extension.`));
|
||||
}
|
||||
const hasHMR = source.includes('import.meta.hot');
|
||||
const hasEnv = source.includes('import.meta.env');
|
||||
if (imports.length || hasHMR || hasEnv) {
|
||||
debug(`${importer}: rewriting`);
|
||||
const s = new magic_string_1.default(source);
|
||||
let hasReplaced = false;
|
||||
const prevImportees = serverPluginHmr_1.importeeMap.get(importer);
|
||||
const currentImportees = new Set();
|
||||
serverPluginHmr_1.importeeMap.set(importer, currentImportees);
|
||||
for (let i = 0; i < imports.length; i++) {
|
||||
const { s: start, e: end, d: dynamicIndex } = imports[i];
|
||||
let id = source.substring(start, end);
|
||||
let hasLiteralDynamicId = false;
|
||||
if (dynamicIndex >= 0) {
|
||||
// #998 remove comment
|
||||
id = id.replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm, '');
|
||||
const literalIdMatch = id.match(/^\s*(?:'([^']+)'|"([^"]+)")\s*$/);
|
||||
if (literalIdMatch) {
|
||||
hasLiteralDynamicId = true;
|
||||
id = literalIdMatch[1] || literalIdMatch[2];
|
||||
}
|
||||
}
|
||||
if (dynamicIndex === -1 || hasLiteralDynamicId) {
|
||||
// do not rewrite external imports
|
||||
if (utils_1.isExternalUrl(id)) {
|
||||
continue;
|
||||
}
|
||||
const resolved = exports.resolveImport(root, importer, id, resolver, timestamp);
|
||||
if (resolved !== id) {
|
||||
debug(` "${id}" --> "${resolved}"`);
|
||||
s.overwrite(start, end, hasLiteralDynamicId ? `'${resolved}'` : resolved);
|
||||
hasReplaced = true;
|
||||
}
|
||||
// save the import chain for hmr analysis
|
||||
const importee = utils_1.cleanUrl(resolved);
|
||||
if (importee !== importer &&
|
||||
// no need to track hmr client or module dependencies
|
||||
importee !== serverPluginClient_1.clientPublicPath) {
|
||||
currentImportees.add(importee);
|
||||
serverPluginHmr_1.debugHmr(` ${importer} imports ${importee}`);
|
||||
serverPluginHmr_1.ensureMapEntry(serverPluginHmr_1.importerMap, importee).add(importer);
|
||||
}
|
||||
}
|
||||
else if (id !== 'import.meta' &&
|
||||
!/\/\*\s*@vite-ignore\s*\*\//.test(id)) {
|
||||
console.warn(chalk_1.default.yellow(`[vite] ignored dynamic import(${id}) in ${importer}.`));
|
||||
}
|
||||
}
|
||||
if (hasHMR) {
|
||||
serverPluginHmr_1.debugHmr(`rewriting ${importer} for HMR.`);
|
||||
serverPluginHmr_1.rewriteFileWithHMR(root, source, importer, resolver, s);
|
||||
hasReplaced = true;
|
||||
}
|
||||
if (hasEnv) {
|
||||
debug(` injecting import.meta.env for ${importer}`);
|
||||
s.prepend(`import __VITE_ENV__ from "${serverPluginEnv_1.envPublicPath}"; ` +
|
||||
`import.meta.env = __VITE_ENV__; `);
|
||||
hasReplaced = true;
|
||||
}
|
||||
// since the importees may have changed due to edits,
|
||||
// check if we need to remove this importer from certain importees
|
||||
if (prevImportees) {
|
||||
prevImportees.forEach((importee) => {
|
||||
if (!currentImportees.has(importee)) {
|
||||
const importers = serverPluginHmr_1.importerMap.get(importee);
|
||||
if (importers) {
|
||||
importers.delete(importer);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!hasReplaced) {
|
||||
debug(` nothing needs rewriting.`);
|
||||
}
|
||||
return hasReplaced ? s.toString() : source;
|
||||
}
|
||||
else {
|
||||
debug(`${importer}: no imports found.`);
|
||||
}
|
||||
return source;
|
||||
}
|
||||
catch (e) {
|
||||
console.error(`[vite] Error: module imports rewrite failed for ${importer}.\n`, e);
|
||||
debug(source);
|
||||
return source;
|
||||
}
|
||||
}
|
||||
exports.rewriteImports = rewriteImports;
|
||||
exports.resolveImport = (root, importer, id, resolver, timestamp) => {
|
||||
id = resolver.alias(id) || id;
|
||||
if (utils_1.bareImportRE.test(id)) {
|
||||
// directly resolve bare module names to its entry path so that relative
|
||||
// imports from it (including source map urls) can work correctly
|
||||
id = `/@modules/${resolver_1.resolveBareModuleRequest(root, id, importer, resolver)}`;
|
||||
}
|
||||
else {
|
||||
// 1. relative to absolute
|
||||
// ./foo -> /some/path/foo
|
||||
let { pathname, query } = resolver.resolveRelativeRequest(importer, id);
|
||||
// 2. resolve dir index and extensions.
|
||||
pathname = resolver.normalizePublicPath(pathname);
|
||||
// 3. mark non-src imports
|
||||
if (!query && path_1.default.extname(pathname) && !resolver_1.jsSrcRE.test(pathname)) {
|
||||
query += `?import`;
|
||||
}
|
||||
id = pathname + query;
|
||||
}
|
||||
// 4. force re-fetch dirty imports by appending timestamp
|
||||
if (timestamp) {
|
||||
const dirtyFiles = serverPluginHmr_1.hmrDirtyFilesMap.get(timestamp);
|
||||
const cleanId = utils_1.cleanUrl(id);
|
||||
// only rewrite if:
|
||||
if (dirtyFiles && dirtyFiles.has(cleanId)) {
|
||||
// 1. this is a marked dirty file (in the import chain of the changed file)
|
||||
id += `${id.includes(`?`) ? `&` : `?`}t=${timestamp}`;
|
||||
}
|
||||
else if (serverPluginHmr_1.latestVersionsMap.has(cleanId)) {
|
||||
// 2. this file was previously hot-updated and has an updated version
|
||||
id += `${id.includes(`?`) ? `&` : `?`}t=${serverPluginHmr_1.latestVersionsMap.get(cleanId)}`;
|
||||
}
|
||||
}
|
||||
return id;
|
||||
};
|
||||
//# sourceMappingURL=serverPluginModuleRewrite.js.map
|
||||
1
node_modules/vite/dist/node/server/serverPluginModuleRewrite.js.map
generated
vendored
1
node_modules/vite/dist/node/server/serverPluginModuleRewrite.js.map
generated
vendored
File diff suppressed because one or more lines are too long
6
node_modules/vite/dist/node/server/serverPluginProxy.d.ts
generated
vendored
6
node_modules/vite/dist/node/server/serverPluginProxy.d.ts
generated
vendored
@@ -1,6 +0,0 @@
|
||||
import { ServerPlugin } from '.';
|
||||
import { IKoaProxiesOptions } from 'koa-proxies';
|
||||
export declare type ProxiesOptions = IKoaProxiesOptions & {
|
||||
ws: boolean;
|
||||
};
|
||||
export declare const proxyPlugin: ServerPlugin;
|
||||
33
node_modules/vite/dist/node/server/serverPluginProxy.js
generated
vendored
33
node_modules/vite/dist/node/server/serverPluginProxy.js
generated
vendored
@@ -1,33 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.proxyPlugin = void 0;
|
||||
const url_1 = require("url");
|
||||
exports.proxyPlugin = ({ app, config, server }) => {
|
||||
if (!config.proxy) {
|
||||
return;
|
||||
}
|
||||
const debug = require('debug')('vite:proxy');
|
||||
const proxy = require('koa-proxies');
|
||||
const options = config.proxy;
|
||||
Object.keys(options).forEach((path) => {
|
||||
let opts = options[path];
|
||||
if (typeof opts === 'string') {
|
||||
opts = { target: opts };
|
||||
}
|
||||
opts.logs = (ctx, target) => {
|
||||
debug(`${ctx.req.method} ${ctx.req.oldPath} proxy to -> ${new url_1.URL(ctx.req.url, target)}`);
|
||||
};
|
||||
app.use(proxy(path, opts));
|
||||
});
|
||||
server.on('upgrade', (req, socket, head) => {
|
||||
if (req.headers['sec-websocket-protocol'] !== 'vite-hmr') {
|
||||
for (const path in options) {
|
||||
let opts = options[path];
|
||||
if (typeof opts === 'object' && opts.ws) {
|
||||
proxy.proxy.ws(req, socket, head, opts);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
//# sourceMappingURL=serverPluginProxy.js.map
|
||||
1
node_modules/vite/dist/node/server/serverPluginProxy.js.map
generated
vendored
1
node_modules/vite/dist/node/server/serverPluginProxy.js.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"serverPluginProxy.js","sourceRoot":"","sources":["../../../src/node/server/serverPluginProxy.ts"],"names":[],"mappings":";;;AACA,6BAAyB;AAKZ,QAAA,WAAW,GAAiB,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE;IACnE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE;QACjB,OAAM;KACP;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,CAAA;IAC5C,MAAM,KAAK,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;IACpC,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAA;IAC5B,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACpC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;QACxB,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YAC5B,IAAI,GAAG,EAAE,MAAM,EAAE,IAAI,EAAoB,CAAA;SAC1C;QACD,IAAI,CAAC,IAAI,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;YAC1B,KAAK,CACH,GAAG,GAAG,CAAC,GAAG,CAAC,MAAM,IAAK,GAAG,CAAC,GAAW,CAAC,OAAO,gBAAgB,IAAI,SAAG,CAClE,GAAG,CAAC,GAAG,CAAC,GAAI,EACZ,MAAM,CACP,EAAE,CACJ,CAAA;QACH,CAAC,CAAA;QACD,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;IAC5B,CAAC,CAAC,CAAA;IAEF,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;QACzC,IAAI,GAAG,CAAC,OAAO,CAAC,wBAAwB,CAAC,KAAK,UAAU,EAAE;YACxD,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE;gBAC1B,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;gBACxB,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,EAAE,EAAE;oBACvC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;iBACxC;aACF;SACF;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
||||
3
node_modules/vite/dist/node/server/serverPluginServeStatic.d.ts
generated
vendored
3
node_modules/vite/dist/node/server/serverPluginServeStatic.d.ts
generated
vendored
@@ -1,3 +0,0 @@
|
||||
import { ServerPlugin } from '.';
|
||||
export declare const seenUrls: Set<unknown>;
|
||||
export declare const serveStaticPlugin: ServerPlugin;
|
||||
77
node_modules/vite/dist/node/server/serverPluginServeStatic.js
generated
vendored
77
node_modules/vite/dist/node/server/serverPluginServeStatic.js
generated
vendored
@@ -1,77 +0,0 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.serveStaticPlugin = exports.seenUrls = void 0;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const chalk_1 = __importDefault(require("chalk"));
|
||||
const send = require('koa-send');
|
||||
const debug = require('debug')('vite:history');
|
||||
exports.seenUrls = new Set();
|
||||
exports.serveStaticPlugin = ({ root, app, resolver, config }) => {
|
||||
app.use(async (ctx, next) => {
|
||||
// short circuit requests that have already been explicitly handled
|
||||
if (ctx.body || ctx.status !== 404) {
|
||||
return;
|
||||
}
|
||||
// warn non-root references to assets under /public/
|
||||
if (ctx.path.startsWith('/public/') && resolver.isAssetRequest(ctx.path)) {
|
||||
console.error(chalk_1.default.yellow(`[vite] files in the public directory are served at the root path.\n` +
|
||||
` ${chalk_1.default.blue(ctx.path)} should be changed to ${chalk_1.default.blue(ctx.path.replace(/^\/public\//, '/'))}.`));
|
||||
}
|
||||
// handle possible user request -> file aliases
|
||||
const expectsHtml = ctx.headers.accept && ctx.headers.accept.includes('text/html');
|
||||
if (!expectsHtml) {
|
||||
const filePath = resolver.requestToFile(ctx.path);
|
||||
if (filePath !== ctx.path &&
|
||||
fs_1.default.existsSync(filePath) &&
|
||||
fs_1.default.statSync(filePath).isFile()) {
|
||||
await ctx.read(filePath);
|
||||
}
|
||||
}
|
||||
await next();
|
||||
// the first request to the server should never 304
|
||||
if (exports.seenUrls.has(ctx.url) && ctx.fresh) {
|
||||
ctx.status = 304;
|
||||
}
|
||||
exports.seenUrls.add(ctx.url);
|
||||
});
|
||||
app.use(require('koa-etag')());
|
||||
app.use(require('koa-static')(root));
|
||||
app.use(require('koa-static')(path_1.default.join(root, 'public')));
|
||||
// history API fallback
|
||||
app.use(async (ctx, next) => {
|
||||
if (ctx.status !== 404) {
|
||||
return next();
|
||||
}
|
||||
if (ctx.method !== 'GET') {
|
||||
debug(`not redirecting ${ctx.url} (not GET)`);
|
||||
return next();
|
||||
}
|
||||
const accept = ctx.headers && ctx.headers.accept;
|
||||
if (typeof accept !== 'string') {
|
||||
debug(`not redirecting ${ctx.url} (no headers.accept)`);
|
||||
return next();
|
||||
}
|
||||
if (accept.includes('application/json')) {
|
||||
debug(`not redirecting ${ctx.url} (json)`);
|
||||
return next();
|
||||
}
|
||||
if (!accept.includes('text/html')) {
|
||||
debug(`not redirecting ${ctx.url} (not accepting html)`);
|
||||
return next();
|
||||
}
|
||||
debug(`redirecting ${ctx.url} to /index.html`);
|
||||
try {
|
||||
await send(ctx, `index.html`, { root });
|
||||
}
|
||||
catch (e) {
|
||||
ctx.url = '/index.html';
|
||||
ctx.status = 404;
|
||||
return next();
|
||||
}
|
||||
});
|
||||
};
|
||||
//# sourceMappingURL=serverPluginServeStatic.js.map
|
||||
1
node_modules/vite/dist/node/server/serverPluginServeStatic.js.map
generated
vendored
1
node_modules/vite/dist/node/server/serverPluginServeStatic.js.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"serverPluginServeStatic.js","sourceRoot":"","sources":["../../../src/node/server/serverPluginServeStatic.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAmB;AACnB,gDAAuB;AAEvB,kDAAyB;AAEzB,MAAM,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;AAChC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,CAAA;AAEjC,QAAA,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAA;AAEpB,QAAA,iBAAiB,GAAiB,CAAC,EAC9C,IAAI,EACJ,GAAG,EACH,QAAQ,EACR,MAAM,EACP,EAAE,EAAE;IACH,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EA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C9C,IAAI;YACF,MAAM,IAAI,CAAC,GAAG,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;SACxC;QAAC,OAAO,CAAC,EAAE;YACV,GAAG,CAAC,GAAG,GAAG,aAAa,CAAA;YACvB,GAAG,CAAC,MAAM,GAAG,GAAG,CAAA;YAChB,OAAO,IAAI,EAAE,CAAA;SACd;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
||||
6
node_modules/vite/dist/node/server/serverPluginSourceMap.d.ts
generated
vendored
6
node_modules/vite/dist/node/server/serverPluginSourceMap.d.ts
generated
vendored
@@ -1,6 +0,0 @@
|
||||
import { ServerPlugin } from '.';
|
||||
import { ExistingRawSourceMap } from 'rollup';
|
||||
import { RawSourceMap } from 'source-map';
|
||||
export declare type SourceMap = ExistingRawSourceMap | RawSourceMap;
|
||||
export declare function mergeSourceMap(oldMap: SourceMap | null | undefined, newMap: SourceMap): SourceMap;
|
||||
export declare const sourceMapPlugin: ServerPlugin;
|
||||
32
node_modules/vite/dist/node/server/serverPluginSourceMap.js
generated
vendored
32
node_modules/vite/dist/node/server/serverPluginSourceMap.js
generated
vendored
@@ -1,32 +0,0 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.sourceMapPlugin = exports.mergeSourceMap = void 0;
|
||||
const merge_source_map_1 = __importDefault(require("merge-source-map"));
|
||||
function mergeSourceMap(oldMap, newMap) {
|
||||
if (!oldMap) {
|
||||
return newMap;
|
||||
}
|
||||
// merge-source-map will overwrite original sources if newMap also has
|
||||
// sourcesContent
|
||||
newMap.sourcesContent = [];
|
||||
return merge_source_map_1.default(oldMap, newMap);
|
||||
}
|
||||
exports.mergeSourceMap = mergeSourceMap;
|
||||
function genSourceMapString(map) {
|
||||
if (typeof map !== 'string') {
|
||||
map = JSON.stringify(map);
|
||||
}
|
||||
return `\n//# sourceMappingURL=data:application/json;base64,${Buffer.from(map).toString('base64')}`;
|
||||
}
|
||||
exports.sourceMapPlugin = ({ app }) => {
|
||||
app.use(async (ctx, next) => {
|
||||
await next();
|
||||
if (typeof ctx.body === 'string' && ctx.map) {
|
||||
ctx.body += genSourceMapString(ctx.map);
|
||||
}
|
||||
});
|
||||
};
|
||||
//# sourceMappingURL=serverPluginSourceMap.js.map
|
||||
1
node_modules/vite/dist/node/server/serverPluginSourceMap.js.map
generated
vendored
1
node_modules/vite/dist/node/server/serverPluginSourceMap.js.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"serverPluginSourceMap.js","sourceRoot":"","sources":["../../../src/node/server/serverPluginSourceMap.ts"],"names":[],"mappings":";;;;;;AACA,wEAAoC;AAMpC,SAAgB,cAAc,CAC5B,MAAoC,EACpC,MAAiB;IAEjB,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,MAAM,CAAA;KACd;IACD,sEAAsE;IACtE,iBAAiB;IACjB,MAAM,CAAC,cAAc,GAAG,EAAE,CAAA;IAC1B,OAAO,0BAAK,CAAC,MAAM,EAAE,MAAM,CAAc,CAAA;AAC3C,CAAC;AAXD,wCAWC;AAED,SAAS,kBAAkB,CAAC,GAAmC;IAC7D,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QAC3B,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;KAC1B;IACD,OAAO,uDAAuD,MAAM,CAAC,IAAI,CACvE,GAAG,CACJ,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAA;AACxB,CAAC;AAEY,QAAA,eAAe,GAAiB,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;IACvD,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QAC1B,MAAM,IAAI,EAAE,CAAA;QACZ,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,IAAI,GAAG,CAAC,GAAG,EAAE;YAC3C,GAAG,CAAC,IAAI,IAAI,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;SACxC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
||||
20
node_modules/vite/dist/node/server/serverPluginVue.d.ts
generated
vendored
20
node_modules/vite/dist/node/server/serverPluginVue.d.ts
generated
vendored
@@ -1,20 +0,0 @@
|
||||
import { ServerPlugin } from '.';
|
||||
import { SFCDescriptor, SFCStyleCompileResults, BindingMetadata } from '@vue/compiler-sfc';
|
||||
import LRUCache from 'lru-cache';
|
||||
import { SourceMap } from './serverPluginSourceMap';
|
||||
export declare const srcImportMap: Map<any, any>;
|
||||
interface CacheEntry {
|
||||
descriptor?: SFCDescriptor;
|
||||
template?: ResultWithMap;
|
||||
script?: ResultWithMap;
|
||||
styles: SFCStyleCompileResults[];
|
||||
customs: string[];
|
||||
}
|
||||
interface ResultWithMap {
|
||||
code: string;
|
||||
map: SourceMap | null | undefined;
|
||||
bindings?: BindingMetadata;
|
||||
}
|
||||
export declare const vueCache: LRUCache<string, CacheEntry>;
|
||||
export declare const vuePlugin: ServerPlugin;
|
||||
export {};
|
||||
527
node_modules/vite/dist/node/server/serverPluginVue.js
generated
vendored
527
node_modules/vite/dist/node/server/serverPluginVue.js
generated
vendored
@@ -1,527 +0,0 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.vuePlugin = exports.vueCache = exports.srcImportMap = void 0;
|
||||
const querystring_1 = __importDefault(require("querystring"));
|
||||
const chalk_1 = __importDefault(require("chalk"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const compiler_sfc_1 = require("@vue/compiler-sfc");
|
||||
const resolveVue_1 = require("../utils/resolveVue");
|
||||
const hash_sum_1 = __importDefault(require("hash-sum"));
|
||||
const lru_cache_1 = __importDefault(require("lru-cache"));
|
||||
const serverPluginHmr_1 = require("./serverPluginHmr");
|
||||
const utils_1 = require("../utils");
|
||||
const esbuildService_1 = require("../esbuildService");
|
||||
const resolver_1 = require("../resolver");
|
||||
const serverPluginServeStatic_1 = require("./serverPluginServeStatic");
|
||||
const serverPluginCss_1 = require("./serverPluginCss");
|
||||
const cssUtils_1 = require("../utils/cssUtils");
|
||||
const serverPluginModuleRewrite_1 = require("./serverPluginModuleRewrite");
|
||||
const serverPluginSourceMap_1 = require("./serverPluginSourceMap");
|
||||
const debug = require('debug')('vite:sfc');
|
||||
const getEtag = require('etag');
|
||||
exports.srcImportMap = new Map();
|
||||
exports.vueCache = new lru_cache_1.default({
|
||||
max: 65535
|
||||
});
|
||||
exports.vuePlugin = ({ root, app, resolver, watcher, config }) => {
|
||||
const etagCacheCheck = (ctx) => {
|
||||
ctx.etag = getEtag(ctx.body);
|
||||
ctx.status =
|
||||
serverPluginServeStatic_1.seenUrls.has(ctx.url) && ctx.etag === ctx.get('If-None-Match') ? 304 : 200;
|
||||
serverPluginServeStatic_1.seenUrls.add(ctx.url);
|
||||
};
|
||||
app.use(async (ctx, next) => {
|
||||
// ctx.vue is set by other tools like vitepress so that vite knows to treat
|
||||
// non .vue files as vue files.
|
||||
if (!ctx.path.endsWith('.vue') && !ctx.vue) {
|
||||
return next();
|
||||
}
|
||||
const query = ctx.query;
|
||||
const publicPath = ctx.path;
|
||||
let filePath = resolver.requestToFile(publicPath);
|
||||
// upstream plugins could've already read the file
|
||||
const descriptor = await parseSFC(root, filePath, ctx.body);
|
||||
if (!descriptor) {
|
||||
return next();
|
||||
}
|
||||
if (!query.type) {
|
||||
// watch potentially out of root vue file since we do a custom read here
|
||||
utils_1.watchFileIfOutOfRoot(watcher, root, filePath);
|
||||
if (descriptor.script && descriptor.script.src) {
|
||||
filePath = await resolveSrcImport(root, descriptor.script, ctx, resolver);
|
||||
}
|
||||
ctx.type = 'js';
|
||||
const { code, map } = await compileSFCMain(descriptor, filePath, publicPath, root);
|
||||
ctx.body = code;
|
||||
ctx.map = map;
|
||||
return etagCacheCheck(ctx);
|
||||
}
|
||||
if (query.type === 'template') {
|
||||
const templateBlock = descriptor.template;
|
||||
if (templateBlock.src) {
|
||||
filePath = await resolveSrcImport(root, templateBlock, ctx, resolver);
|
||||
}
|
||||
ctx.type = 'js';
|
||||
const cached = exports.vueCache.get(filePath);
|
||||
const bindingMetadata = cached && cached.script && cached.script.bindings;
|
||||
const vueSpecifier = resolver_1.resolveBareModuleRequest(root, 'vue', publicPath, resolver);
|
||||
const { code, map } = compileSFCTemplate(root, templateBlock, filePath, publicPath, descriptor.styles.some((s) => s.scoped), bindingMetadata, vueSpecifier, config);
|
||||
ctx.body = code;
|
||||
ctx.map = map;
|
||||
return etagCacheCheck(ctx);
|
||||
}
|
||||
if (query.type === 'style') {
|
||||
const index = Number(query.index);
|
||||
const styleBlock = descriptor.styles[index];
|
||||
if (styleBlock.src) {
|
||||
filePath = await resolveSrcImport(root, styleBlock, ctx, resolver);
|
||||
}
|
||||
const id = hash_sum_1.default(publicPath);
|
||||
const result = await compileSFCStyle(root, styleBlock, index, filePath, publicPath, config);
|
||||
ctx.type = 'js';
|
||||
ctx.body = serverPluginCss_1.codegenCss(`${id}-${index}`, result.code, result.modules);
|
||||
return etagCacheCheck(ctx);
|
||||
}
|
||||
if (query.type === 'custom') {
|
||||
const index = Number(query.index);
|
||||
const customBlock = descriptor.customBlocks[index];
|
||||
if (customBlock.src) {
|
||||
filePath = await resolveSrcImport(root, customBlock, ctx, resolver);
|
||||
}
|
||||
const result = resolveCustomBlock(customBlock, index, filePath, publicPath);
|
||||
ctx.type = 'js';
|
||||
ctx.body = result;
|
||||
return etagCacheCheck(ctx);
|
||||
}
|
||||
});
|
||||
const handleVueReload = (watcher.handleVueReload = async (filePath, timestamp = Date.now(), content) => {
|
||||
const publicPath = resolver.fileToRequest(filePath);
|
||||
const cacheEntry = exports.vueCache.get(filePath);
|
||||
const { send } = watcher;
|
||||
serverPluginHmr_1.debugHmr(`busting Vue cache for ${filePath}`);
|
||||
exports.vueCache.del(filePath);
|
||||
const descriptor = await parseSFC(root, filePath, content);
|
||||
if (!descriptor) {
|
||||
// read failed
|
||||
return;
|
||||
}
|
||||
const prevDescriptor = cacheEntry && cacheEntry.descriptor;
|
||||
if (!prevDescriptor) {
|
||||
// the file has never been accessed yet
|
||||
serverPluginHmr_1.debugHmr(`no existing descriptor found for ${filePath}`);
|
||||
return;
|
||||
}
|
||||
// check which part of the file changed
|
||||
let needRerender = false;
|
||||
const sendReload = () => {
|
||||
send({
|
||||
type: 'vue-reload',
|
||||
path: publicPath,
|
||||
changeSrcPath: publicPath,
|
||||
timestamp
|
||||
});
|
||||
console.log(chalk_1.default.green(`[vite:hmr] `) +
|
||||
`${path_1.default.relative(root, filePath)} updated. (reload)`);
|
||||
};
|
||||
if (!isEqualBlock(descriptor.script, prevDescriptor.script) ||
|
||||
!isEqualBlock(descriptor.scriptSetup, prevDescriptor.scriptSetup)) {
|
||||
return sendReload();
|
||||
}
|
||||
if (!isEqualBlock(descriptor.template, prevDescriptor.template)) {
|
||||
// #748 should re-use previous cached script if only template change
|
||||
// so that the template is compiled with the correct binding metadata
|
||||
if (prevDescriptor.scriptSetup && descriptor.scriptSetup) {
|
||||
exports.vueCache.get(filePath).script = cacheEntry.script;
|
||||
}
|
||||
needRerender = true;
|
||||
}
|
||||
let didUpdateStyle = false;
|
||||
const styleId = hash_sum_1.default(publicPath);
|
||||
const prevStyles = prevDescriptor.styles || [];
|
||||
const nextStyles = descriptor.styles || [];
|
||||
// css modules update causes a reload because the $style object is changed
|
||||
// and it may be used in JS. It also needs to trigger a vue-style-update
|
||||
// event so the client busts the sw cache.
|
||||
if (prevStyles.some((s) => s.module != null) ||
|
||||
nextStyles.some((s) => s.module != null)) {
|
||||
return sendReload();
|
||||
}
|
||||
// force reload if CSS vars injection changed
|
||||
if (prevStyles.some((s, i) => {
|
||||
const next = nextStyles[i];
|
||||
if (s.attrs.vars && (!next || next.attrs.vars !== s.attrs.vars)) {
|
||||
return true;
|
||||
}
|
||||
})) {
|
||||
return sendReload();
|
||||
}
|
||||
// force reload if scoped status has changed
|
||||
if (prevStyles.some((s) => s.scoped) !== nextStyles.some((s) => s.scoped)) {
|
||||
return sendReload();
|
||||
}
|
||||
// only need to update styles if not reloading, since reload forces
|
||||
// style updates as well.
|
||||
nextStyles.forEach((_, i) => {
|
||||
if (!prevStyles[i] || !isEqualBlock(prevStyles[i], nextStyles[i])) {
|
||||
didUpdateStyle = true;
|
||||
const path = `${publicPath}?type=style&index=${i}`;
|
||||
send({
|
||||
type: 'style-update',
|
||||
path,
|
||||
changeSrcPath: path,
|
||||
timestamp
|
||||
});
|
||||
}
|
||||
});
|
||||
// stale styles always need to be removed
|
||||
prevStyles.slice(nextStyles.length).forEach((_, i) => {
|
||||
didUpdateStyle = true;
|
||||
send({
|
||||
type: 'style-remove',
|
||||
path: publicPath,
|
||||
id: `${styleId}-${i + nextStyles.length}`
|
||||
});
|
||||
});
|
||||
const prevCustoms = prevDescriptor.customBlocks || [];
|
||||
const nextCustoms = descriptor.customBlocks || [];
|
||||
// custom blocks update causes a reload
|
||||
// because the custom block contents is changed and it may be used in JS.
|
||||
if (nextCustoms.some((_, i) => !prevCustoms[i] || !isEqualBlock(prevCustoms[i], nextCustoms[i]))) {
|
||||
return sendReload();
|
||||
}
|
||||
if (needRerender) {
|
||||
send({
|
||||
type: 'vue-rerender',
|
||||
path: publicPath,
|
||||
changeSrcPath: publicPath,
|
||||
timestamp
|
||||
});
|
||||
}
|
||||
let updateType = [];
|
||||
if (needRerender) {
|
||||
updateType.push(`template`);
|
||||
}
|
||||
if (didUpdateStyle) {
|
||||
updateType.push(`style`);
|
||||
}
|
||||
if (updateType.length) {
|
||||
console.log(chalk_1.default.green(`[vite:hmr] `) +
|
||||
`${path_1.default.relative(root, filePath)} updated. (${updateType.join(' & ')})`);
|
||||
}
|
||||
});
|
||||
watcher.on('change', (file) => {
|
||||
if (file.endsWith('.vue')) {
|
||||
handleVueReload(file);
|
||||
}
|
||||
});
|
||||
};
|
||||
function isEqualBlock(a, b) {
|
||||
if (!a && !b)
|
||||
return true;
|
||||
if (!a || !b)
|
||||
return false;
|
||||
// src imports will trigger their own updates
|
||||
if (a.src && b.src && a.src === b.src)
|
||||
return true;
|
||||
if (a.content !== b.content)
|
||||
return false;
|
||||
const keysA = Object.keys(a.attrs);
|
||||
const keysB = Object.keys(b.attrs);
|
||||
if (keysA.length !== keysB.length) {
|
||||
return false;
|
||||
}
|
||||
return keysA.every((key) => a.attrs[key] === b.attrs[key]);
|
||||
}
|
||||
async function resolveSrcImport(root, block, ctx, resolver) {
|
||||
const importer = ctx.path;
|
||||
const importee = utils_1.cleanUrl(serverPluginModuleRewrite_1.resolveImport(root, importer, block.src, resolver));
|
||||
const filePath = resolver.requestToFile(importee);
|
||||
block.content = (await ctx.read(filePath)).toString();
|
||||
// register HMR import relationship
|
||||
serverPluginHmr_1.debugHmr(` ${importer} imports ${importee}`);
|
||||
serverPluginHmr_1.ensureMapEntry(serverPluginHmr_1.importerMap, importee).add(ctx.path);
|
||||
exports.srcImportMap.set(filePath, ctx.url);
|
||||
return filePath;
|
||||
}
|
||||
async function parseSFC(root, filePath, content) {
|
||||
let cached = exports.vueCache.get(filePath);
|
||||
if (cached && cached.descriptor) {
|
||||
debug(`${filePath} parse cache hit`);
|
||||
return cached.descriptor;
|
||||
}
|
||||
if (!content) {
|
||||
try {
|
||||
content = await utils_1.cachedRead(null, filePath);
|
||||
}
|
||||
catch (e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (typeof content !== 'string') {
|
||||
content = content.toString();
|
||||
}
|
||||
const start = Date.now();
|
||||
const { parse } = resolveVue_1.resolveCompiler(root);
|
||||
const { descriptor, errors } = parse(content, {
|
||||
filename: filePath,
|
||||
sourceMap: true
|
||||
});
|
||||
if (errors.length) {
|
||||
console.error(chalk_1.default.red(`\n[vite] SFC parse error: `));
|
||||
errors.forEach((e) => {
|
||||
logError(e, filePath, content);
|
||||
});
|
||||
}
|
||||
cached = cached || { styles: [], customs: [] };
|
||||
cached.descriptor = descriptor;
|
||||
exports.vueCache.set(filePath, cached);
|
||||
debug(`${filePath} parsed in ${Date.now() - start}ms.`);
|
||||
return descriptor;
|
||||
}
|
||||
async function compileSFCMain(descriptor, filePath, publicPath, root) {
|
||||
let cached = exports.vueCache.get(filePath);
|
||||
if (cached && cached.script) {
|
||||
return cached.script;
|
||||
}
|
||||
const id = hash_sum_1.default(publicPath);
|
||||
let code = ``;
|
||||
let content = ``;
|
||||
let map;
|
||||
let script = descriptor.script;
|
||||
const compiler = resolveVue_1.resolveCompiler(root);
|
||||
if ((descriptor.script || descriptor.scriptSetup) && compiler.compileScript) {
|
||||
try {
|
||||
script = compiler.compileScript(descriptor);
|
||||
}
|
||||
catch (e) {
|
||||
console.error(chalk_1.default.red(`\n[vite] SFC <script setup> compilation error:\n${chalk_1.default.dim(chalk_1.default.white(filePath))}`));
|
||||
console.error(chalk_1.default.yellow(e.message));
|
||||
}
|
||||
}
|
||||
if (script) {
|
||||
content = script.content;
|
||||
map = script.map;
|
||||
if (script.lang === 'ts') {
|
||||
const res = await esbuildService_1.transform(content, publicPath, {
|
||||
loader: 'ts'
|
||||
});
|
||||
content = res.code;
|
||||
map = serverPluginSourceMap_1.mergeSourceMap(map, JSON.parse(res.map));
|
||||
}
|
||||
}
|
||||
code += compiler_sfc_1.rewriteDefault(content, '__script');
|
||||
let hasScoped = false;
|
||||
let hasCSSModules = false;
|
||||
if (descriptor.styles) {
|
||||
descriptor.styles.forEach((s, i) => {
|
||||
const styleRequest = publicPath + `?type=style&index=${i}`;
|
||||
if (s.scoped)
|
||||
hasScoped = true;
|
||||
if (s.module) {
|
||||
if (!hasCSSModules) {
|
||||
code += `\nconst __cssModules = __script.__cssModules = {}`;
|
||||
hasCSSModules = true;
|
||||
}
|
||||
const styleVar = `__style${i}`;
|
||||
const moduleName = typeof s.module === 'string' ? s.module : '$style';
|
||||
code += `\nimport ${styleVar} from ${JSON.stringify(styleRequest + '&module')}`;
|
||||
code += `\n__cssModules[${JSON.stringify(moduleName)}] = ${styleVar}`;
|
||||
}
|
||||
else {
|
||||
code += `\nimport ${JSON.stringify(styleRequest)}`;
|
||||
}
|
||||
});
|
||||
if (hasScoped) {
|
||||
code += `\n__script.__scopeId = "data-v-${id}"`;
|
||||
}
|
||||
}
|
||||
if (descriptor.customBlocks) {
|
||||
descriptor.customBlocks.forEach((c, i) => {
|
||||
const attrsQuery = attrsToQuery(c.attrs, c.lang);
|
||||
const blockTypeQuery = `&blockType=${querystring_1.default.escape(c.type)}`;
|
||||
let customRequest = publicPath + `?type=custom&index=${i}${blockTypeQuery}${attrsQuery}`;
|
||||
const customVar = `block${i}`;
|
||||
code += `\nimport ${customVar} from ${JSON.stringify(customRequest)}\n`;
|
||||
code += `if (typeof ${customVar} === 'function') ${customVar}(__script)\n`;
|
||||
});
|
||||
}
|
||||
if (descriptor.template) {
|
||||
const templateRequest = publicPath + `?type=template`;
|
||||
code += `\nimport { render as __render } from ${JSON.stringify(templateRequest)}`;
|
||||
code += `\n__script.render = __render`;
|
||||
}
|
||||
code += `\n__script.__hmrId = ${JSON.stringify(publicPath)}`;
|
||||
code += `\ntypeof __VUE_HMR_RUNTIME__ !== 'undefined' && __VUE_HMR_RUNTIME__.createRecord(__script.__hmrId, __script)`;
|
||||
code += `\n__script.__file = ${JSON.stringify(filePath)}`;
|
||||
code += `\nexport default __script`;
|
||||
const result = {
|
||||
code,
|
||||
map,
|
||||
bindings: script ? script.bindings : undefined
|
||||
};
|
||||
cached = cached || { styles: [], customs: [] };
|
||||
cached.script = result;
|
||||
exports.vueCache.set(filePath, cached);
|
||||
return result;
|
||||
}
|
||||
function compileSFCTemplate(root, template, filePath, publicPath, scoped, bindingMetadata, vueSpecifier, { vueCompilerOptions, vueTransformAssetUrls = {}, vueTemplatePreprocessOptions = {} }) {
|
||||
let cached = exports.vueCache.get(filePath);
|
||||
if (cached && cached.template) {
|
||||
debug(`${publicPath} template cache hit`);
|
||||
return cached.template;
|
||||
}
|
||||
const start = Date.now();
|
||||
const { compileTemplate } = resolveVue_1.resolveCompiler(root);
|
||||
if (typeof vueTransformAssetUrls === 'object') {
|
||||
vueTransformAssetUrls = {
|
||||
base: path_1.default.posix.dirname(publicPath),
|
||||
...vueTransformAssetUrls
|
||||
};
|
||||
}
|
||||
const preprocessLang = template.lang;
|
||||
let preprocessOptions = preprocessLang && vueTemplatePreprocessOptions[preprocessLang];
|
||||
if (preprocessLang === 'pug') {
|
||||
preprocessOptions = {
|
||||
doctype: 'html',
|
||||
...preprocessOptions
|
||||
};
|
||||
}
|
||||
const { code, map, errors } = compileTemplate({
|
||||
source: template.content,
|
||||
filename: filePath,
|
||||
inMap: template.map,
|
||||
transformAssetUrls: vueTransformAssetUrls,
|
||||
compilerOptions: {
|
||||
...vueCompilerOptions,
|
||||
scopeId: scoped ? `data-v-${hash_sum_1.default(publicPath)}` : null,
|
||||
bindingMetadata,
|
||||
runtimeModuleName: vueSpecifier
|
||||
},
|
||||
preprocessLang,
|
||||
preprocessOptions,
|
||||
preprocessCustomRequire: (id) => require(utils_1.resolveFrom(root, id))
|
||||
});
|
||||
if (errors.length) {
|
||||
console.error(chalk_1.default.red(`\n[vite] SFC template compilation error: `));
|
||||
errors.forEach((e) => {
|
||||
if (typeof e === 'string') {
|
||||
console.error(e);
|
||||
}
|
||||
else {
|
||||
logError(e, filePath, template.map.sourcesContent[0]);
|
||||
}
|
||||
});
|
||||
}
|
||||
const result = {
|
||||
code,
|
||||
map: map
|
||||
};
|
||||
cached = cached || { styles: [], customs: [] };
|
||||
cached.template = result;
|
||||
exports.vueCache.set(filePath, cached);
|
||||
debug(`${publicPath} template compiled in ${Date.now() - start}ms.`);
|
||||
return result;
|
||||
}
|
||||
async function compileSFCStyle(root, style, index, filePath, publicPath, { cssPreprocessOptions, cssModuleOptions }) {
|
||||
let cached = exports.vueCache.get(filePath);
|
||||
const cachedEntry = cached && cached.styles && cached.styles[index];
|
||||
if (cachedEntry) {
|
||||
debug(`${publicPath} style cache hit`);
|
||||
return cachedEntry;
|
||||
}
|
||||
const start = Date.now();
|
||||
const { generateCodeFrame } = resolveVue_1.resolveCompiler(root);
|
||||
const resource = filePath + `?type=style&index=${index}`;
|
||||
const result = (await cssUtils_1.compileCss(root, publicPath, {
|
||||
source: style.content,
|
||||
filename: resource,
|
||||
id: ``,
|
||||
scoped: style.scoped != null,
|
||||
vars: style.vars != null,
|
||||
modules: style.module != null,
|
||||
preprocessLang: style.lang,
|
||||
preprocessOptions: cssPreprocessOptions,
|
||||
modulesOptions: cssModuleOptions
|
||||
}));
|
||||
cssUtils_1.recordCssImportChain(result.dependencies, resource);
|
||||
if (result.errors.length) {
|
||||
console.error(chalk_1.default.red(`\n[vite] SFC style compilation error: `));
|
||||
result.errors.forEach((e) => {
|
||||
if (typeof e === 'string') {
|
||||
console.error(e);
|
||||
}
|
||||
else {
|
||||
const lineOffset = style.loc.start.line - 1;
|
||||
if (e.line && e.column) {
|
||||
console.log(chalk_1.default.underline(`${filePath}:${e.line + lineOffset}:${e.column}`));
|
||||
}
|
||||
else {
|
||||
console.log(chalk_1.default.underline(filePath));
|
||||
}
|
||||
const filePathRE = new RegExp('.*' +
|
||||
path_1.default.basename(filePath).replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&') +
|
||||
'(:\\d+:\\d+:\\s*)?');
|
||||
const cleanMsg = e.message.replace(filePathRE, '');
|
||||
console.error(chalk_1.default.yellow(cleanMsg));
|
||||
if (e.line && e.column && cleanMsg.split(/\n/g).length === 1) {
|
||||
const original = style.map.sourcesContent[0];
|
||||
const offset = original
|
||||
.split(/\r?\n/g)
|
||||
.slice(0, e.line + lineOffset - 1)
|
||||
.map((l) => l.length)
|
||||
.reduce((total, l) => total + l + 1, 0) +
|
||||
e.column -
|
||||
1;
|
||||
console.error(generateCodeFrame(original, offset, offset + 1)) + `\n`;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
result.code = await cssUtils_1.rewriteCssUrls(result.code, publicPath);
|
||||
cached = cached || { styles: [], customs: [] };
|
||||
cached.styles[index] = result;
|
||||
exports.vueCache.set(filePath, cached);
|
||||
debug(`${publicPath} style compiled in ${Date.now() - start}ms`);
|
||||
return result;
|
||||
}
|
||||
function resolveCustomBlock(custom, index, filePath, publicPath) {
|
||||
let cached = exports.vueCache.get(filePath);
|
||||
const cachedEntry = cached && cached.customs && cached.customs[index];
|
||||
if (cachedEntry) {
|
||||
debug(`${publicPath} custom block cache hit`);
|
||||
return cachedEntry;
|
||||
}
|
||||
const result = custom.content;
|
||||
cached = cached || { styles: [], customs: [] };
|
||||
cached.customs[index] = result;
|
||||
exports.vueCache.set(filePath, cached);
|
||||
return result;
|
||||
}
|
||||
// these are built-in query parameters so should be ignored
|
||||
// if the user happen to add them as attrs
|
||||
const ignoreList = ['id', 'index', 'src', 'type'];
|
||||
function attrsToQuery(attrs, langFallback) {
|
||||
let query = ``;
|
||||
for (const name in attrs) {
|
||||
const value = attrs[name];
|
||||
if (!ignoreList.includes(name)) {
|
||||
query += `&${querystring_1.default.escape(name)}=${value ? querystring_1.default.escape(String(value)) : ``}`;
|
||||
}
|
||||
}
|
||||
if (langFallback && !(`lang` in attrs)) {
|
||||
query += `&lang=${langFallback}`;
|
||||
}
|
||||
return query;
|
||||
}
|
||||
function logError(e, file, src) {
|
||||
const locString = e.loc ? `:${e.loc.start.line}:${e.loc.start.column}` : ``;
|
||||
console.error(chalk_1.default.underline(file + locString));
|
||||
console.error(chalk_1.default.yellow(e.message));
|
||||
if (e.loc) {
|
||||
console.error(compiler_sfc_1.generateCodeFrame(src, e.loc.start.offset, e.loc.end.offset) + `\n`);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=serverPluginVue.js.map
|
||||
1
node_modules/vite/dist/node/server/serverPluginVue.js.map
generated
vendored
1
node_modules/vite/dist/node/server/serverPluginVue.js.map
generated
vendored
File diff suppressed because one or more lines are too long
2
node_modules/vite/dist/node/server/serverPluginWasm.d.ts
generated
vendored
2
node_modules/vite/dist/node/server/serverPluginWasm.d.ts
generated
vendored
@@ -1,2 +0,0 @@
|
||||
import { ServerPlugin } from '.';
|
||||
export declare const wasmPlugin: ServerPlugin;
|
||||
18
node_modules/vite/dist/node/server/serverPluginWasm.js
generated
vendored
18
node_modules/vite/dist/node/server/serverPluginWasm.js
generated
vendored
@@ -1,18 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.wasmPlugin = void 0;
|
||||
const utils_1 = require("../utils");
|
||||
exports.wasmPlugin = ({ app }) => {
|
||||
app.use((ctx, next) => {
|
||||
if (ctx.path.endsWith('.wasm') && utils_1.isImportRequest(ctx)) {
|
||||
ctx.type = 'js';
|
||||
ctx.body = `export default (opts = {}) => {
|
||||
return WebAssembly.instantiateStreaming(fetch(${JSON.stringify(ctx.path)}), opts)
|
||||
.then(obj => obj.instance.exports)
|
||||
}`;
|
||||
return;
|
||||
}
|
||||
return next();
|
||||
});
|
||||
};
|
||||
//# sourceMappingURL=serverPluginWasm.js.map
|
||||
1
node_modules/vite/dist/node/server/serverPluginWasm.js.map
generated
vendored
1
node_modules/vite/dist/node/server/serverPluginWasm.js.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"serverPluginWasm.js","sourceRoot":"","sources":["../../../src/node/server/serverPluginWasm.ts"],"names":[],"mappings":";;;AACA,oCAA0C;AAE7B,QAAA,UAAU,GAAiB,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;IAClD,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;QACpB,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,uBAAe,CAAC,GAAG,CAAC,EAAE;YACtD,GAAG,CAAC,IAAI,GAAG,IAAI,CAAA;YACf,GAAG,CAAC,IAAI,GAAG;wDACuC,IAAI,CAAC,SAAS,CAC5D,GAAG,CAAC,IAAI,CACT;;QAED,CAAA;YACF,OAAM;SACP;QACD,OAAO,IAAI,EAAE,CAAA;IACf,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
||||
2
node_modules/vite/dist/node/server/serverPluginWebWorker.d.ts
generated
vendored
2
node_modules/vite/dist/node/server/serverPluginWebWorker.d.ts
generated
vendored
@@ -1,2 +0,0 @@
|
||||
import { ServerPlugin } from '.';
|
||||
export declare const webWorkerPlugin: ServerPlugin;
|
||||
16
node_modules/vite/dist/node/server/serverPluginWebWorker.js
generated
vendored
16
node_modules/vite/dist/node/server/serverPluginWebWorker.js
generated
vendored
@@ -1,16 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.webWorkerPlugin = void 0;
|
||||
exports.webWorkerPlugin = ({ app }) => {
|
||||
app.use((ctx, next) => {
|
||||
if (ctx.query.worker != null) {
|
||||
ctx.type = 'js';
|
||||
ctx.body = `export default function WrappedWorker() {
|
||||
return new Worker(${JSON.stringify(ctx.path)}, { type: 'module' })
|
||||
}`;
|
||||
return;
|
||||
}
|
||||
return next();
|
||||
});
|
||||
};
|
||||
//# sourceMappingURL=serverPluginWebWorker.js.map
|
||||
1
node_modules/vite/dist/node/server/serverPluginWebWorker.js.map
generated
vendored
1
node_modules/vite/dist/node/server/serverPluginWebWorker.js.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"serverPluginWebWorker.js","sourceRoot":"","sources":["../../../src/node/server/serverPluginWebWorker.ts"],"names":[],"mappings":";;;AAEa,QAAA,eAAe,GAAiB,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;IACvD,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;QACpB,IAAI,GAAG,CAAC,KAAK,CAAC,MAAM,IAAI,IAAI,EAAE;YAC5B,GAAG,CAAC,IAAI,GAAG,IAAI,CAAA;YACf,GAAG,CAAC,IAAI,GAAG;4BACW,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC;QAC5C,CAAA;YACF,OAAM;SACP;QACD,OAAO,IAAI,EAAE,CAAA;IACf,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
||||
58
node_modules/vite/dist/node/transform.d.ts
generated
vendored
58
node_modules/vite/dist/node/transform.d.ts
generated
vendored
@@ -1,58 +0,0 @@
|
||||
import { ServerPlugin } from './server';
|
||||
import { Plugin as RollupPlugin } from 'rollup';
|
||||
import { SourceMap } from './server/serverPluginSourceMap';
|
||||
import { InternalResolver } from './resolver';
|
||||
declare type ParsedQuery = Record<string, string | string[] | undefined>;
|
||||
interface TransformTestContext {
|
||||
/**
|
||||
* Full specifier of the transformed module, including query parameters
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* Path without query (use this to check for file extensions)
|
||||
*/
|
||||
path: string;
|
||||
/**
|
||||
* Parsed query object
|
||||
*/
|
||||
query: ParsedQuery;
|
||||
/**
|
||||
* Indicates whether this is a request made by js import(), or natively by
|
||||
* the browser (e.g. `<img src="...">`).
|
||||
*/
|
||||
isImport: boolean;
|
||||
isBuild: boolean;
|
||||
/**
|
||||
* Indicates that the file for this request was not modified since last call.
|
||||
*/
|
||||
notModified?: true;
|
||||
}
|
||||
export interface TransformContext extends TransformTestContext {
|
||||
code: string;
|
||||
}
|
||||
export interface TransformResult {
|
||||
code: string;
|
||||
map?: SourceMap;
|
||||
}
|
||||
export declare type TransformFn = (ctx: TransformContext) => string | TransformResult | Promise<string | TransformResult>;
|
||||
export interface Transform {
|
||||
test: (ctx: TransformTestContext) => boolean;
|
||||
transform: TransformFn;
|
||||
}
|
||||
export interface IndexHtmlTransformContext {
|
||||
code: string;
|
||||
isBuild: boolean;
|
||||
}
|
||||
export declare type IndexHtmlTransformFn = (ctx: IndexHtmlTransformContext) => string | Promise<string>;
|
||||
export declare type IndexHtmlTransform = IndexHtmlTransformFn | {
|
||||
/**
|
||||
* Timing for applying the transform.
|
||||
* @default: 'post'
|
||||
*/
|
||||
apply?: 'pre' | 'post';
|
||||
transform: IndexHtmlTransformFn;
|
||||
};
|
||||
export declare type CustomBlockTransform = TransformFn;
|
||||
export declare function createServerTransformPlugin(transforms: Transform[], customBlockTransforms: Record<string, CustomBlockTransform>, resolver: InternalResolver): ServerPlugin;
|
||||
export declare function createBuildJsTransformPlugin(transforms: Transform[], customBlockTransforms: Record<string, CustomBlockTransform>): RollupPlugin;
|
||||
export {};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user