vite 3.0.0-alpha.6 → 3.0.0-alpha.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/node/chunks/{dep-8bed6f50.js → dep-16fa9be9.js} +1 -1
- package/dist/node/chunks/{dep-a4f17494.js → dep-395deadd.js} +1 -1
- package/dist/node/chunks/{dep-b4474709.js → dep-3a62832d.js} +1 -1
- package/dist/node/chunks/{dep-52974b5a.js → dep-e214e00e.js} +46 -40
- package/dist/node/cli.js +5 -5
- package/dist/node/constants.js +1 -1
- package/dist/node/index.d.ts +6 -74
- package/dist/node/index.js +1 -1
- package/package.json +1 -1
- package/types/es-module-lexer.d.ts +0 -90
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { x as getAugmentedNamespace, y as getDefaultExportFromCjs } from './dep-
|
|
1
|
+
import { x as getAugmentedNamespace, y as getDefaultExportFromCjs } from './dep-e214e00e.js';
|
|
2
2
|
|
|
3
3
|
import { fileURLToPath as __cjs_fileURLToPath } from 'url';
|
|
4
4
|
import { dirname as __cjs_dirname } from 'path';
|
|
@@ -15464,9 +15464,8 @@ function esbuildDepPlugin(qualified, exportsData, config) {
|
|
|
15464
15464
|
relativePath = `./${relativePath}`;
|
|
15465
15465
|
}
|
|
15466
15466
|
let contents = '';
|
|
15467
|
-
const
|
|
15468
|
-
|
|
15469
|
-
if (!imports.length && !exports.length) {
|
|
15467
|
+
const { hasImports, exports, hasReExports } = exportsData[id];
|
|
15468
|
+
if (!hasImports && !exports.length) {
|
|
15470
15469
|
// cjs
|
|
15471
15470
|
contents += `export default require("${relativePath}");`;
|
|
15472
15471
|
}
|
|
@@ -15474,9 +15473,7 @@ function esbuildDepPlugin(qualified, exportsData, config) {
|
|
|
15474
15473
|
if (exports.includes('default')) {
|
|
15475
15474
|
contents += `import d from "${relativePath}";export default d;`;
|
|
15476
15475
|
}
|
|
15477
|
-
if (
|
|
15478
|
-
exports.length > 1 ||
|
|
15479
|
-
exports[0] !== 'default') {
|
|
15476
|
+
if (hasReExports || exports.length > 1 || exports[0] !== 'default') {
|
|
15480
15477
|
contents += `\nexport * from "${relativePath}"`;
|
|
15481
15478
|
}
|
|
15482
15479
|
}
|
|
@@ -27520,7 +27517,7 @@ async function runOptimizeDeps(resolvedConfig, depsInfo) {
|
|
|
27520
27517
|
splitting: true,
|
|
27521
27518
|
sourcemap: true,
|
|
27522
27519
|
outdir: processingCacheDir,
|
|
27523
|
-
ignoreAnnotations:
|
|
27520
|
+
ignoreAnnotations: resolvedConfig.command !== 'build',
|
|
27524
27521
|
metafile: true,
|
|
27525
27522
|
define,
|
|
27526
27523
|
plugins: [
|
|
@@ -27708,7 +27705,6 @@ function esbuildOutputFromId(outputs, id, cacheDirOutputPath) {
|
|
|
27708
27705
|
}
|
|
27709
27706
|
async function extractExportsData(filePath, config) {
|
|
27710
27707
|
await init;
|
|
27711
|
-
let exportsData;
|
|
27712
27708
|
const esbuildOptions = config.optimizeDeps?.esbuildOptions ?? {};
|
|
27713
27709
|
if (config.optimizeDeps.extensions?.some((ext) => filePath.endsWith(ext))) {
|
|
27714
27710
|
// For custom supported extensions, build the entry file to transform it into JS,
|
|
@@ -27720,35 +27716,45 @@ async function extractExportsData(filePath, config) {
|
|
|
27720
27716
|
write: false,
|
|
27721
27717
|
format: 'esm'
|
|
27722
27718
|
});
|
|
27723
|
-
|
|
27719
|
+
const [imports, exports, facade] = parse$h(result.outputFiles[0].text);
|
|
27720
|
+
return {
|
|
27721
|
+
hasImports: imports.length > 0,
|
|
27722
|
+
exports,
|
|
27723
|
+
facade
|
|
27724
|
+
};
|
|
27724
27725
|
}
|
|
27725
|
-
|
|
27726
|
-
|
|
27727
|
-
|
|
27728
|
-
|
|
27729
|
-
|
|
27730
|
-
|
|
27731
|
-
|
|
27732
|
-
|
|
27733
|
-
|
|
27734
|
-
|
|
27735
|
-
|
|
27736
|
-
|
|
27737
|
-
|
|
27738
|
-
|
|
27739
|
-
|
|
27740
|
-
|
|
27741
|
-
|
|
27742
|
-
|
|
27743
|
-
|
|
27744
|
-
|
|
27745
|
-
for (const { ss, se } of exportsData[0]) {
|
|
27746
|
-
const exp = entryContent.slice(ss, se);
|
|
27747
|
-
if (/export\s+\*\s+from/.test(exp)) {
|
|
27748
|
-
exportsData.hasReExports = true;
|
|
27749
|
-
}
|
|
27750
|
-
}
|
|
27726
|
+
let parseResult;
|
|
27727
|
+
let usedJsxLoader = false;
|
|
27728
|
+
const entryContent = fs__default.readFileSync(filePath, 'utf-8');
|
|
27729
|
+
try {
|
|
27730
|
+
parseResult = parse$h(entryContent);
|
|
27731
|
+
}
|
|
27732
|
+
catch {
|
|
27733
|
+
const loader = esbuildOptions.loader?.[path$p.extname(filePath)] || 'jsx';
|
|
27734
|
+
debug$a(`Unable to parse: ${filePath}.\n Trying again with a ${loader} transform.`);
|
|
27735
|
+
const transformed = await transformWithEsbuild(entryContent, filePath, {
|
|
27736
|
+
loader
|
|
27737
|
+
});
|
|
27738
|
+
// Ensure that optimization won't fail by defaulting '.js' to the JSX parser.
|
|
27739
|
+
// This is useful for packages such as Gatsby.
|
|
27740
|
+
esbuildOptions.loader = {
|
|
27741
|
+
'.js': 'jsx',
|
|
27742
|
+
...esbuildOptions.loader
|
|
27743
|
+
};
|
|
27744
|
+
parseResult = parse$h(transformed.code);
|
|
27745
|
+
usedJsxLoader = true;
|
|
27751
27746
|
}
|
|
27747
|
+
const [imports, exports, facade] = parseResult;
|
|
27748
|
+
const exportsData = {
|
|
27749
|
+
hasImports: imports.length > 0,
|
|
27750
|
+
exports,
|
|
27751
|
+
facade,
|
|
27752
|
+
hasReExports: imports.some(({ ss, se }) => {
|
|
27753
|
+
const exp = entryContent.slice(ss, se);
|
|
27754
|
+
return /export\s+\*\s+from/.test(exp);
|
|
27755
|
+
}),
|
|
27756
|
+
jsxLoader: usedJsxLoader
|
|
27757
|
+
};
|
|
27752
27758
|
return exportsData;
|
|
27753
27759
|
}
|
|
27754
27760
|
// https://github.com/vitejs/vite/issues/1724#issuecomment-767619642
|
|
@@ -27760,9 +27766,9 @@ function needsInterop(config, id, exportsData, output) {
|
|
|
27760
27766
|
KNOWN_INTEROP_IDS.has(id)) {
|
|
27761
27767
|
return true;
|
|
27762
27768
|
}
|
|
27763
|
-
const
|
|
27769
|
+
const { hasImports, exports } = exportsData;
|
|
27764
27770
|
// entry has no ESM syntax - likely CJS or UMD
|
|
27765
|
-
if (!exports.length && !
|
|
27771
|
+
if (!exports.length && !hasImports) {
|
|
27766
27772
|
return true;
|
|
27767
27773
|
}
|
|
27768
27774
|
if (output) {
|
|
@@ -35872,7 +35878,7 @@ const assetAttrsConfig = {
|
|
|
35872
35878
|
const isAsyncScriptMap = new WeakMap();
|
|
35873
35879
|
async function traverseHtml(html, filePath, visitor) {
|
|
35874
35880
|
// lazy load compiler
|
|
35875
|
-
const { parse, transform } = await import('./dep-
|
|
35881
|
+
const { parse, transform } = await import('./dep-3a62832d.js').then(function (n) { return n.c; });
|
|
35876
35882
|
// @vue/compiler-core doesn't like lowercase doctypes
|
|
35877
35883
|
html = html.replace(/<!doctype\s/i, '<!DOCTYPE ');
|
|
35878
35884
|
try {
|
|
@@ -36977,7 +36983,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
36977
36983
|
logger: config.logger
|
|
36978
36984
|
}));
|
|
36979
36985
|
if (isModule) {
|
|
36980
|
-
postcssPlugins.unshift((await import('./dep-
|
|
36986
|
+
postcssPlugins.unshift((await import('./dep-16fa9be9.js').then(function (n) { return n.i; })).default({
|
|
36981
36987
|
...modulesOptions,
|
|
36982
36988
|
getJSON(cssFileName, _modules, outputFileName) {
|
|
36983
36989
|
modules = _modules;
|
|
@@ -47634,7 +47640,7 @@ async function getCertificate(cacheDir) {
|
|
|
47634
47640
|
return content;
|
|
47635
47641
|
}
|
|
47636
47642
|
catch {
|
|
47637
|
-
const content = (await import('./dep-
|
|
47643
|
+
const content = (await import('./dep-395deadd.js')).createCertificate();
|
|
47638
47644
|
promises
|
|
47639
47645
|
.mkdir(cacheDir, { recursive: true })
|
|
47640
47646
|
.then(() => promises.writeFile(cachePath, content))
|
package/dist/node/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { performance } from 'perf_hooks';
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
|
-
import { v as colors, j as createLogger, e as resolveConfig } from './chunks/dep-
|
|
3
|
+
import { v as colors, j as createLogger, e as resolveConfig } from './chunks/dep-e214e00e.js';
|
|
4
4
|
import { VERSION } from './constants.js';
|
|
5
5
|
import 'fs';
|
|
6
6
|
import 'path';
|
|
@@ -682,7 +682,7 @@ cli
|
|
|
682
682
|
.action(async (root, options) => {
|
|
683
683
|
// output structure is preserved even after bundling so require()
|
|
684
684
|
// is ok here
|
|
685
|
-
const { createServer } = await import('./chunks/dep-
|
|
685
|
+
const { createServer } = await import('./chunks/dep-e214e00e.js').then(function (n) { return n.B; });
|
|
686
686
|
try {
|
|
687
687
|
const server = await createServer({
|
|
688
688
|
root,
|
|
@@ -728,7 +728,7 @@ cli
|
|
|
728
728
|
.option('--emptyOutDir', `[boolean] force empty outDir when it's outside of root`)
|
|
729
729
|
.option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
|
|
730
730
|
.action(async (root, options) => {
|
|
731
|
-
const { build } = await import('./chunks/dep-
|
|
731
|
+
const { build } = await import('./chunks/dep-e214e00e.js').then(function (n) { return n.A; });
|
|
732
732
|
const buildOptions = cleanOptions(options);
|
|
733
733
|
try {
|
|
734
734
|
await build({
|
|
@@ -752,7 +752,7 @@ cli
|
|
|
752
752
|
.command('optimize [root]', 'pre-bundle dependencies')
|
|
753
753
|
.option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
|
|
754
754
|
.action(async (root, options) => {
|
|
755
|
-
const { optimizeDeps } = await import('./chunks/dep-
|
|
755
|
+
const { optimizeDeps } = await import('./chunks/dep-e214e00e.js').then(function (n) { return n.z; });
|
|
756
756
|
try {
|
|
757
757
|
const config = await resolveConfig({
|
|
758
758
|
root,
|
|
@@ -775,7 +775,7 @@ cli
|
|
|
775
775
|
.option('--https', `[boolean] use TLS + HTTP/2`)
|
|
776
776
|
.option('--open [path]', `[boolean | string] open browser on startup`)
|
|
777
777
|
.action(async (root, options) => {
|
|
778
|
-
const { preview } = await import('./chunks/dep-
|
|
778
|
+
const { preview } = await import('./chunks/dep-e214e00e.js').then(function (n) { return n.C; });
|
|
779
779
|
try {
|
|
780
780
|
const server = await preview({
|
|
781
781
|
root,
|
package/dist/node/constants.js
CHANGED
package/dist/node/index.d.ts
CHANGED
|
@@ -645,77 +645,6 @@ export declare type ESBuildTransformResult = Omit<TransformResult_3, 'map'> & {
|
|
|
645
645
|
map: SourceMap;
|
|
646
646
|
};
|
|
647
647
|
|
|
648
|
-
export declare interface EsModuleLexerImportSpecifier {
|
|
649
|
-
/**
|
|
650
|
-
* Module name
|
|
651
|
-
*
|
|
652
|
-
* To handle escape sequences in specifier strings, the .n field of imported specifiers will be provided where possible.
|
|
653
|
-
*
|
|
654
|
-
* For dynamic import expressions, this field will be empty if not a valid JS string.
|
|
655
|
-
*
|
|
656
|
-
* @example
|
|
657
|
-
* const [imports1, exports1] = parse(String.raw`import './\u0061\u0062.js'`);
|
|
658
|
-
* imports1[0].n;
|
|
659
|
-
* // Returns "./ab.js"
|
|
660
|
-
*
|
|
661
|
-
* const [imports2, exports2] = parse(`import("./ab.js")`);
|
|
662
|
-
* imports2[0].n;
|
|
663
|
-
* // Returns "./ab.js"
|
|
664
|
-
*
|
|
665
|
-
* const [imports3, exports3] = parse(`import("./" + "ab.js")`);
|
|
666
|
-
* imports3[0].n;
|
|
667
|
-
* // Returns undefined
|
|
668
|
-
*/
|
|
669
|
-
readonly n: string | undefined
|
|
670
|
-
/**
|
|
671
|
-
* Start of module specifier
|
|
672
|
-
*
|
|
673
|
-
* @example
|
|
674
|
-
* const source = `import { a } from 'asdf'`;
|
|
675
|
-
* const [imports, exports] = parse(source);
|
|
676
|
-
* source.substring(imports[0].s, imports[0].e);
|
|
677
|
-
* // Returns "asdf"
|
|
678
|
-
*/
|
|
679
|
-
readonly s: number
|
|
680
|
-
/**
|
|
681
|
-
* End of module specifier
|
|
682
|
-
*/
|
|
683
|
-
readonly e: number
|
|
684
|
-
|
|
685
|
-
/**
|
|
686
|
-
* Start of import statement
|
|
687
|
-
*
|
|
688
|
-
* @example
|
|
689
|
-
* const source = `import { a } from 'asdf'`;
|
|
690
|
-
* const [imports, exports] = parse(source);
|
|
691
|
-
* source.substring(imports[0].ss, imports[0].se);
|
|
692
|
-
* // Returns `"import { a } from 'asdf';"`
|
|
693
|
-
*/
|
|
694
|
-
readonly ss: number
|
|
695
|
-
/**
|
|
696
|
-
* End of import statement
|
|
697
|
-
*/
|
|
698
|
-
readonly se: number
|
|
699
|
-
|
|
700
|
-
/**
|
|
701
|
-
* If this import statement is a dynamic import, this is the start value.
|
|
702
|
-
* Otherwise this is `-1`.
|
|
703
|
-
*/
|
|
704
|
-
readonly d: number
|
|
705
|
-
|
|
706
|
-
/**
|
|
707
|
-
* If this import has an import assertion, this is the start value.
|
|
708
|
-
* Otherwise this is `-1`.
|
|
709
|
-
*/
|
|
710
|
-
readonly a: number
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
export declare type EsModuleLexerParseReturnType = readonly [
|
|
714
|
-
imports: ReadonlyArray<EsModuleLexerImportSpecifier>,
|
|
715
|
-
exports: ReadonlyArray<string>,
|
|
716
|
-
facade: boolean
|
|
717
|
-
];
|
|
718
|
-
|
|
719
648
|
export declare interface ExperimentalOptions {
|
|
720
649
|
/**
|
|
721
650
|
* Append fake `&lang.(ext)` when queries are specified, to preseve the file extension for following plugins to process.
|
|
@@ -726,9 +655,12 @@ export declare interface ExperimentalOptions {
|
|
|
726
655
|
importGlobRestoreExtension?: boolean;
|
|
727
656
|
}
|
|
728
657
|
|
|
729
|
-
export declare type ExportsData =
|
|
730
|
-
|
|
731
|
-
|
|
658
|
+
export declare type ExportsData = {
|
|
659
|
+
hasImports: boolean;
|
|
660
|
+
exports: readonly string[];
|
|
661
|
+
facade: boolean;
|
|
662
|
+
hasReExports?: boolean;
|
|
663
|
+
jsxLoader?: boolean;
|
|
732
664
|
};
|
|
733
665
|
|
|
734
666
|
export declare interface FileSystemServeOptions {
|
package/dist/node/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { b as build, j as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, i as isDepsOptimizerEnabled, l as loadConfigFromFile, q as loadEnv, g as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, p as preview, e as resolveConfig, u as resolveEnvPrefix, a as resolvePackageData, r as resolvePackageEntry, k as searchForWorkspaceRoot, h as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-
|
|
1
|
+
export { b as build, j as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, i as isDepsOptimizerEnabled, l as loadConfigFromFile, q as loadEnv, g as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, p as preview, e as resolveConfig, u as resolveEnvPrefix, a as resolvePackageData, r as resolvePackageEntry, k as searchForWorkspaceRoot, h as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-e214e00e.js';
|
|
2
2
|
import 'fs';
|
|
3
3
|
import 'path';
|
|
4
4
|
import 'url';
|
package/package.json
CHANGED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
// Modified and inlined to avoid extra dependency
|
|
2
|
-
// Source: https://github.com/guybedford/es-module-lexer/blob/main/types/lexer.d.ts
|
|
3
|
-
// MIT Licensed https://github.com/guybedford/es-module-lexer/blob/main/LICENSE
|
|
4
|
-
|
|
5
|
-
export interface ImportSpecifier {
|
|
6
|
-
/**
|
|
7
|
-
* Module name
|
|
8
|
-
*
|
|
9
|
-
* To handle escape sequences in specifier strings, the .n field of imported specifiers will be provided where possible.
|
|
10
|
-
*
|
|
11
|
-
* For dynamic import expressions, this field will be empty if not a valid JS string.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* const [imports1, exports1] = parse(String.raw`import './\u0061\u0062.js'`);
|
|
15
|
-
* imports1[0].n;
|
|
16
|
-
* // Returns "./ab.js"
|
|
17
|
-
*
|
|
18
|
-
* const [imports2, exports2] = parse(`import("./ab.js")`);
|
|
19
|
-
* imports2[0].n;
|
|
20
|
-
* // Returns "./ab.js"
|
|
21
|
-
*
|
|
22
|
-
* const [imports3, exports3] = parse(`import("./" + "ab.js")`);
|
|
23
|
-
* imports3[0].n;
|
|
24
|
-
* // Returns undefined
|
|
25
|
-
*/
|
|
26
|
-
readonly n: string | undefined
|
|
27
|
-
/**
|
|
28
|
-
* Start of module specifier
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* const source = `import { a } from 'asdf'`;
|
|
32
|
-
* const [imports, exports] = parse(source);
|
|
33
|
-
* source.substring(imports[0].s, imports[0].e);
|
|
34
|
-
* // Returns "asdf"
|
|
35
|
-
*/
|
|
36
|
-
readonly s: number
|
|
37
|
-
/**
|
|
38
|
-
* End of module specifier
|
|
39
|
-
*/
|
|
40
|
-
readonly e: number
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Start of import statement
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* const source = `import { a } from 'asdf'`;
|
|
47
|
-
* const [imports, exports] = parse(source);
|
|
48
|
-
* source.substring(imports[0].ss, imports[0].se);
|
|
49
|
-
* // Returns `"import { a } from 'asdf';"`
|
|
50
|
-
*/
|
|
51
|
-
readonly ss: number
|
|
52
|
-
/**
|
|
53
|
-
* End of import statement
|
|
54
|
-
*/
|
|
55
|
-
readonly se: number
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* If this import statement is a dynamic import, this is the start value.
|
|
59
|
-
* Otherwise this is `-1`.
|
|
60
|
-
*/
|
|
61
|
-
readonly d: number
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* If this import has an import assertion, this is the start value.
|
|
65
|
-
* Otherwise this is `-1`.
|
|
66
|
-
*/
|
|
67
|
-
readonly a: number
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Wait for init to resolve before calling `parse`.
|
|
72
|
-
*/
|
|
73
|
-
export const init: Promise<void>
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Outputs the list of exports and locations of import specifiers,
|
|
77
|
-
* including dynamic import and import meta handling.
|
|
78
|
-
*
|
|
79
|
-
* @param source - Source code to parser
|
|
80
|
-
* @param name - Optional sourcename
|
|
81
|
-
* @returns Tuple contaning imports list and exports list.
|
|
82
|
-
*/
|
|
83
|
-
export function parse(
|
|
84
|
-
source: string,
|
|
85
|
-
name?: string
|
|
86
|
-
): readonly [
|
|
87
|
-
imports: ReadonlyArray<ImportSpecifier>,
|
|
88
|
-
exports: ReadonlyArray<string>,
|
|
89
|
-
facade: boolean
|
|
90
|
-
]
|