vite 2.9.8 → 2.9.11

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,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var require$$0 = require('postcss');
4
- var index$1 = require('./dep-e1fc1d62.js');
4
+ var index$1 = require('./dep-97cb3622.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
@@ -1,28 +1,28 @@
1
1
  'use strict';
2
2
 
3
- var require$$0 = require('events');
4
- var index = require('./chunks/dep-e1fc1d62.js');
5
3
  var perf_hooks = require('perf_hooks');
4
+ var require$$0 = require('events');
5
+ var index = require('./chunks/dep-97cb3622.js');
6
6
  require('fs');
7
7
  require('path');
8
+ require('url');
8
9
  require('tty');
10
+ require('os');
11
+ require('esbuild');
12
+ require('assert');
13
+ require('resolve');
9
14
  require('util');
15
+ require('stream');
10
16
  require('net');
11
- require('url');
12
17
  require('http');
13
- require('stream');
14
- require('os');
15
- require('resolve');
18
+ require('child_process');
16
19
  require('module');
17
- require('https');
18
- require('zlib');
19
20
  require('crypto');
20
- require('tls');
21
- require('assert');
22
21
  require('buffer');
23
22
  require('querystring');
24
- require('esbuild');
25
- require('child_process');
23
+ require('zlib');
24
+ require('https');
25
+ require('tls');
26
26
  require('worker_threads');
27
27
  require('readline');
28
28
 
@@ -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-e1fc1d62.js'); }).then(function (n) { return n.index$1; });
686
+ const { createServer } = await Promise.resolve().then(function () { return require('./chunks/dep-97cb3622.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-e1fc1d62.js'); }).then(function (n) { return n.build$1; });
735
+ const { build } = await Promise.resolve().then(function () { return require('./chunks/dep-97cb3622.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-e1fc1d62.js'); }).then(function (n) { return n.index; });
758
+ const { optimizeDeps } = await Promise.resolve().then(function () { return require('./chunks/dep-97cb3622.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-e1fc1d62.js'); }).then(function (n) { return n.preview$1; });
781
+ const { preview } = await Promise.resolve().then(function () { return require('./chunks/dep-97cb3622.js'); }).then(function (n) { return n.preview$1; });
782
782
  try {
783
783
  const server = await preview({
784
784
  root,
@@ -1309,6 +1309,15 @@ export declare interface Plugin extends Plugin_2 {
1309
1309
  * are applied. Hook can be async functions and will be called in series.
1310
1310
  */
1311
1311
  configureServer?: ServerHook;
1312
+ /**
1313
+ * Configure the preview server. The hook receives the connect server and
1314
+ * its underlying http server.
1315
+ *
1316
+ * The hooks are called before other middlewares are applied. A hook can
1317
+ * return a post hook that will be called after other middlewares are
1318
+ * applied. Hooks can be async functions and will be called in series.
1319
+ */
1320
+ configurePreviewServer?: PreviewServerHook;
1312
1321
  /**
1313
1322
  * Transform index.html.
1314
1323
  * The hook receives the following arguments:
@@ -1402,6 +1411,11 @@ export declare interface PreviewServer {
1402
1411
  printUrls: () => void;
1403
1412
  }
1404
1413
 
1414
+ export declare type PreviewServerHook = (server: {
1415
+ middlewares: Connect.Server;
1416
+ httpServer: http.Server;
1417
+ }) => (() => void) | void | Promise<(() => void) | void>;
1418
+
1405
1419
  /**
1406
1420
  * @deprecated Use `server.printUrls()` instead
1407
1421
  */
@@ -2,29 +2,29 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./chunks/dep-e1fc1d62.js');
5
+ var index = require('./chunks/dep-97cb3622.js');
6
6
  require('fs');
7
7
  require('path');
8
+ require('url');
9
+ require('perf_hooks');
8
10
  require('tty');
11
+ require('os');
12
+ require('esbuild');
13
+ require('events');
14
+ require('assert');
15
+ require('resolve');
9
16
  require('util');
17
+ require('stream');
10
18
  require('net');
11
- require('events');
12
- require('url');
13
19
  require('http');
14
- require('stream');
15
- require('os');
16
- require('resolve');
20
+ require('child_process');
17
21
  require('module');
18
- require('perf_hooks');
19
- require('https');
20
- require('zlib');
21
22
  require('crypto');
22
- require('tls');
23
- require('assert');
24
23
  require('buffer');
25
24
  require('querystring');
26
- require('esbuild');
27
- require('child_process');
25
+ require('zlib');
26
+ require('https');
27
+ require('tls');
28
28
  require('worker_threads');
29
29
  require('readline');
30
30
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "2.9.8",
3
+ "version": "2.9.11",
4
4
  "license": "MIT",
5
5
  "author": "Evan You",
6
6
  "description": "Native-ESM powered web dev build tool",
@@ -112,6 +112,7 @@
112
112
  "source-map-js": "^1.0.2",
113
113
  "source-map-support": "^0.5.21",
114
114
  "strip-ansi": "^6.0.1",
115
+ "strip-literal": "^0.2.0",
115
116
  "terser": "^5.13.1",
116
117
  "tsconfck": "^1.2.2",
117
118
  "tslib": "^2.4.0",
@@ -87,7 +87,18 @@ async function handleMessage(payload: HMRPayload) {
87
87
  const newPath = `${base}${searchUrl.slice(1)}${
88
88
  searchUrl.includes('?') ? '&' : '?'
89
89
  }t=${timestamp}`
90
- el.href = new URL(newPath, el.href).href
90
+
91
+ // rather than swapping the href on the existing tag, we will
92
+ // create a new link tag. Once the new stylesheet has loaded we
93
+ // will remove the existing link tag. This removes a Flash Of
94
+ // Unstyled Content that can occur when swapping out the tag href
95
+ // directly, as the new stylesheet has not yet been loaded.
96
+ const newLinkTag = el.cloneNode() as HTMLLinkElement
97
+ newLinkTag.href = new URL(newPath, el.href).href
98
+ const removeOldEl = () => el.remove()
99
+ newLinkTag.addEventListener('load', removeOldEl)
100
+ newLinkTag.addEventListener('error', removeOldEl)
101
+ el.after(newLinkTag)
91
102
  }
92
103
  console.log(`[vite] css hot updated: ${searchUrl}`)
93
104
  }
package/types/shims.d.ts CHANGED
@@ -28,7 +28,7 @@ declare module 'launch-editor-middleware' {
28
28
  }
29
29
 
30
30
  declare module 'postcss-load-config' {
31
- import type { ProcessOptions, Plugin } from 'postcss'
31
+ import type { Plugin, ProcessOptions } from 'postcss'
32
32
  function load(
33
33
  inline: any,
34
34
  root: string
package/types/ws.d.ts CHANGED
@@ -20,9 +20,9 @@ import type {
20
20
  Agent,
21
21
  ClientRequest,
22
22
  ClientRequestArgs,
23
+ Server as HTTPServer,
23
24
  IncomingMessage,
24
- OutgoingHttpHeaders,
25
- Server as HTTPServer
25
+ OutgoingHttpHeaders
26
26
  } from 'http'
27
27
  import type { Server as HTTPSServer } from 'https'
28
28
  import type { Duplex, DuplexOptions } from 'stream'