vite 2.9.0-beta.2 → 2.9.0-beta.6
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/LICENSE.md +1 -1
- package/dist/node/chunks/{dep-183d31dd.js → dep-00d6c1ad.js} +115 -7
- package/dist/node/chunks/{dep-ec2e68f4.js → dep-5633cdf8.js} +0 -0
- package/dist/node/chunks/{dep-c4c66661.js → dep-5ae06c1f.js} +1 -1
- package/dist/node/chunks/{dep-6ae84d6b.js → dep-7a3b37e3.js} +2762 -1389
- package/dist/node/chunks/{dep-ce77a218.js → dep-b1024ee7.js} +3 -3
- package/dist/node/cli.js +5 -5
- package/dist/node/index.d.ts +65 -35
- package/dist/node/index.js +2 -1
- package/dist/node/terser.js +90 -15
- package/package.json +20 -19
- package/types/ws.d.ts +54 -29
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var require$$0 = require('postcss');
|
|
4
|
-
var index$1 = require('./dep-
|
|
4
|
+
var index$1 = require('./dep-7a3b37e3.js');
|
|
5
5
|
var path$2 = require('path');
|
|
6
6
|
var require$$1 = require('crypto');
|
|
7
7
|
var fs = require('fs');
|
|
@@ -7304,8 +7304,8 @@ function getDefaultPlugins({
|
|
|
7304
7304
|
const scope = (0, _postcssModulesScope2.default)({ generateScopedName, exportGlobals });
|
|
7305
7305
|
|
|
7306
7306
|
const plugins = {
|
|
7307
|
-
[behaviours.LOCAL]: [_postcssModulesValues2.default, _postcssModulesLocalByDefault2.default, _postcssModulesExtractImports2.default, scope],
|
|
7308
|
-
[behaviours.GLOBAL]: [_postcssModulesValues2.default, _postcssModulesExtractImports2.default, scope]
|
|
7307
|
+
[behaviours.LOCAL]: [_postcssModulesValues2.default, (0, _postcssModulesLocalByDefault2.default)({ mode: 'local' }), _postcssModulesExtractImports2.default, scope],
|
|
7308
|
+
[behaviours.GLOBAL]: [_postcssModulesValues2.default, (0, _postcssModulesLocalByDefault2.default)({ mode: 'global' }), _postcssModulesExtractImports2.default, scope]
|
|
7309
7309
|
};
|
|
7310
7310
|
|
|
7311
7311
|
return plugins[behaviour];
|
package/dist/node/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var require$$0 = require('events');
|
|
4
|
-
var index = require('./chunks/dep-
|
|
4
|
+
var index = require('./chunks/dep-7a3b37e3.js');
|
|
5
5
|
var perf_hooks = require('perf_hooks');
|
|
6
6
|
require('fs');
|
|
7
7
|
require('path');
|
|
@@ -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-
|
|
686
|
+
const { createServer } = await Promise.resolve().then(function () { return require('./chunks/dep-7a3b37e3.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-
|
|
735
|
+
const { build } = await Promise.resolve().then(function () { return require('./chunks/dep-7a3b37e3.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-
|
|
758
|
+
const { optimizeDeps } = await Promise.resolve().then(function () { return require('./chunks/dep-7a3b37e3.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-
|
|
781
|
+
const { preview } = await Promise.resolve().then(function () { return require('./chunks/dep-7a3b37e3.js'); }).then(function (n) { return n.preview$1; });
|
|
782
782
|
try {
|
|
783
783
|
const server = await preview({
|
|
784
784
|
root,
|
package/dist/node/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import type { DuplexOptions } from 'stream';
|
|
|
10
10
|
import { TransformOptions as EsbuildTransformOptions } from 'esbuild';
|
|
11
11
|
import { EventEmitter } from 'events';
|
|
12
12
|
import * as events from 'events';
|
|
13
|
+
import type { ExistingRawSourceMap } from 'rollup';
|
|
13
14
|
import type * as fs from 'fs';
|
|
14
15
|
import type { GetManualChunk } from 'rollup';
|
|
15
16
|
import * as http from 'http';
|
|
@@ -517,14 +518,13 @@ export declare interface DepOptimizationMetadata {
|
|
|
517
518
|
*/
|
|
518
519
|
optimized: Record<string, OptimizedDepInfo>;
|
|
519
520
|
/**
|
|
520
|
-
* Metadata for
|
|
521
|
+
* Metadata for non-entry optimized chunks and dynamic imports
|
|
521
522
|
*/
|
|
522
|
-
|
|
523
|
+
chunks: Record<string, OptimizedDepInfo>;
|
|
523
524
|
/**
|
|
524
|
-
*
|
|
525
|
-
* but the bundles may not yet be saved to disk
|
|
525
|
+
* Metadata for each newly discovered dependency after processing
|
|
526
526
|
*/
|
|
527
|
-
|
|
527
|
+
discovered: Record<string, OptimizedDepInfo>;
|
|
528
528
|
}
|
|
529
529
|
|
|
530
530
|
export declare interface DepOptimizationOptions {
|
|
@@ -579,8 +579,8 @@ export declare interface DepOptimizationOptions {
|
|
|
579
579
|
}
|
|
580
580
|
|
|
581
581
|
export declare interface DepOptimizationProcessing {
|
|
582
|
-
promise: Promise<
|
|
583
|
-
resolve: (
|
|
582
|
+
promise: Promise<void>;
|
|
583
|
+
resolve: () => void;
|
|
584
584
|
}
|
|
585
585
|
|
|
586
586
|
export declare interface DepOptimizationResult {
|
|
@@ -591,6 +591,13 @@ export declare interface DepOptimizationResult {
|
|
|
591
591
|
* for large applications
|
|
592
592
|
*/
|
|
593
593
|
alteredFiles: boolean;
|
|
594
|
+
/**
|
|
595
|
+
* When doing a re-run, if there are newly discovered dependendencies
|
|
596
|
+
* the page reload will be delayed until the next rerun so the
|
|
597
|
+
* result will be discarded
|
|
598
|
+
*/
|
|
599
|
+
commit: () => void;
|
|
600
|
+
cancel: () => void;
|
|
594
601
|
}
|
|
595
602
|
|
|
596
603
|
export declare interface ErrorPayload {
|
|
@@ -652,6 +659,8 @@ export declare interface FileSystemServeOptions {
|
|
|
652
659
|
deny?: string[];
|
|
653
660
|
}
|
|
654
661
|
|
|
662
|
+
export declare function formatPostcssSourceMap(rawMap: ExistingRawSourceMap, file: string): ExistingRawSourceMap;
|
|
663
|
+
|
|
655
664
|
export declare class FSWatcher extends EventEmitter implements fs.FSWatcher {
|
|
656
665
|
options: WatchOptions
|
|
657
666
|
|
|
@@ -1180,7 +1189,7 @@ export declare interface OptimizedDepInfo {
|
|
|
1180
1189
|
* During optimization, ids can still be resolved to their final location
|
|
1181
1190
|
* but the bundles may not yet be saved to disk
|
|
1182
1191
|
*/
|
|
1183
|
-
processing
|
|
1192
|
+
processing?: Promise<void>;
|
|
1184
1193
|
}
|
|
1185
1194
|
|
|
1186
1195
|
/**
|
|
@@ -2310,6 +2319,8 @@ export declare class WebSocket extends EventEmitter {
|
|
|
2310
2319
|
binaryType: 'nodebuffer' | 'arraybuffer' | 'fragments'
|
|
2311
2320
|
readonly bufferedAmount: number
|
|
2312
2321
|
readonly extensions: string
|
|
2322
|
+
/** Indicates whether the websocket is paused */
|
|
2323
|
+
readonly isPaused: boolean
|
|
2313
2324
|
readonly protocol: string
|
|
2314
2325
|
/** The current state of the connection */
|
|
2315
2326
|
readonly readyState:
|
|
@@ -2328,11 +2339,12 @@ export declare class WebSocket extends EventEmitter {
|
|
|
2328
2339
|
/** The connection is closed. */
|
|
2329
2340
|
readonly CLOSED: 3
|
|
2330
2341
|
|
|
2331
|
-
onopen: (event: WebSocket.Event) => void
|
|
2332
|
-
onerror: (event: WebSocket.ErrorEvent) => void
|
|
2333
|
-
onclose: (event: WebSocket.CloseEvent) => void
|
|
2334
|
-
onmessage: (event: WebSocket.MessageEvent) => void
|
|
2342
|
+
onopen: ((event: WebSocket.Event) => void) | null
|
|
2343
|
+
onerror: ((event: WebSocket.ErrorEvent) => void) | null
|
|
2344
|
+
onclose: ((event: WebSocket.CloseEvent) => void) | null
|
|
2345
|
+
onmessage: ((event: WebSocket.MessageEvent) => void) | null
|
|
2335
2346
|
|
|
2347
|
+
constructor(address: null)
|
|
2336
2348
|
constructor(
|
|
2337
2349
|
address: string | URL_2,
|
|
2338
2350
|
options?: WebSocket.ClientOptions | ClientRequestArgs
|
|
@@ -2359,6 +2371,18 @@ export declare class WebSocket extends EventEmitter {
|
|
|
2359
2371
|
): void
|
|
2360
2372
|
terminate(): void
|
|
2361
2373
|
|
|
2374
|
+
/**
|
|
2375
|
+
* Pause the websocket causing it to stop emitting events. Some events can still be
|
|
2376
|
+
* emitted after this is called, until all buffered data is consumed. This method
|
|
2377
|
+
* is a noop if the ready state is `CONNECTING` or `CLOSED`.
|
|
2378
|
+
*/
|
|
2379
|
+
pause(): void
|
|
2380
|
+
/**
|
|
2381
|
+
* Make a paused socket resume emitting events. This method is a noop if the ready
|
|
2382
|
+
* state is `CONNECTING` or `CLOSED`.
|
|
2383
|
+
*/
|
|
2384
|
+
resume(): void
|
|
2385
|
+
|
|
2362
2386
|
// HTML5 WebSocket events
|
|
2363
2387
|
addEventListener(
|
|
2364
2388
|
method: 'message',
|
|
@@ -2595,6 +2619,7 @@ export declare namespace WebSocket {
|
|
|
2595
2619
|
export interface ClientOptions extends SecureContextOptions {
|
|
2596
2620
|
protocol?: string | undefined
|
|
2597
2621
|
followRedirects?: boolean | undefined
|
|
2622
|
+
generateMask?(mask: Buffer): void
|
|
2598
2623
|
handshakeTimeout?: number | undefined
|
|
2599
2624
|
maxRedirects?: number | undefined
|
|
2600
2625
|
perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined
|
|
@@ -2608,6 +2633,7 @@ export declare namespace WebSocket {
|
|
|
2608
2633
|
checkServerIdentity?(servername: string, cert: CertMeta): boolean
|
|
2609
2634
|
rejectUnauthorized?: boolean | undefined
|
|
2610
2635
|
maxPayload?: number | undefined
|
|
2636
|
+
skipUTF8Validation?: boolean | undefined
|
|
2611
2637
|
}
|
|
2612
2638
|
|
|
2613
2639
|
export interface PerMessageDeflateOptions {
|
|
@@ -2682,6 +2708,7 @@ export declare namespace WebSocket {
|
|
|
2682
2708
|
perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined
|
|
2683
2709
|
maxPayload?: number | undefined
|
|
2684
2710
|
skipUTF8Validation?: boolean | undefined
|
|
2711
|
+
WebSocket?: typeof WebSocket.WebSocket | undefined
|
|
2685
2712
|
}
|
|
2686
2713
|
|
|
2687
2714
|
export interface AddressInfo {
|
|
@@ -2691,10 +2718,10 @@ export declare namespace WebSocket {
|
|
|
2691
2718
|
}
|
|
2692
2719
|
|
|
2693
2720
|
// WebSocket Server
|
|
2694
|
-
export class Server extends EventEmitter {
|
|
2721
|
+
export class Server<T extends WebSocket = WebSocket> extends EventEmitter {
|
|
2695
2722
|
options: ServerOptions
|
|
2696
2723
|
path: string
|
|
2697
|
-
clients: Set<
|
|
2724
|
+
clients: Set<T>
|
|
2698
2725
|
|
|
2699
2726
|
constructor(options?: ServerOptions, callback?: () => void)
|
|
2700
2727
|
|
|
@@ -2704,56 +2731,59 @@ export declare namespace WebSocket {
|
|
|
2704
2731
|
request: IncomingMessage,
|
|
2705
2732
|
socket: Duplex,
|
|
2706
2733
|
upgradeHead: Buffer,
|
|
2707
|
-
callback: (client:
|
|
2734
|
+
callback: (client: T, request: IncomingMessage) => void
|
|
2708
2735
|
): void
|
|
2709
2736
|
shouldHandle(request: IncomingMessage): boolean | Promise<boolean>
|
|
2710
2737
|
|
|
2711
2738
|
// Events
|
|
2712
2739
|
on(
|
|
2713
2740
|
event: 'connection',
|
|
2714
|
-
cb: (this: Server
|
|
2741
|
+
cb: (this: Server<T>, socket: T, request: IncomingMessage) => void
|
|
2715
2742
|
): this
|
|
2716
|
-
on(event: 'error', cb: (this: Server
|
|
2743
|
+
on(event: 'error', cb: (this: Server<T>, error: Error) => void): this
|
|
2717
2744
|
on(
|
|
2718
2745
|
event: 'headers',
|
|
2719
|
-
cb: (this: Server
|
|
2746
|
+
cb: (this: Server<T>, headers: string[], request: IncomingMessage) => void
|
|
2720
2747
|
): this
|
|
2721
|
-
on(event: 'close' | 'listening', cb: (this: Server) => void): this
|
|
2748
|
+
on(event: 'close' | 'listening', cb: (this: Server<T>) => void): this
|
|
2722
2749
|
on(
|
|
2723
2750
|
event: string | symbol,
|
|
2724
|
-
listener: (this: Server
|
|
2751
|
+
listener: (this: Server<T>, ...args: any[]) => void
|
|
2725
2752
|
): this
|
|
2726
2753
|
|
|
2727
2754
|
once(
|
|
2728
2755
|
event: 'connection',
|
|
2729
|
-
cb: (this: Server
|
|
2756
|
+
cb: (this: Server<T>, socket: T, request: IncomingMessage) => void
|
|
2730
2757
|
): this
|
|
2731
|
-
once(event: 'error', cb: (this: Server
|
|
2758
|
+
once(event: 'error', cb: (this: Server<T>, error: Error) => void): this
|
|
2732
2759
|
once(
|
|
2733
2760
|
event: 'headers',
|
|
2734
|
-
cb: (this: Server
|
|
2761
|
+
cb: (this: Server<T>, headers: string[], request: IncomingMessage) => void
|
|
2762
|
+
): this
|
|
2763
|
+
once(event: 'close' | 'listening', cb: (this: Server<T>) => void): this
|
|
2764
|
+
once(
|
|
2765
|
+
event: string | symbol,
|
|
2766
|
+
listener: (this: Server<T>, ...args: any[]) => void
|
|
2735
2767
|
): this
|
|
2736
|
-
once(event: 'close' | 'listening', cb: (this: Server) => void): this
|
|
2737
|
-
once(event: string | symbol, listener: (...args: any[]) => void): this
|
|
2738
2768
|
|
|
2739
2769
|
off(
|
|
2740
2770
|
event: 'connection',
|
|
2741
|
-
cb: (this: Server
|
|
2771
|
+
cb: (this: Server<T>, socket: T, request: IncomingMessage) => void
|
|
2742
2772
|
): this
|
|
2743
|
-
off(event: 'error', cb: (this: Server
|
|
2773
|
+
off(event: 'error', cb: (this: Server<T>, error: Error) => void): this
|
|
2744
2774
|
off(
|
|
2745
2775
|
event: 'headers',
|
|
2746
|
-
cb: (this: Server
|
|
2776
|
+
cb: (this: Server<T>, headers: string[], request: IncomingMessage) => void
|
|
2747
2777
|
): this
|
|
2748
|
-
off(event: 'close' | 'listening', cb: (this: Server) => void): this
|
|
2778
|
+
off(event: 'close' | 'listening', cb: (this: Server<T>) => void): this
|
|
2749
2779
|
off(
|
|
2750
2780
|
event: string | symbol,
|
|
2751
|
-
listener: (this: Server
|
|
2781
|
+
listener: (this: Server<T>, ...args: any[]) => void
|
|
2752
2782
|
): this
|
|
2753
2783
|
|
|
2754
2784
|
addListener(
|
|
2755
2785
|
event: 'connection',
|
|
2756
|
-
cb: (client:
|
|
2786
|
+
cb: (client: T, request: IncomingMessage) => void
|
|
2757
2787
|
): this
|
|
2758
2788
|
addListener(event: 'error', cb: (err: Error) => void): this
|
|
2759
2789
|
addListener(
|
|
@@ -2766,7 +2796,7 @@ export declare namespace WebSocket {
|
|
|
2766
2796
|
listener: (...args: any[]) => void
|
|
2767
2797
|
): this
|
|
2768
2798
|
|
|
2769
|
-
removeListener(event: 'connection', cb: (client:
|
|
2799
|
+
removeListener(event: 'connection', cb: (client: T) => void): this
|
|
2770
2800
|
removeListener(event: 'error', cb: (err: Error) => void): this
|
|
2771
2801
|
removeListener(
|
|
2772
2802
|
event: 'headers',
|
|
@@ -2780,9 +2810,9 @@ export declare namespace WebSocket {
|
|
|
2780
2810
|
}
|
|
2781
2811
|
|
|
2782
2812
|
const WebSocketServer: typeof Server
|
|
2783
|
-
export
|
|
2813
|
+
export interface WebSocketServer extends Server {} // tslint:disable-line no-empty-interface
|
|
2784
2814
|
const WebSocket: typeof WebSocketAlias
|
|
2785
|
-
export
|
|
2815
|
+
export interface WebSocket extends WebSocketAlias {} // tslint:disable-line no-empty-interface
|
|
2786
2816
|
|
|
2787
2817
|
// WebSocket stream
|
|
2788
2818
|
export function createWebSocketStream(
|
|
@@ -2793,7 +2823,7 @@ export declare namespace WebSocket {
|
|
|
2793
2823
|
|
|
2794
2824
|
export declare const WebSocketAlias: typeof WebSocket;
|
|
2795
2825
|
|
|
2796
|
-
export declare
|
|
2826
|
+
export declare interface WebSocketAlias extends WebSocket {}
|
|
2797
2827
|
|
|
2798
2828
|
export declare interface WebSocketServer {
|
|
2799
2829
|
on: WebSocket.Server['on'];
|
package/dist/node/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('./chunks/dep-
|
|
5
|
+
var index = require('./chunks/dep-7a3b37e3.js');
|
|
6
6
|
require('fs');
|
|
7
7
|
require('path');
|
|
8
8
|
require('tty');
|
|
@@ -137,6 +137,7 @@ exports.build = index.build;
|
|
|
137
137
|
exports.createLogger = index.createLogger;
|
|
138
138
|
exports.createServer = index.createServer;
|
|
139
139
|
exports.defineConfig = index.defineConfig;
|
|
140
|
+
exports.formatPostcssSourceMap = index.formatPostcssSourceMap;
|
|
140
141
|
exports.loadConfigFromFile = index.loadConfigFromFile;
|
|
141
142
|
exports.loadEnv = index.loadEnv;
|
|
142
143
|
exports.mergeConfig = index.mergeConfig;
|
package/dist/node/terser.js
CHANGED
|
@@ -10201,7 +10201,7 @@ function is_some_comments(comment) {
|
|
|
10201
10201
|
// multiline comment
|
|
10202
10202
|
return (
|
|
10203
10203
|
(comment.type === "comment2" || comment.type === "comment1")
|
|
10204
|
-
&& /@preserve|@lic|@cc_on|^\**!/i.test(comment.value)
|
|
10204
|
+
&& /@preserve|@copyright|@lic|@cc_on|^\**!/i.test(comment.value)
|
|
10205
10205
|
);
|
|
10206
10206
|
}
|
|
10207
10207
|
|
|
@@ -10314,8 +10314,8 @@ function OutputStream(options) {
|
|
|
10314
10314
|
var OUTPUT = new Rope();
|
|
10315
10315
|
let printed_comments = new Set();
|
|
10316
10316
|
|
|
10317
|
-
var to_utf8 = options.ascii_only ? function(str, identifier) {
|
|
10318
|
-
if (options.ecma >= 2015 && !options.safari10) {
|
|
10317
|
+
var to_utf8 = options.ascii_only ? function(str, identifier = false, regexp = false) {
|
|
10318
|
+
if (options.ecma >= 2015 && !options.safari10 && !regexp) {
|
|
10319
10319
|
str = str.replace(/[\ud800-\udbff][\udc00-\udfff]/g, function(ch) {
|
|
10320
10320
|
var code = get_full_char_code(ch, 0).toString(16);
|
|
10321
10321
|
return "\\u{" + code + "}";
|
|
@@ -11127,7 +11127,8 @@ function OutputStream(options) {
|
|
|
11127
11127
|
var p = output.parent();
|
|
11128
11128
|
if (this.args.length === 0
|
|
11129
11129
|
&& (p instanceof AST_PropAccess // (new Date).getTime(), (new Date)["getTime"]()
|
|
11130
|
-
|| p instanceof AST_Call && p.expression === this
|
|
11130
|
+
|| p instanceof AST_Call && p.expression === this
|
|
11131
|
+
|| p instanceof AST_PrefixedTemplateString && p.prefix === this)) // (new foo)(bar)
|
|
11131
11132
|
return true;
|
|
11132
11133
|
});
|
|
11133
11134
|
|
|
@@ -12242,7 +12243,7 @@ function OutputStream(options) {
|
|
|
12242
12243
|
flags = flags ? sort_regexp_flags(flags) : "";
|
|
12243
12244
|
source = source.replace(r_slash_script, slash_script_replace);
|
|
12244
12245
|
|
|
12245
|
-
output.print(output.to_utf8(`/${source}/${flags}
|
|
12246
|
+
output.print(output.to_utf8(`/${source}/${flags}`, false, true));
|
|
12246
12247
|
|
|
12247
12248
|
const parent = output.parent();
|
|
12248
12249
|
if (
|
|
@@ -12666,6 +12667,11 @@ const MASK_EXPORT_WANT_MANGLE = 1 << 1;
|
|
|
12666
12667
|
|
|
12667
12668
|
let function_defs = null;
|
|
12668
12669
|
let unmangleable_names = null;
|
|
12670
|
+
/**
|
|
12671
|
+
* When defined, there is a function declaration somewhere that's inside of a block.
|
|
12672
|
+
* See https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html#sec-block-level-function-declarations-web-legacy-compatibility-semantics
|
|
12673
|
+
*/
|
|
12674
|
+
let scopes_with_block_defuns = null;
|
|
12669
12675
|
|
|
12670
12676
|
class SymbolDef {
|
|
12671
12677
|
constructor(scope, orig, init) {
|
|
@@ -13216,6 +13222,15 @@ AST_Scope.DEFMETHOD("def_variable", function(symbol, init) {
|
|
|
13216
13222
|
});
|
|
13217
13223
|
|
|
13218
13224
|
function next_mangled(scope, options) {
|
|
13225
|
+
let defun_scope;
|
|
13226
|
+
if (
|
|
13227
|
+
scopes_with_block_defuns
|
|
13228
|
+
&& (defun_scope = scope.get_defun_scope())
|
|
13229
|
+
&& scopes_with_block_defuns.has(defun_scope)
|
|
13230
|
+
) {
|
|
13231
|
+
scope = defun_scope;
|
|
13232
|
+
}
|
|
13233
|
+
|
|
13219
13234
|
var ext = scope.enclosed;
|
|
13220
13235
|
var nth_identifier = options.nth_identifier;
|
|
13221
13236
|
out: while (true) {
|
|
@@ -13350,6 +13365,13 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
|
|
|
13350
13365
|
lname = save_nesting;
|
|
13351
13366
|
return true; // don't descend again in TreeWalker
|
|
13352
13367
|
}
|
|
13368
|
+
if (
|
|
13369
|
+
node instanceof AST_Defun
|
|
13370
|
+
&& !(tw.parent() instanceof AST_Scope)
|
|
13371
|
+
) {
|
|
13372
|
+
scopes_with_block_defuns = scopes_with_block_defuns || new Set();
|
|
13373
|
+
scopes_with_block_defuns.add(node.parent_scope.get_defun_scope());
|
|
13374
|
+
}
|
|
13353
13375
|
if (node instanceof AST_Scope) {
|
|
13354
13376
|
node.variables.forEach(collect);
|
|
13355
13377
|
return;
|
|
@@ -13398,6 +13420,7 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
|
|
|
13398
13420
|
|
|
13399
13421
|
function_defs = null;
|
|
13400
13422
|
unmangleable_names = null;
|
|
13423
|
+
scopes_with_block_defuns = null;
|
|
13401
13424
|
|
|
13402
13425
|
function collect(symbol) {
|
|
13403
13426
|
if (symbol.export & MASK_EXPORT_DONT_MANGLE) {
|
|
@@ -30781,7 +30804,54 @@ function cache_to_json(cache) {
|
|
|
30781
30804
|
};
|
|
30782
30805
|
}
|
|
30783
30806
|
|
|
30784
|
-
|
|
30807
|
+
function log_input(files, options, fs, debug_folder) {
|
|
30808
|
+
if (!(fs && fs.writeFileSync && fs.mkdirSync)) {
|
|
30809
|
+
return;
|
|
30810
|
+
}
|
|
30811
|
+
|
|
30812
|
+
try {
|
|
30813
|
+
fs.mkdirSync(debug_folder);
|
|
30814
|
+
} catch (e) {
|
|
30815
|
+
if (e.code !== "EEXIST") throw e;
|
|
30816
|
+
}
|
|
30817
|
+
|
|
30818
|
+
const log_path = `${debug_folder}/terser-debug-${(Math.random() * 9999999) | 0}.log`;
|
|
30819
|
+
|
|
30820
|
+
options = options || {};
|
|
30821
|
+
|
|
30822
|
+
const options_str = JSON.stringify(options, (_key, thing) => {
|
|
30823
|
+
if (typeof thing === "function") return "[Function " + thing.toString() + "]";
|
|
30824
|
+
if (thing instanceof RegExp) return "[RegExp " + thing.toString() + "]";
|
|
30825
|
+
return thing;
|
|
30826
|
+
}, 4);
|
|
30827
|
+
|
|
30828
|
+
const files_str = (file) => {
|
|
30829
|
+
if (typeof file === "object" && options.parse && options.parse.spidermonkey) {
|
|
30830
|
+
return JSON.stringify(file, null, 2);
|
|
30831
|
+
} else if (typeof file === "object") {
|
|
30832
|
+
return Object.keys(file)
|
|
30833
|
+
.map((key) => key + ": " + files_str(file[key]))
|
|
30834
|
+
.join("\n\n");
|
|
30835
|
+
} else if (typeof file === "string") {
|
|
30836
|
+
return "```\n" + file + "\n```";
|
|
30837
|
+
} else {
|
|
30838
|
+
return file; // What do?
|
|
30839
|
+
}
|
|
30840
|
+
};
|
|
30841
|
+
|
|
30842
|
+
fs.writeFileSync(log_path, "Options: \n" + options_str + "\n\nInput files:\n\n" + files_str(files) + "\n");
|
|
30843
|
+
}
|
|
30844
|
+
|
|
30845
|
+
async function minify(files, options, _fs_module) {
|
|
30846
|
+
if (
|
|
30847
|
+
_fs_module
|
|
30848
|
+
&& typeof process === "object"
|
|
30849
|
+
&& process.env
|
|
30850
|
+
&& typeof process.env.TERSER_DEBUG_DIR === "string"
|
|
30851
|
+
) {
|
|
30852
|
+
log_input(files, options, _fs_module, process.env.TERSER_DEBUG_DIR);
|
|
30853
|
+
}
|
|
30854
|
+
|
|
30785
30855
|
options = defaults(options, {
|
|
30786
30856
|
compress: {},
|
|
30787
30857
|
ecma: undefined,
|
|
@@ -30804,6 +30874,7 @@ async function minify(files, options) {
|
|
|
30804
30874
|
warnings: false,
|
|
30805
30875
|
wrap: false,
|
|
30806
30876
|
}, true);
|
|
30877
|
+
|
|
30807
30878
|
var timings = options.timings && {
|
|
30808
30879
|
start: Date.now()
|
|
30809
30880
|
};
|
|
@@ -31205,7 +31276,7 @@ async function run_cli({ program, packageJson, fs, path }) {
|
|
|
31205
31276
|
|
|
31206
31277
|
let result;
|
|
31207
31278
|
try {
|
|
31208
|
-
result = await minify(files, options);
|
|
31279
|
+
result = await minify(files, options, fs);
|
|
31209
31280
|
} catch (ex) {
|
|
31210
31281
|
if (ex.name == "SyntaxError") {
|
|
31211
31282
|
print_error("Parse error at " + ex.filename + ":" + ex.line + "," + ex.col);
|
|
@@ -31268,14 +31339,18 @@ async function run_cli({ program, packageJson, fs, path }) {
|
|
|
31268
31339
|
}, 2));
|
|
31269
31340
|
} else if (program.output == "spidermonkey") {
|
|
31270
31341
|
try {
|
|
31271
|
-
const minified = await minify(
|
|
31272
|
-
|
|
31273
|
-
|
|
31274
|
-
|
|
31275
|
-
|
|
31276
|
-
|
|
31277
|
-
|
|
31278
|
-
|
|
31342
|
+
const minified = await minify(
|
|
31343
|
+
result.code,
|
|
31344
|
+
{
|
|
31345
|
+
compress: false,
|
|
31346
|
+
mangle: false,
|
|
31347
|
+
format: {
|
|
31348
|
+
ast: true,
|
|
31349
|
+
code: false
|
|
31350
|
+
}
|
|
31351
|
+
},
|
|
31352
|
+
fs
|
|
31353
|
+
);
|
|
31279
31354
|
console.log(JSON.stringify(minified.ast.to_mozilla_ast(), null, 2));
|
|
31280
31355
|
} catch (ex) {
|
|
31281
31356
|
fatal(ex);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite",
|
|
3
|
-
"version": "2.9.0-beta.
|
|
3
|
+
"version": "2.9.0-beta.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Evan You",
|
|
6
6
|
"description": "Native-ESM powered web dev build tool",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
},
|
|
44
44
|
"//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"esbuild": "^0.14.
|
|
47
|
-
"postcss": "^8.4.
|
|
46
|
+
"esbuild": "^0.14.27",
|
|
47
|
+
"postcss": "^8.4.12",
|
|
48
48
|
"resolve": "^1.22.0",
|
|
49
49
|
"rollup": "^2.59.0"
|
|
50
50
|
},
|
|
@@ -52,17 +52,17 @@
|
|
|
52
52
|
"fsevents": "~2.3.2"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@ampproject/remapping": "^2.1.
|
|
56
|
-
"@babel/parser": "^7.17.
|
|
55
|
+
"@ampproject/remapping": "^2.1.2",
|
|
56
|
+
"@babel/parser": "^7.17.8",
|
|
57
57
|
"@babel/types": "^7.17.0",
|
|
58
|
-
"@jridgewell/trace-mapping": "^0.3.
|
|
58
|
+
"@jridgewell/trace-mapping": "^0.3.4",
|
|
59
59
|
"@rollup/plugin-alias": "^3.1.9",
|
|
60
|
-
"@rollup/plugin-commonjs": "^21.0.
|
|
60
|
+
"@rollup/plugin-commonjs": "^21.0.2",
|
|
61
61
|
"@rollup/plugin-dynamic-import-vars": "^1.4.2",
|
|
62
62
|
"@rollup/plugin-json": "^4.1.0",
|
|
63
63
|
"@rollup/plugin-node-resolve": "13.1.3",
|
|
64
|
-
"@rollup/plugin-typescript": "^8.3.
|
|
65
|
-
"@rollup/pluginutils": "^4.
|
|
64
|
+
"@rollup/plugin-typescript": "^8.3.1",
|
|
65
|
+
"@rollup/pluginutils": "^4.2.0",
|
|
66
66
|
"@types/convert-source-map": "^1.5.2",
|
|
67
67
|
"@types/cross-spawn": "^6.0.2",
|
|
68
68
|
"@types/debug": "^4.1.7",
|
|
@@ -71,12 +71,12 @@
|
|
|
71
71
|
"@types/less": "^3.0.3",
|
|
72
72
|
"@types/micromatch": "^4.0.2",
|
|
73
73
|
"@types/mime": "^2.0.3",
|
|
74
|
-
"@types/node": "^16.11.
|
|
74
|
+
"@types/node": "^16.11.26",
|
|
75
75
|
"@types/resolve": "^1.20.1",
|
|
76
76
|
"@types/sass": "~1.43.1",
|
|
77
77
|
"@types/stylus": "^0.48.36",
|
|
78
|
-
"@types/ws": "^8.
|
|
79
|
-
"@vue/compiler-dom": "^3.2.
|
|
78
|
+
"@types/ws": "^8.5.3",
|
|
79
|
+
"@vue/compiler-dom": "^3.2.31",
|
|
80
80
|
"acorn": "^8.7.0",
|
|
81
81
|
"cac": "6.7.9",
|
|
82
82
|
"chokidar": "^3.5.3",
|
|
@@ -85,33 +85,34 @@
|
|
|
85
85
|
"convert-source-map": "^1.8.0",
|
|
86
86
|
"cors": "^2.8.5",
|
|
87
87
|
"cross-spawn": "^7.0.3",
|
|
88
|
-
"debug": "^4.3.
|
|
88
|
+
"debug": "^4.3.4",
|
|
89
89
|
"dotenv": "^14.3.2",
|
|
90
90
|
"dotenv-expand": "^5.1.0",
|
|
91
|
-
"es-module-lexer": "^0.
|
|
91
|
+
"es-module-lexer": "^0.10.4",
|
|
92
92
|
"estree-walker": "^2.0.2",
|
|
93
93
|
"etag": "^1.8.1",
|
|
94
94
|
"fast-glob": "^3.2.11",
|
|
95
95
|
"http-proxy": "^1.18.1",
|
|
96
|
-
"json5": "^2.2.
|
|
96
|
+
"json5": "^2.2.1",
|
|
97
97
|
"launch-editor-middleware": "^2.3.0",
|
|
98
|
-
"magic-string": "^0.
|
|
98
|
+
"magic-string": "^0.26.1",
|
|
99
99
|
"micromatch": "^4.0.4",
|
|
100
100
|
"mrmime": "^1.0.0",
|
|
101
|
-
"node-forge": "^1.
|
|
101
|
+
"node-forge": "^1.3.0",
|
|
102
102
|
"okie": "^1.0.1",
|
|
103
103
|
"open": "^8.4.0",
|
|
104
104
|
"periscopic": "^2.0.3",
|
|
105
105
|
"picocolors": "^1.0.0",
|
|
106
106
|
"postcss-import": "^14.0.2",
|
|
107
107
|
"postcss-load-config": "^3.1.3",
|
|
108
|
-
"postcss-modules": "^4.3.
|
|
108
|
+
"postcss-modules": "^4.3.1",
|
|
109
109
|
"resolve.exports": "^1.1.0",
|
|
110
110
|
"rollup-plugin-license": "^2.6.1",
|
|
111
111
|
"sirv": "^2.0.2",
|
|
112
|
+
"source-map-js": "^1.0.2",
|
|
112
113
|
"source-map-support": "^0.5.21",
|
|
113
114
|
"strip-ansi": "^6.0.1",
|
|
114
|
-
"terser": "^5.
|
|
115
|
+
"terser": "^5.12.1",
|
|
115
116
|
"tsconfck": "^1.2.0",
|
|
116
117
|
"tslib": "^2.3.1",
|
|
117
118
|
"types": "link:./types",
|