vite 4.0.0-beta.3 → 4.0.0-beta.4

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.
@@ -1,6 +1,6 @@
1
1
  import require$$0__default from 'fs';
2
2
  import require$$0 from 'postcss';
3
- import { B as commonjsGlobal } from './dep-704b2c30.js';
3
+ import { C as commonjsGlobal } from './dep-3f45d7c9.js';
4
4
  import require$$0$1 from 'path';
5
5
  import require$$5 from 'crypto';
6
6
  import require$$0$2 from 'util';
package/dist/node/cli.js CHANGED
@@ -2,7 +2,7 @@ import path from 'node:path';
2
2
  import fs from 'node:fs';
3
3
  import { performance } from 'node:perf_hooks';
4
4
  import { EventEmitter } from 'events';
5
- import { A as picocolors, w as createLogger, h as resolveConfig } from './chunks/dep-704b2c30.js';
5
+ import { A as picocolors, B as bindShortcuts, w as createLogger, h as resolveConfig } from './chunks/dep-3f45d7c9.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:url';
8
8
  import 'node:module';
@@ -34,8 +34,8 @@ import 'node:http';
34
34
  import 'node:https';
35
35
  import 'rollup';
36
36
  import 'querystring';
37
- import 'node:readline';
38
37
  import 'node:child_process';
38
+ import 'node:readline';
39
39
  import 'node:zlib';
40
40
 
