vite 2.9.13 → 2.9.14

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.

Potentially problematic release.


This version of vite might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./dep-80fe9c6b.js');
3
+ var index = require('./dep-c9998dc6.js');
4
4
 
5
5
  function _mergeNamespaces(n, m) {
6
6
  for (var i = 0; i < m.length; i++) {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./dep-80fe9c6b.js');
3
+ var index = require('./dep-c9998dc6.js');
4
4
  var require$$1 = require('crypto');
5
5
  require('fs');
6
6
  require('path');
@@ -22715,239 +22715,6 @@ const JSON5 = {
22715
22715
 
22716
22716
  var lib$2 = JSON5;
22717
22717
 
22718
- function formatGlobRelativePattern(base, pattern) {
22719
- let parentDepth = 0;
22720
- while (pattern.startsWith('../')) {
22721
- pattern = pattern.slice(3);
22722
- base = path__default.resolve(base, '../');
22723
- parentDepth++;
22724
- }
22725
- if (pattern.startsWith('./')) {
22726
- pattern = pattern.slice(2);
22727
- }
22728
- return { base, pattern, parentDepth, isAbsolute: false };
22729
- }
22730
- async function transformImportGlob(source, pos, importer, importIndex, root, logger, normalizeUrl, resolve, preload = true) {
22731
- var _a;
22732
- const isEager = source.slice(pos, pos + 21) === 'import.meta.globEager';
22733
- const isEagerDefault = isEager && source.slice(pos + 21, pos + 28) === 'Default';
22734
- const err = (msg) => {
22735
- const e = new Error(`Invalid glob import syntax: ${msg}`);
22736
- e.pos = pos;
22737
- return e;
22738
- };
22739
- importer = cleanUrl(importer);
22740
- const importerBasename = path__default.basename(importer);
22741
- const [userPattern, options, endIndex] = lexGlobPattern(source, pos);
22742
- let globParams = null;
22743
- if (userPattern.startsWith('/')) {
22744
- globParams = {
22745
- isAbsolute: true,
22746
- base: path__default.resolve(root),
22747
- pattern: userPattern.slice(1),
22748
- parentDepth: 0
22749
- };
22750
- }
22751
- else if (userPattern.startsWith('.')) {
22752
- globParams = formatGlobRelativePattern(path__default.dirname(importer), userPattern);
22753
- }
22754
- else if (resolve) {
22755
- const resolvedId = await resolve(userPattern, importer);
22756
- if (resolvedId) {
22757
- const importerDirname = path__default.dirname(importer);
22758
- globParams = formatGlobRelativePattern(importerDirname, normalizePath$3(path__default.relative(importerDirname, resolvedId)));
22759
- }
22760
- }
22761
- if (!globParams) {
22762
- throw err(`pattern must start with "." or "/" (relative to project root) or alias path`);
22763
- }
22764
- const { base, parentDepth, isAbsolute, pattern } = globParams;
22765
- const files = out.sync(pattern, {
22766
- cwd: base,
22767
- // Ignore node_modules by default unless explicitly indicated in the pattern
22768
- ignore: /(^|\/)node_modules\//.test(pattern) ? [] : ['**/node_modules/**']
22769
- });
22770
- const imports = [];
22771
- let importsString = ``;
22772
- let entries = ``;
22773
- for (let i = 0; i < files.length; i++) {
22774
- // skip importer itself
22775
- if (files[i] === importerBasename)
22776
- continue;
22777
- const file = isAbsolute
22778
- ? `/${files[i]}`
22779
- : parentDepth
22780
- ? `${'../'.repeat(parentDepth)}${files[i]}`
22781
- : `./${files[i]}`;
22782
- let importee = file;
22783
- if (normalizeUrl) {
22784
- [importee] = await normalizeUrl(file, pos);
22785
- }
22786
- imports.push(importee);
22787
- // TODO remove assert syntax for the Vite 3.0 release.
22788
- const isRawAssert = ((_a = options === null || options === void 0 ? void 0 : options.assert) === null || _a === void 0 ? void 0 : _a.type) === 'raw';
22789
- const isRawType = (options === null || options === void 0 ? void 0 : options.as) === 'raw';
22790
- if (isRawType || isRawAssert) {
22791
- if (isRawAssert) {
22792
- logger.warn(colors$1.yellow(colors$1.bold("(!) import.meta.glob('...', { assert: { type: 'raw' }}) is deprecated. Use import.meta.glob('...', { as: 'raw' }) instead.")));
22793
- }
22794
- entries += ` ${JSON.stringify(file)}: ${JSON.stringify(await fs$n.promises.readFile(path__default.join(base, files[i]), 'utf-8'))},`;
22795
- }
22796
- else {
22797
- if (isEager) {
22798
- const identifier = `__glob_${importIndex}_${i}`;
22799
- importsString += `import ${isEagerDefault ? `` : `* as `}${identifier} from ${JSON.stringify(importee)};`;
22800
- entries += ` ${JSON.stringify(file)}: ${identifier},`;
22801
- }
22802
- else {
22803
- let imp = `import(${JSON.stringify(importee)})`;
22804
- if (!normalizeUrl && preload) {
22805
- imp =
22806
- `(${isModernFlag}` +
22807
- `? ${preloadMethod}(()=>${imp},"${preloadMarker}")` +
22808
- `: ${imp})`;
22809
- }
22810
- entries += ` ${JSON.stringify(file)}: () => ${imp},`;
22811
- }
22812
- }
22813
- }
22814
- return {
22815
- imports,
22816
- importsString,
22817
- exp: `{${entries}}`,
22818
- endIndex,
22819
- isEager,
22820
- pattern,
22821
- base
22822
- };
22823
- }
22824
- function lexGlobPattern(code, pos) {
22825
- let state = 0 /* inCall */;
22826
- let pattern = '';
22827
- let i = code.indexOf(`(`, pos) + 1;
22828
- outer: for (; i < code.length; i++) {
22829
- const char = code.charAt(i);
22830
- switch (state) {
22831
- case 0 /* inCall */:
22832
- if (char === `'`) {
22833
- state = 1 /* inSingleQuoteString */;
22834
- }
22835
- else if (char === `"`) {
22836
- state = 2 /* inDoubleQuoteString */;
22837
- }
22838
- else if (char === '`') {
22839
- state = 3 /* inTemplateString */;
22840
- }
22841
- else if (/\s/.test(char)) {
22842
- continue;
22843
- }
22844
- else {
22845
- error$2(i);
22846
- }
22847
- break;
22848
- case 1 /* inSingleQuoteString */:
22849
- if (char === `'`) {
22850
- break outer;
22851
- }
22852
- else {
22853
- pattern += char;
22854
- }
22855
- break;
22856
- case 2 /* inDoubleQuoteString */:
22857
- if (char === `"`) {
22858
- break outer;
22859
- }
22860
- else {
22861
- pattern += char;
22862
- }
22863
- break;
22864
- case 3 /* inTemplateString */:
22865
- if (char === '`') {
22866
- break outer;
22867
- }
22868
- else {
22869
- pattern += char;
22870
- }
22871
- break;
22872
- default:
22873
- throw new Error('unknown import.meta.glob lexer state');
22874
- }
22875
- }
22876
- const noCommentCode = code
22877
- .slice(i + 1)
22878
- .replace(singlelineCommentsRE, blankReplacer)
22879
- .replace(multilineCommentsRE, blankReplacer);
22880
- const endIndex = noCommentCode.indexOf(')');
22881
- const optionString = noCommentCode.substring(0, endIndex);
22882
- const commaIndex = optionString.indexOf(',');
22883
- let options = {};
22884
- if (commaIndex > -1) {
22885
- options = lib$2.parse(optionString.substring(commaIndex + 1));
22886
- }
22887
- return [pattern, options, endIndex + i + 2];
22888
- }
22889
- function error$2(pos) {
22890
- const err = new Error(`import.meta.glob() can only accept string literals.`);
22891
- err.pos = pos;
22892
- throw err;
22893
- }
22894
-
22895
- const isDebug$6 = !!process.env.DEBUG;
22896
- const debug$e = createDebugger('vite:sourcemap', {
22897
- onlyWhenFocused: true
22898
- });
22899
- // Virtual modules should be prefixed with a null byte to avoid a
22900
- // false positive "missing source" warning. We also check for certain
22901
- // prefixes used for special handling in esbuildDepPlugin.
22902
- const virtualSourceRE = /^(\0|dep:|browser-external:)/;
22903
- async function injectSourcesContent(map, file, logger) {
22904
- let sourceRoot;
22905
- try {
22906
- // The source root is undefined for virtual modules and permission errors.
22907
- sourceRoot = await fs$n.promises.realpath(path__default.resolve(path__default.dirname(file), map.sourceRoot || ''));
22908
- }
22909
- catch { }
22910
- const missingSources = [];
22911
- map.sourcesContent = await Promise.all(map.sources.map((sourcePath) => {
22912
- if (sourcePath && !virtualSourceRE.test(sourcePath)) {
22913
- sourcePath = decodeURI(sourcePath);
22914
- if (sourceRoot) {
22915
- sourcePath = path__default.resolve(sourceRoot, sourcePath);
22916
- }
22917
- return fs$n.promises.readFile(sourcePath, 'utf-8').catch(() => {
22918
- missingSources.push(sourcePath);
22919
- return null;
22920
- });
22921
- }
22922
- return null;
22923
- }));
22924
- // Use this command…
22925
- // DEBUG="vite:sourcemap" vite build
22926
- // …to log the missing sources.
22927
- if (missingSources.length) {
22928
- logger.warnOnce(`Sourcemap for "${file}" points to missing source files`);
22929
- isDebug$6 && debug$e(`Missing sources:\n ` + missingSources.join(`\n `));
22930
- }
22931
- }
22932
- function genSourceMapUrl(map) {
22933
- if (typeof map !== 'string') {
22934
- map = JSON.stringify(map);
22935
- }
22936
- return `data:application/json;base64,${Buffer.from(map).toString('base64')}`;
22937
- }
22938
- function getCodeWithSourcemap(type, code, map) {
22939
- if (isDebug$6) {
22940
- code += `\n/*${JSON.stringify(map, null, 2).replace(/\*\//g, '*\\/')}*/\n`;
22941
- }
22942
- if (type === 'js') {
22943
- code += `\n//# sourceMappingURL=${genSourceMapUrl(map !== null && map !== void 0 ? map : undefined)}`;
22944
- }
22945
- else if (type === 'css') {
22946
- code += `\n/*# sourceMappingURL=${genSourceMapUrl(map !== null && map !== void 0 ? map : undefined)} */`;
22947
- }
22948
- return code;
22949
- }
22950
-
22951
22718
  var dist$1 = {};
22952
22719
 
22953
22720
  (function (exports) {
@@ -30103,6 +29870,62 @@ rc.sync = withTypeScriptLoader((ctx, path, options) => {
30103
29870
  */
30104
29871
  var src$1 = rc;
30105
29872
 
29873
+ const isDebug$6 = !!process.env.DEBUG;
29874
+ const debug$e = createDebugger('vite:sourcemap', {
29875
+ onlyWhenFocused: true
29876
+ });
29877
+ // Virtual modules should be prefixed with a null byte to avoid a
29878
+ // false positive "missing source" warning. We also check for certain
29879
+ // prefixes used for special handling in esbuildDepPlugin.
29880
+ const virtualSourceRE = /^(\0|dep:|browser-external:)/;
29881
+ async function injectSourcesContent(map, file, logger) {
29882
+ let sourceRoot;
29883
+ try {
29884
+ // The source root is undefined for virtual modules and permission errors.
29885
+ sourceRoot = await fs$n.promises.realpath(path__default.resolve(path__default.dirname(file), map.sourceRoot || ''));
29886
+ }
29887
+ catch { }
29888
+ const missingSources = [];
29889
+ map.sourcesContent = await Promise.all(map.sources.map((sourcePath) => {
29890
+ if (sourcePath && !virtualSourceRE.test(sourcePath)) {
29891
+ sourcePath = decodeURI(sourcePath);
29892
+ if (sourceRoot) {
29893
+ sourcePath = path__default.resolve(sourceRoot, sourcePath);
29894
+ }
29895
+ return fs$n.promises.readFile(sourcePath, 'utf-8').catch(() => {
29896
+ missingSources.push(sourcePath);
29897
+ return null;
29898
+ });
29899
+ }
29900
+ return null;
29901
+ }));
29902
+ // Use this command…
29903
+ // DEBUG="vite:sourcemap" vite build
29904
+ // …to log the missing sources.
29905
+ if (missingSources.length) {
29906
+ logger.warnOnce(`Sourcemap for "${file}" points to missing source files`);
29907
+ isDebug$6 && debug$e(`Missing sources:\n ` + missingSources.join(`\n `));
29908
+ }
29909
+ }
29910
+ function genSourceMapUrl(map) {
29911
+ if (typeof map !== 'string') {
29912
+ map = JSON.stringify(map);
29913
+ }
29914
+ return `data:application/json;base64,${Buffer.from(map).toString('base64')}`;
29915
+ }
29916
+ function getCodeWithSourcemap(type, code, map) {
29917
+ if (isDebug$6) {
29918
+ code += `\n/*${JSON.stringify(map, null, 2).replace(/\*\//g, '*\\/')}*/\n`;
29919
+ }
29920
+ if (type === 'js') {
29921
+ code += `\n//# sourceMappingURL=${genSourceMapUrl(map !== null && map !== void 0 ? map : undefined)}`;
29922
+ }
29923
+ else if (type === 'css') {
29924
+ code += `\n/*# sourceMappingURL=${genSourceMapUrl(map !== null && map !== void 0 ? map : undefined)} */`;
29925
+ }
29926
+ return code;
29927
+ }
29928
+
30106
29929
  // This file was generated. Do not modify manually!
30107
29930
  var astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 370, 1, 154, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 161, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 19306, 9, 87, 9, 39, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4706, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 262, 6, 10, 9, 357, 0, 62, 13, 1495, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
30108
29931
 
@@ -36554,7 +36377,7 @@ const assetAttrsConfig = {
36554
36377
  const isAsyncScriptMap = new WeakMap();
36555
36378
  async function traverseHtml(html, filePath, visitor) {
36556
36379
  // lazy load compiler
36557
- const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-e66f37a9.js'); }).then(function (n) { return n.compilerDom_cjs; });
36380
+ const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-6e727db7.js'); }).then(function (n) { return n.compilerDom_cjs; });
36558
36381
  // @vue/compiler-core doesn't like lowercase doctypes
36559
36382
  html = html.replace(/<!doctype\s/i, '<!DOCTYPE ');
36560
36383
  try {
@@ -37135,6 +36958,7 @@ const htmlProxyRE = /(\?|&)html-proxy\b/;
37135
36958
  const commonjsProxyRE = /\?commonjs-proxy/;
37136
36959
  const inlineRE = /(\?|&)inline\b/;
37137
36960
  const inlineCSSRE = /(\?|&)inline-css\b/;
36961
+ const usedRE = /(\?|&)used\b/;
37138
36962
  const varRE = /^var\(/i;
37139
36963
  const isCSSRequest = (request) => cssLangRE.test(request);
37140
36964
  const isDirectCSSRequest = (request) => cssLangRE.test(request) && directRequestRE.test(request);
@@ -37310,18 +37134,24 @@ function cssPostPlugin(config) {
37310
37134
  styles.set(id, css);
37311
37135
  }
37312
37136
  let code;
37313
- if (modulesCode) {
37314
- code = modulesCode;
37137
+ if (usedRE.test(id)) {
37138
+ if (modulesCode) {
37139
+ code = modulesCode;
37140
+ }
37141
+ else {
37142
+ let content = css;
37143
+ if (config.build.minify) {
37144
+ content = await minifyCSS(content, config);
37145
+ }
37146
+ code = `export default ${JSON.stringify(content)}`;
37147
+ }
37315
37148
  }
37316
37149
  else {
37317
- let content = css;
37318
- if (config.build.minify) {
37319
- content = await minifyCSS(content, config);
37320
- }
37321
- // marking as pure to make it tree-shakable by minifier
37322
- // but the module itself is still treated as a non tree-shakable module
37323
- // because moduleSideEffects is 'no-treeshake'
37324
- code = `export default /* #__PURE__ */ (() => ${JSON.stringify(content)})()`;
37150
+ // if moduleCode exists return it **even if** it does not have `?used`
37151
+ // this will disable tree-shake to work with `import './foo.module.css'` but this usually does not happen
37152
+ // this is a limitation of the current approach by `?used` to make tree-shake work
37153
+ // See #8936 for more details
37154
+ code = modulesCode || `export default ''`;
37325
37155
  }
37326
37156
  return {
37327
37157
  code,
@@ -37604,7 +37434,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
37604
37434
  replacer: urlReplacer
37605
37435
  }));
37606
37436
  if (isModule) {
37607
- postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-e3eda1c7.js'); }).then(function (n) { return n.index; })).default({
37437
+ postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-de42cef2.js'); }).then(function (n) { return n.index; })).default({
37608
37438
  ...modulesOptions,
37609
37439
  getJSON(cssFileName, _modules, outputFileName) {
37610
37440
  modules = _modules;
@@ -38253,6 +38083,185 @@ function isPreProcessor(lang) {
38253
38083
  return lang && lang in preProcessors;
38254
38084
  }
38255
38085
 
38086
+ function formatGlobRelativePattern(base, pattern) {
38087
+ let parentDepth = 0;
38088
+ while (pattern.startsWith('../')) {
38089
+ pattern = pattern.slice(3);
38090
+ base = path__default.resolve(base, '../');
38091
+ parentDepth++;
38092
+ }
38093
+ if (pattern.startsWith('./')) {
38094
+ pattern = pattern.slice(2);
38095
+ }
38096
+ return { base, pattern, parentDepth, isAbsolute: false };
38097
+ }
38098
+ async function transformImportGlob(source, pos, importer, importIndex, root, logger, normalizeUrl, resolve, preload = true) {
38099
+ var _a;
38100
+ const isEager = source.slice(pos, pos + 21) === 'import.meta.globEager';
38101
+ const isEagerDefault = isEager && source.slice(pos + 21, pos + 28) === 'Default';
38102
+ const err = (msg) => {
38103
+ const e = new Error(`Invalid glob import syntax: ${msg}`);
38104
+ e.pos = pos;
38105
+ return e;
38106
+ };
38107
+ importer = cleanUrl(importer);
38108
+ const importerBasename = path__default.basename(importer);
38109
+ const [userPattern, options, endIndex] = lexGlobPattern(source, pos);
38110
+ let globParams = null;
38111
+ if (userPattern.startsWith('/')) {
38112
+ globParams = {
38113
+ isAbsolute: true,
38114
+ base: path__default.resolve(root),
38115
+ pattern: userPattern.slice(1),
38116
+ parentDepth: 0
38117
+ };
38118
+ }
38119
+ else if (userPattern.startsWith('.')) {
38120
+ globParams = formatGlobRelativePattern(path__default.dirname(importer), userPattern);
38121
+ }
38122
+ else if (resolve) {
38123
+ const resolvedId = await resolve(userPattern, importer);
38124
+ if (resolvedId) {
38125
+ const importerDirname = path__default.dirname(importer);
38126
+ globParams = formatGlobRelativePattern(importerDirname, normalizePath$3(path__default.relative(importerDirname, resolvedId)));
38127
+ }
38128
+ }
38129
+ if (!globParams) {
38130
+ throw err(`pattern must start with "." or "/" (relative to project root) or alias path`);
38131
+ }
38132
+ const { base, parentDepth, isAbsolute, pattern } = globParams;
38133
+ const files = out.sync(pattern, {
38134
+ cwd: base,
38135
+ // Ignore node_modules by default unless explicitly indicated in the pattern
38136
+ ignore: /(^|\/)node_modules\//.test(pattern) ? [] : ['**/node_modules/**']
38137
+ });
38138
+ const imports = [];
38139
+ let importsString = ``;
38140
+ let entries = ``;
38141
+ for (let i = 0; i < files.length; i++) {
38142
+ // skip importer itself
38143
+ if (files[i] === importerBasename)
38144
+ continue;
38145
+ const file = isAbsolute
38146
+ ? `/${files[i]}`
38147
+ : parentDepth
38148
+ ? `${'../'.repeat(parentDepth)}${files[i]}`
38149
+ : `./${files[i]}`;
38150
+ let importee = file;
38151
+ if (normalizeUrl) {
38152
+ [importee] = await normalizeUrl(file, pos);
38153
+ }
38154
+ imports.push(importee);
38155
+ // TODO remove assert syntax for the Vite 3.0 release.
38156
+ const isRawAssert = ((_a = options === null || options === void 0 ? void 0 : options.assert) === null || _a === void 0 ? void 0 : _a.type) === 'raw';
38157
+ const isRawType = (options === null || options === void 0 ? void 0 : options.as) === 'raw';
38158
+ if (isRawType || isRawAssert) {
38159
+ if (isRawAssert) {
38160
+ logger.warn(colors$1.yellow(colors$1.bold("(!) import.meta.glob('...', { assert: { type: 'raw' }}) is deprecated. Use import.meta.glob('...', { as: 'raw' }) instead.")));
38161
+ }
38162
+ entries += ` ${JSON.stringify(file)}: ${JSON.stringify(await fs$n.promises.readFile(path__default.join(base, files[i]), 'utf-8'))},`;
38163
+ }
38164
+ else {
38165
+ const importeeUrl = isCSSRequest(importee) ? `${importee}?used` : importee;
38166
+ if (isEager) {
38167
+ const identifier = `__glob_${importIndex}_${i}`;
38168
+ // css imports injecting a ?used query to export the css string
38169
+ importsString += `import ${isEagerDefault ? `` : `* as `}${identifier} from ${JSON.stringify(importeeUrl)};`;
38170
+ entries += ` ${JSON.stringify(file)}: ${identifier},`;
38171
+ }
38172
+ else {
38173
+ let imp = `import(${JSON.stringify(importeeUrl)})`;
38174
+ if (!normalizeUrl && preload) {
38175
+ imp =
38176
+ `(${isModernFlag}` +
38177
+ `? ${preloadMethod}(()=>${imp},"${preloadMarker}")` +
38178
+ `: ${imp})`;
38179
+ }
38180
+ entries += ` ${JSON.stringify(file)}: () => ${imp},`;
38181
+ }
38182
+ }
38183
+ }
38184
+ return {
38185
+ imports,
38186
+ importsString,
38187
+ exp: `{${entries}}`,
38188
+ endIndex,
38189
+ isEager,
38190
+ pattern,
38191
+ base
38192
+ };
38193
+ }
38194
+ function lexGlobPattern(code, pos) {
38195
+ let state = 0 /* inCall */;
38196
+ let pattern = '';
38197
+ let i = code.indexOf(`(`, pos) + 1;
38198
+ outer: for (; i < code.length; i++) {
38199
+ const char = code.charAt(i);
38200
+ switch (state) {
38201
+ case 0 /* inCall */:
38202
+ if (char === `'`) {
38203
+ state = 1 /* inSingleQuoteString */;
38204
+ }
38205
+ else if (char === `"`) {
38206
+ state = 2 /* inDoubleQuoteString */;
38207
+ }
38208
+ else if (char === '`') {
38209
+ state = 3 /* inTemplateString */;
38210
+ }
38211
+ else if (/\s/.test(char)) {
38212
+ continue;
38213
+ }
38214
+ else {
38215
+ error$2(i);
38216
+ }
38217
+ break;
38218
+ case 1 /* inSingleQuoteString */:
38219
+ if (char === `'`) {
38220
+ break outer;
38221
+ }
38222
+ else {
38223
+ pattern += char;
38224
+ }
38225
+ break;
38226
+ case 2 /* inDoubleQuoteString */:
38227
+ if (char === `"`) {
38228
+ break outer;
38229
+ }
38230
+ else {
38231
+ pattern += char;
38232
+ }
38233
+ break;
38234
+ case 3 /* inTemplateString */:
38235
+ if (char === '`') {
38236
+ break outer;
38237
+ }
38238
+ else {
38239
+ pattern += char;
38240
+ }
38241
+ break;
38242
+ default:
38243
+ throw new Error('unknown import.meta.glob lexer state');
38244
+ }
38245
+ }
38246
+ const noCommentCode = code
38247
+ .slice(i + 1)
38248
+ .replace(singlelineCommentsRE, blankReplacer)
38249
+ .replace(multilineCommentsRE, blankReplacer);
38250
+ const endIndex = noCommentCode.indexOf(')');
38251
+ const optionString = noCommentCode.substring(0, endIndex);
38252
+ const commaIndex = optionString.indexOf(',');
38253
+ let options = {};
38254
+ if (commaIndex > -1) {
38255
+ options = lib$2.parse(optionString.substring(commaIndex + 1));
38256
+ }
38257
+ return [pattern, options, endIndex + i + 2];
38258
+ }
38259
+ function error$2(pos) {
38260
+ const err = new Error(`import.meta.glob() can only accept string literals.`);
38261
+ err.pos = pos;
38262
+ throw err;
38263
+ }
38264
+
38256
38265
  /**
38257
38266
  * A flag for injected helpers. This flag will be set to `false` if the output
38258
38267
  * target is not native es - so that injected helper logic can be conditionally
@@ -38364,7 +38373,8 @@ function buildImportAnalysisPlugin(config) {
38364
38373
  const str = () => s || (s = new MagicString(source));
38365
38374
  let needPreloadHelper = false;
38366
38375
  for (let index = 0; index < imports.length; index++) {
38367
- const { s: start, e: end, ss: expStart, se: expEnd, d: dynamicIndex } = imports[index];
38376
+ const { s: start, e: end, ss: expStart, se: expEnd, n: specifier, d: dynamicIndex } = imports[index];
38377
+ const isDynamic = dynamicIndex > -1;
38368
38378
  // import.meta.glob
38369
38379
  if (source.slice(start, end) === 'import.meta' &&
38370
38380
  source.slice(end, end + 5) === '.glob') {
@@ -38383,11 +38393,26 @@ function buildImportAnalysisPlugin(config) {
38383
38393
  }
38384
38394
  continue;
38385
38395
  }
38386
- if (dynamicIndex > -1 && insertPreload) {
38396
+ if (isDynamic && insertPreload) {
38387
38397
  needPreloadHelper = true;
38388
- const original = source.slice(expStart, expEnd);
38389
- const replacement = `${preloadMethod}(() => ${original},${isModernFlag}?"${preloadMarker}":void 0)`;
38390
- str().overwrite(expStart, expEnd, replacement, { contentOnly: true });
38398
+ str().prependLeft(expStart, `${preloadMethod}(() => `);
38399
+ str().appendRight(expEnd, `,${isModernFlag}?"${preloadMarker}":void 0)`);
38400
+ }
38401
+ // Differentiate CSS imports that use the default export from those that
38402
+ // do not by injecting a ?used query - this allows us to avoid including
38403
+ // the CSS string when unnecessary (esbuild has trouble tree-shaking
38404
+ // them)
38405
+ if (specifier &&
38406
+ isCSSRequest(specifier) &&
38407
+ // always inject ?used query when it is a dynamic import
38408
+ // because there is no way to check whether the default export is used
38409
+ (source.slice(expStart, start).includes('from') || isDynamic) &&
38410
+ // edge case for package names ending with .css (e.g normalize.css)
38411
+ !(bareImportRE.test(specifier) && !specifier.includes('/'))) {
38412
+ const url = specifier.replace(/\?|$/, (m) => `?used${m ? '&' : ''}`);
38413
+ str().overwrite(start, end, isDynamic ? `'${url}'` : url, {
38414
+ contentOnly: true
38415
+ });
38391
38416
  }
38392
38417
  }
38393
38418
  if (needPreloadHelper &&
@@ -48163,7 +48188,7 @@ async function getCertificate(cacheDir) {
48163
48188
  return content;
48164
48189
  }
48165
48190
  catch {
48166
- const content = (await Promise.resolve().then(function () { return require('./dep-56de50fc.js'); })).createCertificate();
48191
+ const content = (await Promise.resolve().then(function () { return require('./dep-99a2ccc8.js'); })).createCertificate();
48167
48192
  fs$n.promises
48168
48193
  .mkdir(cacheDir, { recursive: true })
48169
48194
  .then(() => fs$n.promises.writeFile(cachePath, content))
@@ -49775,7 +49800,7 @@ function serveStaticMiddleware(dir, server) {
49775
49800
  return;
49776
49801
  }
49777
49802
  if (redirected) {
49778
- req.url = redirected;
49803
+ req.url = encodeURIComponent(redirected);
49779
49804
  }
49780
49805
  serve(req, res, next);
49781
49806
  };
@@ -49797,7 +49822,7 @@ function serveRawFsMiddleware(server) {
49797
49822
  url = url.slice(FS_PREFIX.length);
49798
49823
  if (isWindows$3)
49799
49824
  url = url.replace(/^[A-Z]:/i, '');
49800
- req.url = url;
49825
+ req.url = encodeURIComponent(url);
49801
49826
  serveFromRoot(req, res, next);
49802
49827
  }
49803
49828
  else {
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var require$$0 = require('postcss');
4
- var index$1 = require('./dep-80fe9c6b.js');
4
+ var index$1 = require('./dep-c9998dc6.js');
5
5
  var path$2 = require('path');
6
6
  var require$$1 = require('crypto');
7
7
  var fs = require('fs');
package/dist/node/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  var perf_hooks = require('perf_hooks');
4
4
  var require$$0 = require('events');
5
- var index = require('./chunks/dep-80fe9c6b.js');
5
+ var index = require('./chunks/dep-c9998dc6.js');
6
6
  require('fs');
7
7
  require('path');
8
8
  require('url');
@@ -683,7 +683,7 @@ cli
683
683
  .action(async (root, options) => {
684
684
  // output structure is preserved even after bundling so require()
685
685
  // is ok here
686
- const { createServer } = await Promise.resolve().then(function () { return require('./chunks/dep-80fe9c6b.js'); }).then(function (n) { return n.index$1; });
686
+ const { createServer } = await Promise.resolve().then(function () { return require('./chunks/dep-c9998dc6.js'); }).then(function (n) { return n.index$1; });
687
687
  try {
688
688
  const server = await createServer({
689
689
  root,
@@ -732,7 +732,7 @@ cli
732
732
  .option('--emptyOutDir', `[boolean] force empty outDir when it's outside of root`)
733
733
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
734
734
  .action(async (root, options) => {
735
- const { build } = await Promise.resolve().then(function () { return require('./chunks/dep-80fe9c6b.js'); }).then(function (n) { return n.build$1; });
735
+ const { build } = await Promise.resolve().then(function () { return require('./chunks/dep-c9998dc6.js'); }).then(function (n) { return n.build$1; });
736
736
  const buildOptions = cleanOptions(options);
737
737
  try {
738
738
  await build({
@@ -755,7 +755,7 @@ cli
755
755
  .command('optimize [root]', 'pre-bundle dependencies')
756
756
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
757
757
  .action(async (root, options) => {
758
- const { optimizeDeps } = await Promise.resolve().then(function () { return require('./chunks/dep-80fe9c6b.js'); }).then(function (n) { return n.index; });
758
+ const { optimizeDeps } = await Promise.resolve().then(function () { return require('./chunks/dep-c9998dc6.js'); }).then(function (n) { return n.index; });
759
759
  try {
760
760
  const config = await index.resolveConfig({
761
761
  root,
@@ -778,7 +778,7 @@ cli
778
778
  .option('--https', `[boolean] use TLS + HTTP/2`)
779
779
  .option('--open [path]', `[boolean | string] open browser on startup`)
780
780
  .action(async (root, options) => {
781
- const { preview } = await Promise.resolve().then(function () { return require('./chunks/dep-80fe9c6b.js'); }).then(function (n) { return n.preview$1; });
781
+ const { preview } = await Promise.resolve().then(function () { return require('./chunks/dep-c9998dc6.js'); }).then(function (n) { return n.preview$1; });
782
782
  try {
783
783
  const server = await preview({
784
784
  root,
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./chunks/dep-80fe9c6b.js');
5
+ var index = require('./chunks/dep-c9998dc6.js');
6
6
  require('fs');
7
7
  require('path');
8
8
  require('url');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "2.9.13",
3
+ "version": "2.9.14",
4
4
  "license": "MIT",
5
5
  "author": "Evan You",
6
6
  "description": "Native-ESM powered web dev build tool",