vite 5.0.0-beta.6 → 5.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/client.mjs +17 -0
- package/dist/client/client.mjs.map +1 -1
- package/dist/node/chunks/{dep-db07a1ea.js → dep-7af400e9.js} +145 -86
- package/dist/node/chunks/{dep-ce41d4ea.js → dep-8648c2fe.js} +1 -1
- package/dist/node/chunks/{dep-c3c41c00.js → dep-cb981dcb.js} +1 -1
- package/dist/node/cli.js +5 -5
- package/dist/node/index.d.ts +3270 -3474
- package/dist/node/index.js +2 -2
- package/package.json +6 -9
- package/types/hot.d.ts +4 -0
|
@@ -28511,7 +28511,7 @@ const browserExternalId = '__vite-browser-external';
|
|
|
28511
28511
|
// special id for packages that are optional peer deps
|
|
28512
28512
|
const optionalPeerDepId = '__vite-optional-peer-dep';
|
|
28513
28513
|
const subpathImportsPrefix = '#';
|
|
28514
|
-
const startsWithWordCharRE = /^\w/;
|
|
28514
|
+
const startsWithWordCharRE$1 = /^\w/;
|
|
28515
28515
|
const debug$e = createDebugger('vite:resolve-details', {
|
|
28516
28516
|
onlyWhenFocused: true,
|
|
28517
28517
|
});
|
|
@@ -28603,7 +28603,7 @@ function resolvePlugin(resolveOptions) {
|
|
|
28603
28603
|
// relative
|
|
28604
28604
|
if (id[0] === '.' ||
|
|
28605
28605
|
((preferRelative || importer?.endsWith('.html')) &&
|
|
28606
|
-
startsWithWordCharRE.test(id))) {
|
|
28606
|
+
startsWithWordCharRE$1.test(id))) {
|
|
28607
28607
|
const basedir = importer ? path$o.dirname(importer) : process.cwd();
|
|
28608
28608
|
const fsPath = path$o.resolve(basedir, id);
|
|
28609
28609
|
// handle browser field mapping for relative imports
|
|
@@ -38053,7 +38053,7 @@ function buildHtmlPlugin(config) {
|
|
|
38053
38053
|
// newline trailing the previous node
|
|
38054
38054
|
const lineStartOffset = node.sourceCodeLocation.startOffset -
|
|
38055
38055
|
node.sourceCodeLocation.startCol;
|
|
38056
|
-
const line = s.slice(lineStartOffset, node.sourceCodeLocation.startOffset);
|
|
38056
|
+
const line = s.slice(Math.max(0, lineStartOffset), node.sourceCodeLocation.startOffset);
|
|
38057
38057
|
// <previous-line-node></previous-line-node>
|
|
38058
38058
|
// <target-node></target-node>
|
|
38059
38059
|
//
|
|
@@ -38127,21 +38127,7 @@ function buildHtmlPlugin(config) {
|
|
|
38127
38127
|
}
|
|
38128
38128
|
else if (node.childNodes.length) {
|
|
38129
38129
|
const scriptNode = node.childNodes.pop();
|
|
38130
|
-
|
|
38131
|
-
let match;
|
|
38132
|
-
inlineImportRE.lastIndex = 0;
|
|
38133
|
-
while ((match = inlineImportRE.exec(cleanCode))) {
|
|
38134
|
-
const { 1: url, index } = match;
|
|
38135
|
-
const startUrl = cleanCode.indexOf(url, index);
|
|
38136
|
-
const start = startUrl + 1;
|
|
38137
|
-
const end = start + url.length - 2;
|
|
38138
|
-
const startOffset = scriptNode.sourceCodeLocation.startOffset;
|
|
38139
|
-
scriptUrls.push({
|
|
38140
|
-
start: start + startOffset,
|
|
38141
|
-
end: end + startOffset,
|
|
38142
|
-
url: scriptNode.value.slice(start, end),
|
|
38143
|
-
});
|
|
38144
|
-
}
|
|
38130
|
+
scriptUrls.push(...extractImportExpressionFromClassicScript(scriptNode));
|
|
38145
38131
|
}
|
|
38146
38132
|
}
|
|
38147
38133
|
// For asset references in index.html, also generate an import
|
|
@@ -38182,26 +38168,19 @@ function buildHtmlPlugin(config) {
|
|
|
38182
38168
|
}
|
|
38183
38169
|
}
|
|
38184
38170
|
}
|
|
38185
|
-
|
|
38186
|
-
// extract inline styles as virtual css and add class attribute to tag for selecting
|
|
38187
|
-
const inlineStyle = node.attrs.find((prop) => prop.prefix === undefined &&
|
|
38188
|
-
prop.name === 'style' &&
|
|
38189
|
-
// only url(...) or image-set(...) in css need to emit file
|
|
38190
|
-
(prop.value.includes('url(') ||
|
|
38191
|
-
prop.value.includes('image-set(')));
|
|
38171
|
+
const inlineStyle = findNeedTransformStyleAttribute(node);
|
|
38192
38172
|
if (inlineStyle) {
|
|
38193
38173
|
inlineModuleIndex++;
|
|
38194
|
-
// replace `inline style`
|
|
38174
|
+
// replace `inline style` with __VITE_INLINE_CSS__**_**__
|
|
38195
38175
|
// and import css in js code
|
|
38196
|
-
const code = inlineStyle.value;
|
|
38176
|
+
const code = inlineStyle.attr.value;
|
|
38197
38177
|
const filePath = id.replace(normalizePath$3(config.root), '');
|
|
38198
38178
|
addToHTMLProxyCache(config, filePath, inlineModuleIndex, { code });
|
|
38199
38179
|
// will transform with css plugin and cache result with css-post plugin
|
|
38200
38180
|
js += `\nimport "${id}?html-proxy&inline-css&style-attr&index=${inlineModuleIndex}.css"`;
|
|
38201
38181
|
const hash = getHash(cleanUrl(id));
|
|
38202
38182
|
// will transform in `applyHtmlTransforms`
|
|
38203
|
-
|
|
38204
|
-
overwriteAttrValue(s, sourceCodeLocation, `__VITE_INLINE_CSS__${hash}_${inlineModuleIndex}__`);
|
|
38183
|
+
overwriteAttrValue(s, inlineStyle.location, `__VITE_INLINE_CSS__${hash}_${inlineModuleIndex}__`);
|
|
38205
38184
|
}
|
|
38206
38185
|
// <style>...</style>
|
|
38207
38186
|
if (node.nodeName === 'style' && node.childNodes.length) {
|
|
@@ -38460,6 +38439,37 @@ function buildHtmlPlugin(config) {
|
|
|
38460
38439
|
},
|
|
38461
38440
|
};
|
|
38462
38441
|
}
|
|
38442
|
+
// <tag style="... url(...) or image-set(...) ..."></tag>
|
|
38443
|
+
// extract inline styles as virtual css
|
|
38444
|
+
function findNeedTransformStyleAttribute(node) {
|
|
38445
|
+
const attr = node.attrs.find((prop) => prop.prefix === undefined &&
|
|
38446
|
+
prop.name === 'style' &&
|
|
38447
|
+
// only url(...) or image-set(...) in css need to emit file
|
|
38448
|
+
(prop.value.includes('url(') || prop.value.includes('image-set(')));
|
|
38449
|
+
if (!attr)
|
|
38450
|
+
return undefined;
|
|
38451
|
+
const location = node.sourceCodeLocation?.attrs?.['style'];
|
|
38452
|
+
return { attr, location };
|
|
38453
|
+
}
|
|
38454
|
+
function extractImportExpressionFromClassicScript(scriptTextNode) {
|
|
38455
|
+
const startOffset = scriptTextNode.sourceCodeLocation.startOffset;
|
|
38456
|
+
const cleanCode = stripLiteral(scriptTextNode.value);
|
|
38457
|
+
const scriptUrls = [];
|
|
38458
|
+
let match;
|
|
38459
|
+
inlineImportRE.lastIndex = 0;
|
|
38460
|
+
while ((match = inlineImportRE.exec(cleanCode))) {
|
|
38461
|
+
const { 1: url, index } = match;
|
|
38462
|
+
const startUrl = cleanCode.indexOf(url, index);
|
|
38463
|
+
const start = startUrl + 1;
|
|
38464
|
+
const end = start + url.length - 2;
|
|
38465
|
+
scriptUrls.push({
|
|
38466
|
+
start: start + startOffset,
|
|
38467
|
+
end: end + startOffset,
|
|
38468
|
+
url: scriptTextNode.value.slice(start, end),
|
|
38469
|
+
});
|
|
38470
|
+
}
|
|
38471
|
+
return scriptUrls;
|
|
38472
|
+
}
|
|
38463
38473
|
function preImportMapHook(config) {
|
|
38464
38474
|
return (html, ctx) => {
|
|
38465
38475
|
const importMapIndex = html.match(importMapRE)?.index;
|
|
@@ -38913,6 +38923,19 @@ function cssPostPlugin(config) {
|
|
|
38913
38923
|
return;
|
|
38914
38924
|
}
|
|
38915
38925
|
css = stripBomTag(css);
|
|
38926
|
+
// cache css compile result to map
|
|
38927
|
+
// and then use the cache replace inline-style-flag
|
|
38928
|
+
// when `generateBundle` in vite:build-html plugin and devHtmlHook
|
|
38929
|
+
const inlineCSS = inlineCSSRE.test(id);
|
|
38930
|
+
const isHTMLProxy = htmlProxyRE.test(id);
|
|
38931
|
+
if (inlineCSS && isHTMLProxy) {
|
|
38932
|
+
const query = parseRequest(id);
|
|
38933
|
+
if (styleAttrRE.test(id)) {
|
|
38934
|
+
css = css.replace(/"/g, '"');
|
|
38935
|
+
}
|
|
38936
|
+
addToHTMLProxyTransformResult(`${getHash(cleanUrl(id))}_${Number.parseInt(query.index)}`, css);
|
|
38937
|
+
return `export default ''`;
|
|
38938
|
+
}
|
|
38916
38939
|
const inlined = inlineRE.test(id);
|
|
38917
38940
|
const modules = cssModulesCache.get(config).get(id);
|
|
38918
38941
|
// #6984, #7552
|
|
@@ -38956,18 +38979,6 @@ function cssPostPlugin(config) {
|
|
|
38956
38979
|
}
|
|
38957
38980
|
// build CSS handling ----------------------------------------------------
|
|
38958
38981
|
// record css
|
|
38959
|
-
// cache css compile result to map
|
|
38960
|
-
// and then use the cache replace inline-style-flag when `generateBundle` in vite:build-html plugin
|
|
38961
|
-
const inlineCSS = inlineCSSRE.test(id);
|
|
38962
|
-
const isHTMLProxy = htmlProxyRE.test(id);
|
|
38963
|
-
const query = parseRequest(id);
|
|
38964
|
-
if (inlineCSS && isHTMLProxy) {
|
|
38965
|
-
if (styleAttrRE.test(id)) {
|
|
38966
|
-
css = css.replace(/"/g, '"');
|
|
38967
|
-
}
|
|
38968
|
-
addToHTMLProxyTransformResult(`${getHash(cleanUrl(id))}_${Number.parseInt(query.index)}`, css);
|
|
38969
|
-
return `export default ''`;
|
|
38970
|
-
}
|
|
38971
38982
|
if (!inlined) {
|
|
38972
38983
|
styles.set(id, css);
|
|
38973
38984
|
}
|
|
@@ -39528,8 +39539,8 @@ function createCachedImport(imp) {
|
|
|
39528
39539
|
return cached;
|
|
39529
39540
|
};
|
|
39530
39541
|
}
|
|
39531
|
-
const importPostcssImport = createCachedImport(() => import('./dep-
|
|
39532
|
-
const importPostcssModules = createCachedImport(() => import('./dep-
|
|
39542
|
+
const importPostcssImport = createCachedImport(() => import('./dep-8648c2fe.js').then(function (n) { return n.i; }));
|
|
39543
|
+
const importPostcssModules = createCachedImport(() => import('./dep-cb981dcb.js').then(function (n) { return n.i; }));
|
|
39533
39544
|
const importPostcss = createCachedImport(() => import('postcss'));
|
|
39534
39545
|
/**
|
|
39535
39546
|
* @experimental
|
|
@@ -42350,19 +42361,8 @@ function importAnalysisPlugin(config) {
|
|
|
42350
42361
|
[imports, exports] = parse$e(source);
|
|
42351
42362
|
}
|
|
42352
42363
|
catch (e) {
|
|
42353
|
-
const
|
|
42354
|
-
|
|
42355
|
-
const maybeJSX = !isVue && isJSRequest(importer);
|
|
42356
|
-
const msg = isVue
|
|
42357
|
-
? `Install @vitejs/plugin-vue to handle .vue files.`
|
|
42358
|
-
: maybeJSX
|
|
42359
|
-
? isJsx
|
|
42360
|
-
? `If you use tsconfig.json, make sure to not set jsx to preserve.`
|
|
42361
|
-
: `If you are using JSX, make sure to name the file with the .jsx or .tsx extension.`
|
|
42362
|
-
: `You may need to install appropriate plugins to handle the ${path$o.extname(importer)} file format, or if it's an asset, add "**/*${path$o.extname(importer)}" to \`assetsInclude\` in your configuration.`;
|
|
42363
|
-
this.error(`Failed to parse source for import analysis because the content ` +
|
|
42364
|
-
`contains invalid JS syntax. ` +
|
|
42365
|
-
msg, e.idx);
|
|
42364
|
+
const { message, showCodeFrame } = createParseErrorInfo(importer, source);
|
|
42365
|
+
this.error(message, showCodeFrame ? e.idx : undefined);
|
|
42366
42366
|
}
|
|
42367
42367
|
const depsOptimizer = getDepsOptimizer(config, ssr);
|
|
42368
42368
|
const { moduleGraph } = server;
|
|
@@ -42753,6 +42753,25 @@ function mergeAcceptedUrls(orderedUrls) {
|
|
|
42753
42753
|
}
|
|
42754
42754
|
return acceptedUrls;
|
|
42755
42755
|
}
|
|
42756
|
+
function createParseErrorInfo(importer, source) {
|
|
42757
|
+
const isVue = importer.endsWith('.vue');
|
|
42758
|
+
const isJsx = importer.endsWith('.jsx') || importer.endsWith('.tsx');
|
|
42759
|
+
const maybeJSX = !isVue && isJSRequest(importer);
|
|
42760
|
+
const probablyBinary = source.includes('\ufffd' /* unicode replacement character */);
|
|
42761
|
+
const msg = isVue
|
|
42762
|
+
? `Install @vitejs/plugin-vue to handle .vue files.`
|
|
42763
|
+
: maybeJSX
|
|
42764
|
+
? isJsx
|
|
42765
|
+
? `If you use tsconfig.json, make sure to not set jsx to preserve.`
|
|
42766
|
+
: `If you are using JSX, make sure to name the file with the .jsx or .tsx extension.`
|
|
42767
|
+
: `You may need to install appropriate plugins to handle the ${path$o.extname(importer)} file format, or if it's an asset, add "**/*${path$o.extname(importer)}" to \`assetsInclude\` in your configuration.`;
|
|
42768
|
+
return {
|
|
42769
|
+
message: `Failed to parse source for import analysis because the content ` +
|
|
42770
|
+
`contains invalid JS syntax. ` +
|
|
42771
|
+
msg,
|
|
42772
|
+
showCodeFrame: !probablyBinary,
|
|
42773
|
+
};
|
|
42774
|
+
}
|
|
42756
42775
|
function interopNamedImports(str, importSpecifier, rewrittenUrl, importIndex, importer, config) {
|
|
42757
42776
|
const source = str.original;
|
|
42758
42777
|
const { s: start, e: end, ss: expStart, se: expEnd, d: dynamicIndex, } = importSpecifier;
|
|
@@ -47297,7 +47316,8 @@ function buildImportAnalysisPlugin(config) {
|
|
|
47297
47316
|
imports = parse$e(source)[0];
|
|
47298
47317
|
}
|
|
47299
47318
|
catch (e) {
|
|
47300
|
-
|
|
47319
|
+
const { message, showCodeFrame } = createParseErrorInfo(importer, source);
|
|
47320
|
+
this.error(message, showCodeFrame ? e.idx : undefined);
|
|
47301
47321
|
}
|
|
47302
47322
|
if (!imports.length) {
|
|
47303
47323
|
return null;
|
|
@@ -64947,7 +64967,8 @@ function proxyMiddleware(httpServer, options, config) {
|
|
|
64947
64967
|
}
|
|
64948
64968
|
else if (bypassResult === false) {
|
|
64949
64969
|
debug$1?.(`bypass: ${req.url} -> 404`);
|
|
64950
|
-
|
|
64970
|
+
res.statusCode = 404;
|
|
64971
|
+
return res.end();
|
|
64951
64972
|
}
|
|
64952
64973
|
}
|
|
64953
64974
|
debug$1?.(`${req.url} -> ${opts.target || opts.forward}`);
|
|
@@ -65352,8 +65373,9 @@ function getHtmlFilename(url, server) {
|
|
|
65352
65373
|
function shouldPreTransform(url, config) {
|
|
65353
65374
|
return (!checkPublicFile(url, config) && (isJSRequest(url) || isCSSRequest(url)));
|
|
65354
65375
|
}
|
|
65355
|
-
const
|
|
65356
|
-
|
|
65376
|
+
const startsWithWordCharRE = /^\w/;
|
|
65377
|
+
const isSrcSet = (attr) => attr.name === 'srcset' && attr.prefix === undefined;
|
|
65378
|
+
const processNodeUrl = (url, useSrcSetReplacer, config, htmlPath, originalUrl, server) => {
|
|
65357
65379
|
if (server?.moduleGraph) {
|
|
65358
65380
|
const mod = server.moduleGraph.urlToModuleMap.get(url);
|
|
65359
65381
|
if (mod && mod.lastHMRTimestamp > 0) {
|
|
@@ -65364,12 +65386,12 @@ const processNodeUrl = (attr, sourceCodeLocation, s, config, htmlPath, originalU
|
|
|
65364
65386
|
if (url[0] === '/' && url[1] !== '/') {
|
|
65365
65387
|
// prefix with base (dev only, base is never relative)
|
|
65366
65388
|
const fullUrl = path$o.posix.join(devBase, url);
|
|
65367
|
-
overwriteAttrValue(s, sourceCodeLocation, fullUrl);
|
|
65368
65389
|
if (server && shouldPreTransform(url, config)) {
|
|
65369
65390
|
preTransformRequest(server, fullUrl, devBase);
|
|
65370
65391
|
}
|
|
65392
|
+
return fullUrl;
|
|
65371
65393
|
}
|
|
65372
|
-
else if (url[0] === '.' &&
|
|
65394
|
+
else if ((url[0] === '.' || startsWithWordCharRE.test(url)) &&
|
|
65373
65395
|
originalUrl &&
|
|
65374
65396
|
originalUrl !== '/' &&
|
|
65375
65397
|
htmlPath === '/index.html') {
|
|
@@ -65385,10 +65407,10 @@ const processNodeUrl = (attr, sourceCodeLocation, s, config, htmlPath, originalU
|
|
|
65385
65407
|
// path will add `/a/` prefix, it will caused 404.
|
|
65386
65408
|
// rewrite before `./index.js` -> `localhost:5173/a/index.js`.
|
|
65387
65409
|
// rewrite after `../index.js` -> `localhost:5173/index.js`.
|
|
65388
|
-
const processedUrl =
|
|
65410
|
+
const processedUrl = useSrcSetReplacer
|
|
65389
65411
|
? processSrcSetSync(url, ({ url }) => replacer(url))
|
|
65390
65412
|
: replacer(url);
|
|
65391
|
-
|
|
65413
|
+
return processedUrl;
|
|
65392
65414
|
}
|
|
65393
65415
|
};
|
|
65394
65416
|
const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl }) => {
|
|
@@ -65416,6 +65438,7 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
|
|
|
65416
65438
|
let inlineModuleIndex = -1;
|
|
65417
65439
|
const proxyCacheUrl = cleanUrl(proxyModulePath).replace(normalizePath$3(config.root), '');
|
|
65418
65440
|
const styleUrl = [];
|
|
65441
|
+
const inlineStyles = [];
|
|
65419
65442
|
const addInlineModule = (node, ext) => {
|
|
65420
65443
|
inlineModuleIndex++;
|
|
65421
65444
|
const contentNode = node.childNodes[0];
|
|
@@ -65448,11 +65471,32 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
|
|
|
65448
65471
|
if (node.nodeName === 'script') {
|
|
65449
65472
|
const { src, sourceCodeLocation, isModule } = getScriptInfo(node);
|
|
65450
65473
|
if (src) {
|
|
65451
|
-
processNodeUrl(src,
|
|
65474
|
+
const processedUrl = processNodeUrl(src.value, isSrcSet(src), config, htmlPath, originalUrl, server);
|
|
65475
|
+
if (processedUrl) {
|
|
65476
|
+
overwriteAttrValue(s, sourceCodeLocation, processedUrl);
|
|
65477
|
+
}
|
|
65452
65478
|
}
|
|
65453
65479
|
else if (isModule && node.childNodes.length) {
|
|
65454
65480
|
addInlineModule(node, 'js');
|
|
65455
65481
|
}
|
|
65482
|
+
else if (node.childNodes.length) {
|
|
65483
|
+
const scriptNode = node.childNodes[node.childNodes.length - 1];
|
|
65484
|
+
for (const { url, start, end, } of extractImportExpressionFromClassicScript(scriptNode)) {
|
|
65485
|
+
const processedUrl = processNodeUrl(url, false, config, htmlPath, originalUrl);
|
|
65486
|
+
if (processedUrl) {
|
|
65487
|
+
s.update(start, end, processedUrl);
|
|
65488
|
+
}
|
|
65489
|
+
}
|
|
65490
|
+
}
|
|
65491
|
+
}
|
|
65492
|
+
const inlineStyle = findNeedTransformStyleAttribute(node);
|
|
65493
|
+
if (inlineStyle) {
|
|
65494
|
+
inlineModuleIndex++;
|
|
65495
|
+
inlineStyles.push({
|
|
65496
|
+
index: inlineModuleIndex,
|
|
65497
|
+
location: inlineStyle.location,
|
|
65498
|
+
code: inlineStyle.attr.value,
|
|
65499
|
+
});
|
|
65456
65500
|
}
|
|
65457
65501
|
if (node.nodeName === 'style' && node.childNodes.length) {
|
|
65458
65502
|
const children = node.childNodes[0];
|
|
@@ -65468,31 +65512,46 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
|
|
|
65468
65512
|
for (const p of node.attrs) {
|
|
65469
65513
|
const attrKey = getAttrKey(p);
|
|
65470
65514
|
if (p.value && assetAttrs.includes(attrKey)) {
|
|
65471
|
-
processNodeUrl(p
|
|
65515
|
+
const processedUrl = processNodeUrl(p.value, isSrcSet(p), config, htmlPath, originalUrl);
|
|
65516
|
+
if (processedUrl) {
|
|
65517
|
+
overwriteAttrValue(s, node.sourceCodeLocation.attrs[attrKey], processedUrl);
|
|
65518
|
+
}
|
|
65472
65519
|
}
|
|
65473
65520
|
}
|
|
65474
65521
|
}
|
|
65475
65522
|
});
|
|
65476
|
-
await Promise.all(
|
|
65477
|
-
|
|
65478
|
-
|
|
65479
|
-
|
|
65480
|
-
|
|
65481
|
-
|
|
65482
|
-
|
|
65483
|
-
|
|
65484
|
-
if (result
|
|
65485
|
-
if (result.map.
|
|
65486
|
-
|
|
65523
|
+
await Promise.all([
|
|
65524
|
+
...styleUrl.map(async ({ start, end, code }, index) => {
|
|
65525
|
+
const url = `${proxyModulePath}?html-proxy&direct&index=${index}.css`;
|
|
65526
|
+
// ensure module in graph after successful load
|
|
65527
|
+
const mod = await moduleGraph.ensureEntryFromUrl(url, false);
|
|
65528
|
+
ensureWatchedFile(watcher, mod.file, config.root);
|
|
65529
|
+
const result = await server.pluginContainer.transform(code, mod.id);
|
|
65530
|
+
let content = '';
|
|
65531
|
+
if (result) {
|
|
65532
|
+
if (result.map && 'version' in result.map) {
|
|
65533
|
+
if (result.map.mappings) {
|
|
65534
|
+
await injectSourcesContent(result.map, proxyModulePath, config.logger);
|
|
65535
|
+
}
|
|
65536
|
+
content = getCodeWithSourcemap('css', result.code, result.map);
|
|
65537
|
+
}
|
|
65538
|
+
else {
|
|
65539
|
+
content = result.code;
|
|
65487
65540
|
}
|
|
65488
|
-
content = getCodeWithSourcemap('css', result.code, result.map);
|
|
65489
|
-
}
|
|
65490
|
-
else {
|
|
65491
|
-
content = result.code;
|
|
65492
65541
|
}
|
|
65493
|
-
|
|
65494
|
-
|
|
65495
|
-
|
|
65542
|
+
s.overwrite(start, end, content);
|
|
65543
|
+
}),
|
|
65544
|
+
...inlineStyles.map(async ({ index, location, code }) => {
|
|
65545
|
+
// will transform with css plugin and cache result with css-post plugin
|
|
65546
|
+
const url = `${proxyModulePath}?html-proxy&inline-css&style-attr&index=${index}.css`;
|
|
65547
|
+
const mod = await moduleGraph.ensureEntryFromUrl(url, false);
|
|
65548
|
+
ensureWatchedFile(watcher, mod.file, config.root);
|
|
65549
|
+
await server?.pluginContainer.transform(code, mod.id);
|
|
65550
|
+
const hash = getHash(cleanUrl(mod.id));
|
|
65551
|
+
const result = htmlProxyResult.get(`${hash}_${index}`);
|
|
65552
|
+
overwriteAttrValue(s, location, result ?? '');
|
|
65553
|
+
}),
|
|
65554
|
+
]);
|
|
65496
65555
|
html = s.toString();
|
|
65497
65556
|
return {
|
|
65498
65557
|
html,
|
|
@@ -66918,8 +66977,8 @@ assetFileNames isn't equal for every build.rollupOptions.output. A single patter
|
|
|
66918
66977
|
*/
|
|
66919
66978
|
function resolveBaseUrl(base = '/', isBuild, logger) {
|
|
66920
66979
|
if (base[0] === '.') {
|
|
66921
|
-
logger.warn(colors$1.yellow(colors$1.bold(`(!) invalid "base" option: ${base}. The value can only be an absolute ` +
|
|
66922
|
-
`URL,
|
|
66980
|
+
logger.warn(colors$1.yellow(colors$1.bold(`(!) invalid "base" option: "${base}". The value can only be an absolute ` +
|
|
66981
|
+
`URL, "./", or an empty string.`)));
|
|
66923
66982
|
return '/';
|
|
66924
66983
|
}
|
|
66925
66984
|
// external URL flag
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as commonjsGlobal, D as getDefaultExportFromCjs } from './dep-
|
|
1
|
+
import { E as commonjsGlobal, D as getDefaultExportFromCjs } from './dep-7af400e9.js';
|
|
2
2
|
import require$$0__default from 'fs';
|
|
3
3
|
import require$$0 from 'postcss';
|
|
4
4
|
import require$$0$1 from 'path';
|
package/dist/node/cli.js
CHANGED
|
@@ -2,7 +2,7 @@ import path from 'node:path';
|
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import { performance } from 'node:perf_hooks';
|
|
4
4
|
import { EventEmitter } from 'events';
|
|
5
|
-
import { C as colors, x as createLogger, h as resolveConfig } from './chunks/dep-
|
|
5
|
+
import { C as colors, x as createLogger, h as resolveConfig } from './chunks/dep-7af400e9.js';
|
|
6
6
|
import { VERSION } from './constants.js';
|
|
7
7
|
import 'node:fs/promises';
|
|
8
8
|
import 'node:url';
|
|
@@ -759,7 +759,7 @@ cli
|
|
|
759
759
|
filterDuplicateOptions(options);
|
|
760
760
|
// output structure is preserved even after bundling so require()
|
|
761
761
|
// is ok here
|
|
762
|
-
const { createServer } = await import('./chunks/dep-
|
|
762
|
+
const { createServer } = await import('./chunks/dep-7af400e9.js').then(function (n) { return n.H; });
|
|
763
763
|
try {
|
|
764
764
|
const server = await createServer({
|
|
765
765
|
root,
|
|
@@ -840,7 +840,7 @@ cli
|
|
|
840
840
|
.option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
|
|
841
841
|
.action(async (root, options) => {
|
|
842
842
|
filterDuplicateOptions(options);
|
|
843
|
-
const { build } = await import('./chunks/dep-
|
|
843
|
+
const { build } = await import('./chunks/dep-7af400e9.js').then(function (n) { return n.G; });
|
|
844
844
|
const buildOptions = cleanOptions(options);
|
|
845
845
|
try {
|
|
846
846
|
await build({
|
|
@@ -868,7 +868,7 @@ cli
|
|
|
868
868
|
.option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
|
|
869
869
|
.action(async (root, options) => {
|
|
870
870
|
filterDuplicateOptions(options);
|
|
871
|
-
const { optimizeDeps } = await import('./chunks/dep-
|
|
871
|
+
const { optimizeDeps } = await import('./chunks/dep-7af400e9.js').then(function (n) { return n.F; });
|
|
872
872
|
try {
|
|
873
873
|
const config = await resolveConfig({
|
|
874
874
|
root,
|
|
@@ -895,7 +895,7 @@ cli
|
|
|
895
895
|
.option('--outDir <dir>', `[string] output directory (default: dist)`)
|
|
896
896
|
.action(async (root, options) => {
|
|
897
897
|
filterDuplicateOptions(options);
|
|
898
|
-
const { preview } = await import('./chunks/dep-
|
|
898
|
+
const { preview } = await import('./chunks/dep-7af400e9.js').then(function (n) { return n.I; });
|
|
899
899
|
try {
|
|
900
900
|
const server = await preview({
|
|
901
901
|
root,
|