41
41
  function toArr(any) {
@@ -652,22 +652,27 @@ class CAC extends EventEmitter {
652
652
  const cac = (name = "") => new CAC(name);
653
653
 
654
654
  const cli = cac('vite');
655
+ // @ts-ignore
656
+ let profileSession = global.__vite_profile_session;
657
+ let profileCount = 0;
655
658
  const stopProfiler = (log) => {
656
- // @ts-ignore
657
- const profileSession = global.__vite_profile_session;
658
- if (profileSession) {
659
+ if (!profileSession)
660
+ return;
661
+ return new Promise((res, rej) => {
659
662
  profileSession.post('Profiler.stop', (err, { profile }) => {
660
663
  // Write profile to disk, upload, etc.
661
664
  if (!err) {
662
- const outPath = path.resolve('./vite-profile.cpuprofile');
665
+ const outPath = path.resolve(`./vite-profile-${profileCount++}.cpuprofile`);
663
666
  fs.writeFileSync(outPath, JSON.stringify(profile));
664
667
  log(picocolors.exports.yellow(`CPU profile written to ${picocolors.exports.white(picocolors.exports.dim(outPath))}`));
668
+ profileSession = undefined;
669
+ res();
665
670
  }
666
671
  else {
667
- throw err;
672
+ rej(err);
668
673
  }
669
674
  });
670
- }
675
+ });
671
676
  };
672
677
  const filterDuplicateOptions = (options) => {
673
678
  for (const [key, value] of Object.entries(options)) {
@@ -720,7 +725,7 @@ cli
720
725
  filterDuplicateOptions(options);
721
726
  // output structure is preserved even after bundling so require()
722
727
  // is ok here
723
- const { createServer } = await import('./chunks/dep-704b2c30.js').then(function (n) { return n.E; });
728
+ const { createServer } = await import('./chunks/dep-3f45d7c9.js').then(function (n) { return n.F; });
724
729
  try {
725
730
  const server = await createServer({
726
731
  root,
@@ -744,7 +749,33 @@ cli
744
749
  : '';
745
750
  info(`\n ${picocolors.exports.green(`${picocolors.exports.bold('VITE')} v${VERSION}`)} ${startupDurationString}\n`, { clear: !server.config.logger.hasWarned });
746
751
  server.printUrls();
747
- stopProfiler((message) => server.config.logger.info(` ${message}`));
752
+ bindShortcuts(server, {
753
+ print: true,
754
+ customShortcuts: [
755
+ profileSession && {
756
+ key: 'p',
757
+ description: 'start/stop the profiler',
758
+ async action(server) {
759
+ if (profileSession) {
760
+ await stopProfiler(server.config.logger.info);
761
+ }
762
+ else {
763
+ const inspector = await import('node:inspector').then((r) => r.default);
764
+ await new Promise((res) => {
765
+ profileSession = new inspector.Session();
766
+ profileSession.connect();
767
+ profileSession.post('Profiler.enable', () => {
768
+ profileSession.post('Profiler.start', () => {
769
+ server.config.logger.info('Profiler started');
770
+ res();
771
+ });
772
+ });
773
+ });
774
+ }
775
+ },
776
+ },
777
+ ],
778
+ });
748
779
  }
749
780
  catch (e) {
750
781
  const logger = createLogger(options.logLevel);
@@ -773,7 +804,7 @@ cli
773
804
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
774
805
  .action(async (root, options) => {
775
806
  filterDuplicateOptions(options);
776
- const { build } = await import('./chunks/dep-704b2c30.js').then(function (n) { return n.D; });
807
+ const { build } = await import('./chunks/dep-3f45d7c9.js').then(function (n) { return n.E; });
777
808
  const buildOptions = cleanOptions(options);
778
809
  try {
779
810
  await build({
@@ -801,7 +832,7 @@ cli
801
832
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
802
833
  .action(async (root, options) => {
803
834
  filterDuplicateOptions(options);
804
- const { optimizeDeps } = await import('./chunks/dep-704b2c30.js').then(function (n) { return n.C; });
835
+ const { optimizeDeps } = await import('./chunks/dep-3f45d7c9.js').then(function (n) { return n.D; });
805
836
  try {
806
837
  const config = await resolveConfig({
807
838
  root,
@@ -826,7 +857,7 @@ cli
826
857
  .option('--outDir <dir>', `[string] output directory (default: dist)`)
827
858
  .action(async (root, options) => {
828
859
  filterDuplicateOptions(options);
829
- const { preview } = await import('./chunks/dep-704b2c30.js').then(function (n) { return n.F; });
860
+ const { preview } = await import('./chunks/dep-3f45d7c9.js').then(function (n) { return n.G; });
830
861
  try {
831
862
  const server = await preview({
832
863
  root,
@@ -2590,6 +2590,7 @@ export declare interface ViteDevServer {
2590
2590
  /* Excluded from this release type: _forceOptimizeOnRestart */
2591
2591
  /* Excluded from this release type: _pendingRequests */
2592
2592
  /* Excluded from this release type: _fsDenyGlob */
2593
+ /* Excluded from this release type: _shortcutsOptions */
2593
2594
  }
2594
2595
 
2595
2596
  export declare interface WatchOptions {
@@ -1,4 +1,4 @@
1
- export { b as build, e as buildErrorMessage, u as createFilter, w as createLogger, c as createServer, g as defineConfig, f as formatPostcssSourceMap, j as getDepOptimizationConfig, k as isDepsOptimizerEnabled, l as loadConfigFromFile, y as loadEnv, q as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, i as resolveBaseUrl, h as resolveConfig, z as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, x as searchForWorkspaceRoot, v as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-704b2c30.js';
1
+ export { b as build, e as buildErrorMessage, u as createFilter, w as createLogger, c as createServer, g as defineConfig, f as formatPostcssSourceMap, j as getDepOptimizationConfig, k as isDepsOptimizerEnabled, l as loadConfigFromFile, y as loadEnv, q as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, i as resolveBaseUrl, h as resolveConfig, z as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, x as searchForWorkspaceRoot, v as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-3f45d7c9.js';
2
2
  export { VERSION as version } from './constants.js';
3
3
  export { version as esbuildVersion } from 'esbuild';
4
4
  export { VERSION as rollupVersion } from 'rollup';
@@ -34,8 +34,8 @@ import 'tls';
34
34
  import 'node:http';
35
35
  import 'node:https';
36
36
  import 'querystring';
37
- import 'node:readline';
38
37
  import 'node:child_process';
38
+ import 'node:readline';
39
39
  import 'node:zlib';
40
40
 
41
41
  // This file will be built for both ESM and CJS. Avoid relying on other modules as possible.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "4.0.0-beta.3",
3
+ "version": "4.0.0-beta.4",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",