vite 5.4.0-beta.0 → 5.4.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-BuSuK4CE.js';
1
+ import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-gy9yrVx2.js';
2
2
  import require$$0__default from 'fs';
3
3
  import require$$0 from 'postcss';
4
4
  import require$$0$1 from 'path';
@@ -20428,7 +20428,7 @@ function fileToDevUrl(id, config) {
20428
20428
  } else {
20429
20429
  rtn = path$n.posix.join(FS_PREFIX, id);
20430
20430
  }
20431
- const base = joinUrlSegments(config.server?.origin ?? "", config.base);
20431
+ const base = joinUrlSegments(config.server?.origin ?? "", config.decodedBase);
20432
20432
  return joinUrlSegments(base, removeLeadingSlash(rtn));
20433
20433
  }
20434
20434
  function getPublicAssetFilename(hash, config) {
@@ -20438,7 +20438,7 @@ const publicAssetUrlCache = /* @__PURE__ */ new WeakMap();
20438
20438
  const publicAssetUrlRE = /__VITE_PUBLIC_ASSET__([a-z\d]{8})__/g;
20439
20439
  function publicFileToBuiltUrl(url, config) {
20440
20440
  if (config.command !== "build") {
20441
- return joinUrlSegments(config.base, url);
20441
+ return joinUrlSegments(config.decodedBase, url);
20442
20442
  }
20443
20443
  const hash = getHash(url);
20444
20444
  let cache = publicAssetUrlCache.get(config);
@@ -36988,8 +36988,8 @@ function createCachedImport(imp) {
36988
36988
  return cached;
36989
36989
  };
36990
36990
  }
36991
- const importPostcssImport = createCachedImport(() => import('./dep-C5hW-0CE.js').then(function (n) { return n.i; }));
36992
- const importPostcssModules = createCachedImport(() => import('./dep-AVIP6AlI.js').then(function (n) { return n.i; }));
36991
+ const importPostcssImport = createCachedImport(() => import('./dep-y7MNyJvV.js').then(function (n) { return n.i; }));
36992
+ const importPostcssModules = createCachedImport(() => import('./dep-Du4V_m3I.js').then(function (n) { return n.i; }));
36993
36993
  const importPostcss = createCachedImport(() => import('postcss'));
36994
36994
  const preprocessorWorkerControllerCache = /* @__PURE__ */ new WeakMap();
36995
36995
  let alwaysFakeWorkerWorkerControllerCache;
@@ -37296,6 +37296,19 @@ ${e.message}`
37296
37296
  }
37297
37297
  }
37298
37298
  }
37299
+ function loadSassPackage(root) {
37300
+ try {
37301
+ const path2 = loadPreprocessorPath("sass-embedded", root);
37302
+ return { name: "sass-embedded", path: path2 };
37303
+ } catch (e1) {
37304
+ try {
37305
+ const path2 = loadPreprocessorPath("sass" /* sass */, root);
37306
+ return { name: "sass", path: path2 };
37307
+ } catch (e2) {
37308
+ throw e1;
37309
+ }
37310
+ }
37311
+ }
37299
37312
  let cachedSss;
37300
37313
  function loadSss(root) {
37301
37314
  if (cachedSss) return cachedSss;
@@ -37410,18 +37423,18 @@ const makeModernScssWorker = (resolvers, alias, maxWorkers) => {
37410
37423
  () => async (sassPath, data, options) => {
37411
37424
  const sass = require(sassPath);
37412
37425
  const path2 = require("node:path");
37413
- const { fileURLToPath, pathToFileURL } = (
37426
+ const { fileURLToPath: fileURLToPath2, pathToFileURL: pathToFileURL2 } = (
37414
37427
  // eslint-disable-next-line no-restricted-globals
37415
37428
  require("node:url")
37416
37429
  );
37417
37430
  const sassOptions = { ...options };
37418
- sassOptions.url = pathToFileURL(options.filename);
37431
+ sassOptions.url = pathToFileURL2(options.filename);
37419
37432
  sassOptions.sourceMap = options.enableSourcemap;
37420
37433
  const internalImporter = {
37421
37434
  async canonicalize(url, context) {
37422
- const importer = context.containingUrl ? fileURLToPath(context.containingUrl) : options.filename;
37435
+ const importer = context.containingUrl ? fileURLToPath2(context.containingUrl) : options.filename;
37423
37436
  const resolved = await internalCanonicalize(url, importer);
37424
- return resolved ? pathToFileURL(resolved) : null;
37437
+ return resolved ? pathToFileURL2(resolved) : null;
37425
37438
  },
37426
37439
  async load(canonicalUrl) {
37427
37440
  const ext = path2.extname(canonicalUrl.pathname);
@@ -37432,7 +37445,7 @@ const makeModernScssWorker = (resolvers, alias, maxWorkers) => {
37432
37445
  syntax = "css";
37433
37446
  }
37434
37447
  const contents = await internalLoad(
37435
- fileURLToPath(canonicalUrl),
37448
+ fileURLToPath2(canonicalUrl),
37436
37449
  options.filename
37437
37450
  );
37438
37451
  return { contents, syntax };
@@ -37447,7 +37460,7 @@ const makeModernScssWorker = (resolvers, alias, maxWorkers) => {
37447
37460
  css: result.css,
37448
37461
  map: result.sourceMap ? JSON.stringify(result.sourceMap) : void 0,
37449
37462
  stats: {
37450
- includedFiles: result.loadedUrls.filter((url) => url.protocol === "file:").map((url) => fileURLToPath(url))
37463
+ includedFiles: result.loadedUrls.filter((url) => url.protocol === "file:").map((url) => fileURLToPath2(url))
37451
37464
  }
37452
37465
  };
37453
37466
  },
@@ -37464,6 +37477,60 @@ const makeModernScssWorker = (resolvers, alias, maxWorkers) => {
37464
37477
  );
37465
37478
  return worker;
37466
37479
  };
37480
+ const makeModernCompilerScssWorker = (resolvers, alias, _maxWorkers) => {
37481
+ let compiler;
37482
+ const worker = {
37483
+ async run(sassPath, data, options) {
37484
+ const sass = (await import(pathToFileURL(sassPath).href)).default;
37485
+ compiler ??= await sass.initAsyncCompiler();
37486
+ const sassOptions = { ...options };
37487
+ sassOptions.url = pathToFileURL(options.filename);
37488
+ sassOptions.sourceMap = options.enableSourcemap;
37489
+ const internalImporter = {
37490
+ async canonicalize(url, context) {
37491
+ const importer = context.containingUrl ? fileURLToPath(context.containingUrl) : options.filename;
37492
+ const resolved = await resolvers.sass(url, cleanScssBugUrl(importer));
37493
+ return resolved ? pathToFileURL(resolved) : null;
37494
+ },
37495
+ async load(canonicalUrl) {
37496
+ const ext = path$n.extname(canonicalUrl.pathname);
37497
+ let syntax = "scss";
37498
+ if (ext === ".sass") {
37499
+ syntax = "indented";
37500
+ } else if (ext === ".css") {
37501
+ syntax = "css";
37502
+ }
37503
+ const result2 = await rebaseUrls(
37504
+ fileURLToPath(canonicalUrl),
37505
+ options.filename,
37506
+ alias,
37507
+ "$",
37508
+ resolvers.sass
37509
+ );
37510
+ const contents = result2.contents ?? await fsp.readFile(result2.file, "utf-8");
37511
+ return { contents, syntax };
37512
+ }
37513
+ };
37514
+ sassOptions.importers = [
37515
+ ...sassOptions.importers ?? [],
37516
+ internalImporter
37517
+ ];
37518
+ const result = await compiler.compileStringAsync(data, sassOptions);
37519
+ return {
37520
+ css: result.css,
37521
+ map: result.sourceMap ? JSON.stringify(result.sourceMap) : void 0,
37522
+ stats: {
37523
+ includedFiles: result.loadedUrls.filter((url) => url.protocol === "file:").map((url) => fileURLToPath(url))
37524
+ }
37525
+ };
37526
+ },
37527
+ async stop() {
37528
+ compiler?.dispose();
37529
+ compiler = void 0;
37530
+ }
37531
+ };
37532
+ return worker;
37533
+ };
37467
37534
  const scssProcessor = (maxWorkers) => {
37468
37535
  const workerMap = /* @__PURE__ */ new Map();
37469
37536
  return {
@@ -37473,11 +37540,12 @@ const scssProcessor = (maxWorkers) => {
37473
37540
  }
37474
37541
  },
37475
37542
  async process(source, root, options, resolvers) {
37476
- const sassPath = loadPreprocessorPath("sass" /* sass */, root);
37543
+ const sassPackage = loadSassPackage(root);
37544
+ const api = options.api ?? "legacy";
37477
37545
  if (!workerMap.has(options.alias)) {
37478
37546
  workerMap.set(
37479
37547
  options.alias,
37480
- options.api === "modern" ? makeModernScssWorker(resolvers, options.alias, maxWorkers) : makeScssWorker(resolvers, options.alias, maxWorkers)
37548
+ api === "modern-compiler" ? makeModernCompilerScssWorker(resolvers, options.alias) : api === "modern" ? makeModernScssWorker(resolvers, options.alias, maxWorkers) : makeScssWorker(resolvers, options.alias, maxWorkers)
37481
37549
  );
37482
37550
  }
37483
37551
  const worker = workerMap.get(options.alias);
@@ -37493,7 +37561,7 @@ const scssProcessor = (maxWorkers) => {
37493
37561
  };
37494
37562
  try {
37495
37563
  const result = await worker.run(
37496
- sassPath,
37564
+ sassPackage.path,
37497
37565
  data,
37498
37566
  optionsWithoutAdditionalData
37499
37567
  );
@@ -45531,7 +45599,7 @@ const cachedFsUtilsMap = /* @__PURE__ */ new WeakMap();
45531
45599
  function getFsUtils(config) {
45532
45600
  let fsUtils = cachedFsUtilsMap.get(config);
45533
45601
  if (!fsUtils) {
45534
- if (config.command !== "serve" || config.server.fs.cachedChecks === false || config.server.watch?.ignored || process.versions.pnp) {
45602
+ if (config.command !== "serve" || config.server.fs.cachedChecks !== true || config.server.watch?.ignored || process.versions.pnp) {
45535
45603
  fsUtils = commonFsUtils;
45536
45604
  } else if (!config.resolve.preserveSymlinks && config.root !== getRealPath(config.root)) {
45537
45605
  fsUtils = commonFsUtils;
@@ -61890,7 +61958,12 @@ const processNodeUrl = (url, useSrcSetReplacer, config, htmlPath, originalUrl, s
61890
61958
  );
61891
61959
  }
61892
61960
  if (preTransformUrl) {
61893
- preTransformRequest(server, preTransformUrl, config.base);
61961
+ try {
61962
+ preTransformUrl = decodeURI(preTransformUrl);
61963
+ } catch (err) {
61964
+ return url2;
61965
+ }
61966
+ preTransformRequest(server, preTransformUrl, config.decodedBase);
61894
61967
  }
61895
61968
  }
61896
61969
  return url2;
@@ -61901,6 +61974,7 @@ const processNodeUrl = (url, useSrcSetReplacer, config, htmlPath, originalUrl, s
61901
61974
  const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl }) => {
61902
61975
  const { config, moduleGraph, watcher } = server;
61903
61976
  const base = config.base || "/";
61977
+ const decodedBase = config.decodedBase || "/";
61904
61978
  let proxyModulePath;
61905
61979
  let proxyModuleUrl;
61906
61980
  const trailingSlash = htmlPath.endsWith("/");
@@ -61912,7 +61986,7 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
61912
61986
  proxyModulePath = `\0${validPath}`;
61913
61987
  proxyModuleUrl = wrapId$1(proxyModulePath);
61914
61988
  }
61915
- proxyModuleUrl = joinUrlSegments(base, proxyModuleUrl);
61989
+ proxyModuleUrl = joinUrlSegments(decodedBase, proxyModuleUrl);
61916
61990
  const s = new MagicString(html);
61917
61991
  let inlineModuleIndex = -1;
61918
61992
  const proxyCacheUrl = decodeURI(
@@ -61944,7 +62018,7 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
61944
62018
  node.sourceCodeLocation.endOffset,
61945
62019
  `<script type="module" src="${modulePath}"><\/script>`
61946
62020
  );
61947
- preTransformRequest(server, modulePath, base);
62021
+ preTransformRequest(server, modulePath, decodedBase);
61948
62022
  };
61949
62023
  await traverseHtml(html, filename, (node) => {
61950
62024
  if (!nodeIsElement(node)) {
@@ -62106,14 +62180,10 @@ function indexHtmlMiddleware(root, server) {
62106
62180
  next();
62107
62181
  };
62108
62182
  }
62109
- function preTransformRequest(server, url, base) {
62183
+ function preTransformRequest(server, decodedUrl, decodedBase) {
62110
62184
  if (!server.config.server.preTransformRequests) return;
62111
- try {
62112
- url = unwrapId$1(stripBase(decodeURI(url), base));
62113
- } catch {
62114
- return;
62115
- }
62116
- server.warmupRequest(url);
62185
+ decodedUrl = unwrapId$1(stripBase(decodedUrl, decodedBase));
62186
+ server.warmupRequest(decodedUrl);
62117
62187
  }
62118
62188
 
62119
62189
  const logTime = createDebugger("vite:time");
@@ -65616,7 +65686,7 @@ function toOutputFilePathInJS(filename, type, hostId, hostType, config, toRelati
65616
65686
  if (relative && !config.build.ssr) {
65617
65687
  return toRelative(filename, hostId);
65618
65688
  }
65619
- return joinUrlSegments(config.base, filename);
65689
+ return joinUrlSegments(config.decodedBase, filename);
65620
65690
  }
65621
65691
  function createToImportMetaURLBasedRelativeRuntime(format, isWorker) {
65622
65692
  const formatLong = isWorker && format === "iife" ? "worker-iife" : format;
@@ -65653,7 +65723,7 @@ function toOutputFilePathWithoutRuntime(filename, type, hostId, hostType, config
65653
65723
  if (relative && !config.build.ssr) {
65654
65724
  return toRelative(filename, hostId);
65655
65725
  } else {
65656
- return joinUrlSegments(config.base, filename);
65726
+ return joinUrlSegments(config.decodedBase, filename);
65657
65727
  }
65658
65728
  }
65659
65729
  const toOutputFilePathInCss = toOutputFilePathWithoutRuntime;
@@ -66185,6 +66255,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
66185
66255
  plugins: createWorkerPlugins,
66186
66256
  rollupOptions: config.worker?.rollupOptions || {}
66187
66257
  };
66258
+ const base = withTrailingSlash(resolvedBase);
66188
66259
  resolved = {
66189
66260
  configFile: configFile ? normalizePath$3(configFile) : void 0,
66190
66261
  configFileDependencies: configFileDependencies.map(
@@ -66192,7 +66263,8 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
66192
66263
  ),
66193
66264
  inlineConfig,
66194
66265
  root: resolvedRoot,
66195
- base: withTrailingSlash(resolvedBase),
66266
+ base,
66267
+ decodedBase: decodeURI(base),
66196
66268
  rawBase: resolvedBase,
66197
66269
  resolve: resolveOptions,
66198
66270
  publicDir: resolvedPublicDir,
@@ -1,4 +1,4 @@
1
- import { B as getDefaultExportFromCjs } from './dep-BuSuK4CE.js';
1
+ import { B as getDefaultExportFromCjs } from './dep-gy9yrVx2.js';
2
2
  import require$$0 from 'path';
3
3
  import require$$0__default from 'fs';
4
4
  import { l as lib } from './dep-IQS-Za7F.js';
package/dist/node/cli.js CHANGED
@@ -2,7 +2,7 @@ import path from 'node:path';
2
2
  import fs__default from 'node:fs';
3
3
  import { performance } from 'node:perf_hooks';
4
4
  import { EventEmitter } from 'events';
5
- import { A as colors, v as createLogger, r as resolveConfig } from './chunks/dep-BuSuK4CE.js';
5
+ import { A as colors, v as createLogger, r as resolveConfig } from './chunks/dep-gy9yrVx2.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -730,7 +730,7 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
730
730
  `[boolean] force the optimizer to ignore the cache and re-bundle`
731
731
  ).action(async (root, options) => {
732
732
  filterDuplicateOptions(options);
733
- const { createServer } = await import('./chunks/dep-BuSuK4CE.js').then(function (n) { return n.E; });
733
+ const { createServer } = await import('./chunks/dep-gy9yrVx2.js').then(function (n) { return n.E; });
734
734
  try {
735
735
  const server = await createServer({
736
736
  root,
@@ -822,7 +822,7 @@ cli.command("build [root]", "build for production").option("--target <target>",
822
822
  `[boolean] force empty outDir when it's outside of root`
823
823
  ).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).action(async (root, options) => {
824
824
  filterDuplicateOptions(options);
825
- const { build } = await import('./chunks/dep-BuSuK4CE.js').then(function (n) { return n.F; });
825
+ const { build } = await import('./chunks/dep-gy9yrVx2.js').then(function (n) { return n.F; });
826
826
  const buildOptions = cleanOptions(options);
827
827
  try {
828
828
  await build({
@@ -851,7 +851,7 @@ cli.command("optimize [root]", "pre-bundle dependencies").option(
851
851
  ).action(
852
852
  async (root, options) => {
853
853
  filterDuplicateOptions(options);
854
- const { optimizeDeps } = await import('./chunks/dep-BuSuK4CE.js').then(function (n) { return n.D; });
854
+ const { optimizeDeps } = await import('./chunks/dep-gy9yrVx2.js').then(function (n) { return n.D; });
855
855
  try {
856
856
  const config = await resolveConfig(
857
857
  {
@@ -877,7 +877,7 @@ ${e.stack}`),
877
877
  cli.command("preview [root]", "locally preview production build").option("--host [host]", `[string] specify hostname`, { type: [convertHost] }).option("--port <port>", `[number] specify port`).option("--strictPort", `[boolean] exit if specified port is already in use`).option("--open [path]", `[boolean | string] open browser on startup`).option("--outDir <dir>", `[string] output directory (default: dist)`).action(
878
878
  async (root, options) => {
879
879
  filterDuplicateOptions(options);
880
- const { preview } = await import('./chunks/dep-BuSuK4CE.js').then(function (n) { return n.G; });
880
+ const { preview } = await import('./chunks/dep-gy9yrVx2.js').then(function (n) { return n.G; });
881
881
  try {
882
882
  const server = await preview({
883
883
  root,
@@ -1,6 +1,6 @@
1
1
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
- import { i as isInNodeModules, a as arraify } from './chunks/dep-BuSuK4CE.js';
3
- export { b as build, g as buildErrorMessage, k as createFilter, v as createLogger, c as createServer, d as defineConfig, h as fetchModule, f as formatPostcssSourceMap, x as isFileServingAllowed, l as loadConfigFromFile, y as loadEnv, j as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, e as preprocessCSS, p as preview, r as resolveConfig, z as resolveEnvPrefix, q as rollupVersion, w as searchForWorkspaceRoot, u as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-BuSuK4CE.js';
2
+ import { i as isInNodeModules, a as arraify } from './chunks/dep-gy9yrVx2.js';
3
+ export { b as build, g as buildErrorMessage, k as createFilter, v as createLogger, c as createServer, d as defineConfig, h as fetchModule, f as formatPostcssSourceMap, x as isFileServingAllowed, l as loadConfigFromFile, y as loadEnv, j as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, e as preprocessCSS, p as preview, r as resolveConfig, z as resolveEnvPrefix, q as rollupVersion, w as searchForWorkspaceRoot, u as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-gy9yrVx2.js';
4
4
  export { VERSION as version } from './constants.js';
5
5
  export { version as esbuildVersion } from 'esbuild';
6
6
  import { existsSync, readFileSync } from 'node:fs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "5.4.0-beta.0",
3
+ "version": "5.4.0-beta.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -129,6 +129,7 @@
129
129
  "rollup-plugin-esbuild": "^6.1.1",
130
130
  "rollup-plugin-license": "^3.5.2",
131
131
  "sass": "^1.77.8",
132
+ "sass-embedded": "^1.77.8",
132
133
  "sirv": "^2.0.4",
133
134
  "source-map-support": "^0.5.21",
134
135
  "strip-ansi": "^7.1.0",
@@ -144,6 +145,7 @@
144
145
  "less": "*",
145
146
  "lightningcss": "^1.21.0",
146
147
  "sass": "*",
148
+ "sass-embedded": "*",
147
149
  "stylus": "*",
148
150
  "sugarss": "*",
149
151
  "terser": "^5.4.0"
@@ -155,6 +157,9 @@
155
157
  "sass": {
156
158
  "optional": true
157
159
  },
160
+ "sass-embedded": {
161
+ "optional": true
162
+ },
158
163
  "stylus": {
159
164
  "optional": true
160
165
  },