vite 2.5.8 → 2.5.9
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.
- package/CHANGELOG.md +9 -0
- package/dist/node/chunks/{dep-874085d4.js → dep-05fcddd5.js} +55 -36
- package/dist/node/chunks/{dep-874085d4.js.map → dep-05fcddd5.js.map} +1 -1
- package/dist/node/chunks/{dep-3536ae33.js → dep-499befab.js} +2 -2
- package/dist/node/chunks/{dep-3536ae33.js.map → dep-499befab.js.map} +1 -1
- package/dist/node/chunks/{dep-3ec0104c.js → dep-58243dfd.js} +2 -2
- package/dist/node/chunks/{dep-3ec0104c.js.map → dep-58243dfd.js.map} +1 -1
- package/dist/node/chunks/{dep-713b08c9.js → dep-fcb82982.js} +2 -2
- package/dist/node/chunks/{dep-713b08c9.js.map → dep-fcb82982.js.map} +1 -1
- package/dist/node/cli.js +4 -4
- package/dist/node/index.d.ts +10 -4
- package/dist/node/index.js +2 -1
- package/dist/node/index.js.map +1 -1
- package/package.json +1 -1
- package/src/node/index.ts +2 -0
- package/src/node/plugins/esbuild.ts +51 -33
- package/src/node/server/index.ts +2 -0
package/dist/node/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var require$$0$1 = require('events');
|
|
4
|
-
var build = require('./chunks/dep-
|
|
4
|
+
var build = require('./chunks/dep-05fcddd5.js');
|
|
5
5
|
var path = require('path');
|
|
6
6
|
var require$$0$2 = require('tty');
|
|
7
7
|
var require$$0$3 = require('util');
|
|
@@ -14002,7 +14002,7 @@ cli
|
|
|
14002
14002
|
.action(async (root, options) => {
|
|
14003
14003
|
// output structure is preserved even after bundling so require()
|
|
14004
14004
|
// is ok here
|
|
14005
|
-
const { createServer } = await Promise.resolve().then(function () { return require('./chunks/dep-
|
|
14005
|
+
const { createServer } = await Promise.resolve().then(function () { return require('./chunks/dep-05fcddd5.js'); }).then(function (n) { return n.index$1; });
|
|
14006
14006
|
try {
|
|
14007
14007
|
const server = await createServer({
|
|
14008
14008
|
root,
|
|
@@ -14036,7 +14036,7 @@ cli
|
|
|
14036
14036
|
.option('--emptyOutDir', `[boolean] force empty outDir when it's outside of root`)
|
|
14037
14037
|
.option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
|
|
14038
14038
|
.action(async (root, options) => {
|
|
14039
|
-
const { build: build$1 } = await Promise.resolve().then(function () { return require('./chunks/dep-
|
|
14039
|
+
const { build: build$1 } = await Promise.resolve().then(function () { return require('./chunks/dep-05fcddd5.js'); }).then(function (n) { return n.build$1; });
|
|
14040
14040
|
const buildOptions = cleanOptions(options);
|
|
14041
14041
|
try {
|
|
14042
14042
|
await build$1({
|
|
@@ -14059,7 +14059,7 @@ cli
|
|
|
14059
14059
|
.command('optimize [root]')
|
|
14060
14060
|
.option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
|
|
14061
14061
|
.action(async (root, options) => {
|
|
14062
|
-
const { optimizeDeps } = await Promise.resolve().then(function () { return require('./chunks/dep-
|
|
14062
|
+
const { optimizeDeps } = await Promise.resolve().then(function () { return require('./chunks/dep-05fcddd5.js'); }).then(function (n) { return n.index; });
|
|
14063
14063
|
try {
|
|
14064
14064
|
const config = await build.resolveConfig({
|
|
14065
14065
|
root,
|
package/dist/node/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { BuildOptions as BuildOptions_2 } from 'esbuild';
|
|
4
4
|
import { CustomPluginOptions } from 'rollup';
|
|
5
|
+
import { TransformOptions as EsbuildTransformOptions } from 'esbuild';
|
|
5
6
|
import * as events from 'events';
|
|
6
7
|
import * as fs from 'fs';
|
|
7
8
|
import * as http from 'http';
|
|
@@ -28,7 +29,6 @@ import { ServerResponse } from 'http';
|
|
|
28
29
|
import { SourceDescription } from 'rollup';
|
|
29
30
|
import { SourceMap } from 'rollup';
|
|
30
31
|
import * as stream from 'stream';
|
|
31
|
-
import { TransformOptions as TransformOptions_2 } from 'esbuild';
|
|
32
32
|
import { TransformPluginContext } from 'rollup';
|
|
33
33
|
import { TransformResult as TransformResult_2 } from 'rollup';
|
|
34
34
|
import { TransformResult as TransformResult_3 } from 'esbuild';
|
|
@@ -89,7 +89,7 @@ export declare interface BuildOptions {
|
|
|
89
89
|
* For custom targets, see https://esbuild.github.io/api/#target and
|
|
90
90
|
* https://esbuild.github.io/content-types/#javascript for more details.
|
|
91
91
|
*/
|
|
92
|
-
target?: 'modules' |
|
|
92
|
+
target?: 'modules' | EsbuildTransformOptions['target'] | false;
|
|
93
93
|
/**
|
|
94
94
|
* whether to inject module preload polyfill.
|
|
95
95
|
* Note: does not apply to library mode.
|
|
@@ -471,12 +471,14 @@ export declare interface ErrorPayload {
|
|
|
471
471
|
}
|
|
472
472
|
}
|
|
473
473
|
|
|
474
|
-
export declare interface ESBuildOptions extends
|
|
474
|
+
export declare interface ESBuildOptions extends EsbuildTransformOptions {
|
|
475
475
|
include?: string | RegExp | string[] | RegExp[];
|
|
476
476
|
exclude?: string | RegExp | string[] | RegExp[];
|
|
477
477
|
jsxInject?: string;
|
|
478
478
|
}
|
|
479
479
|
|
|
480
|
+
export { EsbuildTransformOptions }
|
|
481
|
+
|
|
480
482
|
export declare type ESBuildTransformResult = Omit<TransformResult_3, 'map'> & {
|
|
481
483
|
map: SourceMap;
|
|
482
484
|
};
|
|
@@ -1684,6 +1686,8 @@ export declare interface TransformResult {
|
|
|
1684
1686
|
dynamicDeps?: string[];
|
|
1685
1687
|
}
|
|
1686
1688
|
|
|
1689
|
+
export declare function transformWithEsbuild(code: string, filename: string, options?: EsbuildTransformOptions, inMap?: object): Promise<ESBuildTransformResult>;
|
|
1690
|
+
|
|
1687
1691
|
export declare interface Update {
|
|
1688
1692
|
type: 'js-update' | 'css-update'
|
|
1689
1693
|
path: string
|
|
@@ -1870,8 +1874,10 @@ export declare interface ViteDevServer {
|
|
|
1870
1874
|
/**
|
|
1871
1875
|
* Util for transforming a file with esbuild.
|
|
1872
1876
|
* Can be useful for certain plugins.
|
|
1877
|
+
*
|
|
1878
|
+
* @deprecated import `transformWithEsbuild` from `vite` instead
|
|
1873
1879
|
*/
|
|
1874
|
-
transformWithEsbuild(code: string, filename: string, options?:
|
|
1880
|
+
transformWithEsbuild(code: string, filename: string, options?: EsbuildTransformOptions, inMap?: object): Promise<ESBuildTransformResult>;
|
|
1875
1881
|
/**
|
|
1876
1882
|
* Load a given URL as an instantiated module for SSR.
|
|
1877
1883
|
*/
|
package/dist/node/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var build = require('./chunks/dep-
|
|
5
|
+
var build = require('./chunks/dep-05fcddd5.js');
|
|
6
6
|
require('fs');
|
|
7
7
|
require('path');
|
|
8
8
|
require('os');
|
|
@@ -47,4 +47,5 @@ exports.resolvePackageData = build.resolvePackageData;
|
|
|
47
47
|
exports.resolvePackageEntry = build.resolvePackageEntry;
|
|
48
48
|
exports.send = build.send;
|
|
49
49
|
exports.sortUserPlugins = build.sortUserPlugins;
|
|
50
|
+
exports.transformWithEsbuild = build.transformWithEsbuild;
|
|
50
51
|
//# sourceMappingURL=index.js.map
|
package/dist/node/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
package/src/node/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { build } from './build'
|
|
|
4
4
|
export { optimizeDeps } from './optimizer'
|
|
5
5
|
export { send } from './server/send'
|
|
6
6
|
export { createLogger } from './logger'
|
|
7
|
+
export { transformWithEsbuild } from './plugins/esbuild'
|
|
7
8
|
export { resolvePackageData, resolvePackageEntry } from './plugins/resolve'
|
|
8
9
|
export { normalizePath } from './utils'
|
|
9
10
|
|
|
@@ -51,6 +52,7 @@ export type {
|
|
|
51
52
|
} from './plugins/html'
|
|
52
53
|
export type { CSSOptions, CSSModulesOptions } from './plugins/css'
|
|
53
54
|
export type { JsonOptions } from './plugins/json'
|
|
55
|
+
export type { TransformOptions as EsbuildTransformOptions } from 'esbuild'
|
|
54
56
|
export type { ESBuildOptions, ESBuildTransformResult } from './plugins/esbuild'
|
|
55
57
|
export type { Manifest, ManifestChunk } from './plugins/manifest'
|
|
56
58
|
export type {
|
|
@@ -50,52 +50,70 @@ export async function transformWithEsbuild(
|
|
|
50
50
|
options?: TransformOptions,
|
|
51
51
|
inMap?: object
|
|
52
52
|
): Promise<ESBuildTransformResult> {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
let loader = options?.loader
|
|
54
|
+
|
|
55
|
+
if (!loader) {
|
|
56
|
+
// if the id ends with a valid ext, use it (e.g. vue blocks)
|
|
57
|
+
// otherwise, cleanup the query before checking the ext
|
|
58
|
+
const ext = path
|
|
59
|
+
.extname(/\.\w+$/.test(filename) ? filename : cleanUrl(filename))
|
|
60
|
+
.slice(1)
|
|
58
61
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
if (ext === 'cjs' || ext === 'mjs') {
|
|
63
|
+
loader = 'js'
|
|
64
|
+
} else {
|
|
65
|
+
loader = ext as Loader
|
|
66
|
+
}
|
|
62
67
|
}
|
|
63
68
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
69
|
+
let tsconfigRaw = options?.tsconfigRaw
|
|
70
|
+
|
|
71
|
+
// if options provide tsconfigraw in string, it takes highest precedence
|
|
72
|
+
if (typeof tsconfigRaw !== 'string') {
|
|
73
|
+
// these fields would affect the compilation result
|
|
74
|
+
// https://esbuild.github.io/content-types/#tsconfig-json
|
|
75
|
+
const meaningfulFields: Array<keyof TSCompilerOptions> = [
|
|
76
|
+
'jsxFactory',
|
|
77
|
+
'jsxFragmentFactory',
|
|
78
|
+
'useDefineForClassFields',
|
|
79
|
+
'importsNotUsedAsValues'
|
|
80
|
+
]
|
|
81
|
+
const compilerOptionsForFile: TSCompilerOptions = {}
|
|
82
|
+
if (loader === 'ts' || loader === 'tsx') {
|
|
83
|
+
const loadedTsconfig = await loadTsconfigJsonForFile(filename)
|
|
84
|
+
const loadedCompilerOptions = loadedTsconfig.compilerOptions ?? {}
|
|
85
|
+
|
|
86
|
+
for (const field of meaningfulFields) {
|
|
87
|
+
if (field in loadedCompilerOptions) {
|
|
88
|
+
// @ts-ignore TypeScript can't tell they are of the same type
|
|
89
|
+
compilerOptionsForFile[field] = loadedCompilerOptions[field]
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// align with TypeScript 4.3
|
|
94
|
+
// https://github.com/microsoft/TypeScript/pull/42663
|
|
95
|
+
if (loadedCompilerOptions.target?.toLowerCase() === 'esnext') {
|
|
96
|
+
compilerOptionsForFile.useDefineForClassFields =
|
|
97
|
+
loadedCompilerOptions.useDefineForClassFields ?? true
|
|
81
98
|
}
|
|
82
99
|
}
|
|
83
100
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
101
|
+
tsconfigRaw = {
|
|
102
|
+
...tsconfigRaw,
|
|
103
|
+
compilerOptions: {
|
|
104
|
+
...compilerOptionsForFile,
|
|
105
|
+
...tsconfigRaw?.compilerOptions
|
|
106
|
+
}
|
|
89
107
|
}
|
|
90
108
|
}
|
|
91
109
|
|
|
92
110
|
const resolvedOptions = {
|
|
93
|
-
loader: loader as Loader,
|
|
94
111
|
sourcemap: true,
|
|
95
112
|
// ensure source file name contains full query
|
|
96
113
|
sourcefile: filename,
|
|
97
|
-
|
|
98
|
-
|
|
114
|
+
...options,
|
|
115
|
+
loader,
|
|
116
|
+
tsconfigRaw
|
|
99
117
|
} as ESBuildOptions
|
|
100
118
|
|
|
101
119
|
delete resolvedOptions.include
|
package/src/node/server/index.ts
CHANGED
|
@@ -237,6 +237,8 @@ export interface ViteDevServer {
|
|
|
237
237
|
/**
|
|
238
238
|
* Util for transforming a file with esbuild.
|
|
239
239
|
* Can be useful for certain plugins.
|
|
240
|
+
*
|
|
241
|
+
* @deprecated import `transformWithEsbuild` from `vite` instead
|
|
240
242
|
*/
|
|
241
243
|
transformWithEsbuild(
|
|
242
244
|
code: string,
|