vite 3.0.0-alpha.5 → 3.0.0-alpha.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.
Files changed (80) hide show
  1. package/dist/node/chunks/{dep-0232e200.js → dep-52974b5a.js} +42 -11
  2. package/dist/node/chunks/{dep-21067347.js → dep-8bed6f50.js} +1 -1
  3. package/dist/node/chunks/{dep-cd161504.js → dep-a4f17494.js} +1 -1
  4. package/dist/node/chunks/{dep-13a14c32.js → dep-b4474709.js} +1 -1
  5. package/dist/node/cli.js +5 -5
  6. package/dist/node/constants.js +1 -1
  7. package/dist/node/index.d.ts +79 -2
  8. package/dist/node/index.js +1 -1
  9. package/package.json +3 -2
  10. package/types/es-module-lexer.d.ts +90 -0
  11. package/dist/node/build.d.ts +0 -178
  12. package/dist/node/certificate.d.ts +0 -2
  13. package/dist/node/cli.d.ts +0 -1
  14. package/dist/node/config.d.ts +0 -246
  15. package/dist/node/constants.d.ts +0 -35
  16. package/dist/node/env.d.ts +0 -3
  17. package/dist/node/http.d.ts +0 -88
  18. package/dist/node/logger.d.ts +0 -31
  19. package/dist/node/optimizer/esbuildDepPlugin.d.ts +0 -4
  20. package/dist/node/optimizer/index.d.ts +0 -181
  21. package/dist/node/optimizer/optimizer.d.ts +0 -4
  22. package/dist/node/optimizer/scan.d.ts +0 -8
  23. package/dist/node/packages.d.ts +0 -27
  24. package/dist/node/plugin.d.ts +0 -130
  25. package/dist/node/plugins/asset.d.ts +0 -68
  26. package/dist/node/plugins/assetImportMetaUrl.d.ts +0 -13
  27. package/dist/node/plugins/clientInjections.d.ts +0 -7
  28. package/dist/node/plugins/css.d.ts +0 -86
  29. package/dist/node/plugins/dataUri.d.ts +0 -5
  30. package/dist/node/plugins/define.d.ts +0 -3
  31. package/dist/node/plugins/dynamicImportVars.d.ts +0 -9
  32. package/dist/node/plugins/ensureWatch.d.ts +0 -5
  33. package/dist/node/plugins/esbuild.d.ts +0 -15
  34. package/dist/node/plugins/html.d.ts +0 -120
  35. package/dist/node/plugins/importAnalysis.d.ts +0 -47
  36. package/dist/node/plugins/importAnalysisBuild.d.ts +0 -16
  37. package/dist/node/plugins/importMetaGlob.d.ts +0 -34
  38. package/dist/node/plugins/index.d.ts +0 -3
  39. package/dist/node/plugins/json.d.ts +0 -23
  40. package/dist/node/plugins/loadFallback.d.ts +0 -5
  41. package/dist/node/plugins/manifest.d.ts +0 -14
  42. package/dist/node/plugins/metadata.d.ts +0 -9
  43. package/dist/node/plugins/modulePreloadPolyfill.d.ts +0 -4
  44. package/dist/node/plugins/optimizedDeps.d.ts +0 -7
  45. package/dist/node/plugins/preAlias.d.ts +0 -6
  46. package/dist/node/plugins/reporter.d.ts +0 -3
  47. package/dist/node/plugins/resolve.d.ts +0 -41
  48. package/dist/node/plugins/splitVendorChunk.d.ts +0 -12
  49. package/dist/node/plugins/ssrRequireHook.d.ts +0 -12
  50. package/dist/node/plugins/terser.d.ts +0 -3
  51. package/dist/node/plugins/wasm.d.ts +0 -4
  52. package/dist/node/plugins/worker.d.ts +0 -9
  53. package/dist/node/plugins/workerImportMetaUrl.d.ts +0 -3
  54. package/dist/node/preview.d.ts +0 -33
  55. package/dist/node/publicUtils.d.ts +0 -11
  56. package/dist/node/server/hmr.d.ts +0 -39
  57. package/dist/node/server/index.d.ts +0 -189
  58. package/dist/node/server/middlewares/base.d.ts +0 -3
  59. package/dist/node/server/middlewares/compression.d.ts +0 -1
  60. package/dist/node/server/middlewares/error.d.ts +0 -8
  61. package/dist/node/server/middlewares/indexHtml.d.ts +0 -4
  62. package/dist/node/server/middlewares/proxy.d.ts +0 -20
  63. package/dist/node/server/middlewares/spaFallback.d.ts +0 -2
  64. package/dist/node/server/middlewares/static.d.ts +0 -6
  65. package/dist/node/server/middlewares/time.d.ts +0 -2
  66. package/dist/node/server/middlewares/transform.d.ts +0 -3
  67. package/dist/node/server/moduleGraph.d.ts +0 -55
  68. package/dist/node/server/openBrowser.d.ts +0 -15
  69. package/dist/node/server/pluginContainer.d.ts +0 -41
  70. package/dist/node/server/searchRoot.d.ts +0 -8
  71. package/dist/node/server/send.d.ts +0 -10
  72. package/dist/node/server/sourcemap.d.ts +0 -11
  73. package/dist/node/server/transformRequest.d.ts +0 -14
  74. package/dist/node/server/ws.d.ts +0 -55
  75. package/dist/node/ssr/ssrExternal.d.ts +0 -11
  76. package/dist/node/ssr/ssrManifestPlugin.d.ts +0 -3
  77. package/dist/node/ssr/ssrModuleLoader.d.ts +0 -7
  78. package/dist/node/ssr/ssrStacktrace.d.ts +0 -3
  79. package/dist/node/ssr/ssrTransform.d.ts +0 -14
  80. package/dist/node/utils.d.ts +0 -144
@@ -26773,9 +26773,18 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
26773
26773
  (loader.startsWith('ts') ? extractImportPaths(content) : '');
26774
26774
  const key = `${path}?id=${scriptId++}`;
26775
26775
  if (contents.includes('import.meta.glob')) {
26776
+ let transpiledContents;
26777
+ // transpile because `transformGlobImport` only expects js
26778
+ if (loader !== 'js') {
26779
+ transpiledContents = (await transform$2(contents, { loader }))
26780
+ .code;
26781
+ }
26782
+ else {
26783
+ transpiledContents = contents;
26784
+ }
26776
26785
  scripts[key] = {
26777
26786
  loader: 'js',
26778
- contents: (await transformGlobImport(contents, path, config.root, resolve))?.s.toString() || contents
26787
+ contents: (await transformGlobImport(transpiledContents, path, config.root, resolve))?.s.toString() || transpiledContents
26779
26788
  };
26780
26789
  }
26781
26790
  else {
@@ -26962,6 +26971,7 @@ function getDepsOptimizer(config) {
26962
26971
  async function initDepsOptimizer(config, server) {
26963
26972
  const { logger } = config;
26964
26973
  const isBuild = config.command === 'build';
26974
+ const scan = config.command !== 'build' && config.optimizeDeps.devScan;
26965
26975
  const sessionTimestamp = Date.now().toString();
26966
26976
  const cachedMetadata = loadCachedDepOptimizationMetadata(config);
26967
26977
  let handle;
@@ -27000,7 +27010,7 @@ async function initDepsOptimizer(config, server) {
27000
27010
  // If there wasn't a cache or it is outdated, we need to prepare a first run
27001
27011
  let firstRunCalled = !!cachedMetadata;
27002
27012
  if (!cachedMetadata) {
27003
- if (isBuild) {
27013
+ if (!scan) {
27004
27014
  // Initialize discovered deps with manually added optimizeDeps.include info
27005
27015
  const discovered = await initialProjectDependencies(config, sessionTimestamp);
27006
27016
  const { metadata } = depsOptimizer;
@@ -27267,9 +27277,13 @@ async function initDepsOptimizer(config, server) {
27267
27277
  processing: depOptimizationProcessing.promise,
27268
27278
  exportsData: extractExportsData(resolved, config)
27269
27279
  });
27270
- // Debounced rerun, let other missing dependencies be discovered before
27271
- // the running next optimizeDeps
27272
- if (!isBuild) {
27280
+ // Until the first optimize run is called, avoid triggering processing
27281
+ // We'll wait until the user codebase is eagerly processed by Vite so
27282
+ // we can get a list of every missing dependency before giving to the
27283
+ // browser a dependency that may be outdated, thus avoiding full page reloads
27284
+ if (scan || firstRunCalled) {
27285
+ // Debounced rerun, let other missing dependencies be discovered before
27286
+ // the running next optimizeDeps
27273
27287
  debouncedProcessing();
27274
27288
  }
27275
27289
  // Return the path for the optimized bundle, this path is known before
@@ -35858,7 +35872,7 @@ const assetAttrsConfig = {
35858
35872
  const isAsyncScriptMap = new WeakMap();
35859
35873
  async function traverseHtml(html, filePath, visitor) {
35860
35874
  // lazy load compiler
35861
- const { parse, transform } = await import('./dep-13a14c32.js').then(function (n) { return n.c; });
35875
+ const { parse, transform } = await import('./dep-b4474709.js').then(function (n) { return n.c; });
35862
35876
  // @vue/compiler-core doesn't like lowercase doctypes
35863
35877
  html = html.replace(/<!doctype\s/i, '<!DOCTYPE ');
35864
35878
  try {
@@ -36963,7 +36977,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
36963
36977
  logger: config.logger
36964
36978
  }));
36965
36979
  if (isModule) {
36966
- postcssPlugins.unshift((await import('./dep-21067347.js').then(function (n) { return n.i; })).default({
36980
+ postcssPlugins.unshift((await import('./dep-8bed6f50.js').then(function (n) { return n.i; })).default({
36967
36981
  ...modulesOptions,
36968
36982
  getJSON(cssFileName, _modules, outputFileName) {
36969
36983
  modules = _modules;
@@ -39643,6 +39657,19 @@ function runOptimizerWhenIdle(config) {
39643
39657
  function optimizedDepsPlugin(config) {
39644
39658
  return {
39645
39659
  name: 'vite:optimized-deps',
39660
+ buildStart() {
39661
+ if (!config.isWorker) {
39662
+ initRunProcessingInfo(config);
39663
+ }
39664
+ },
39665
+ async resolveId(id) {
39666
+ if (getDepsOptimizer(config)?.isOptimizedDepFile(id)) {
39667
+ return id;
39668
+ }
39669
+ },
39670
+ // this.load({ id }) isn't implemented in PluginContainer
39671
+ // The logic to register an id to wait until it is processed
39672
+ // is in importAnalysis, see call to delayDepsOptimizerUntil
39646
39673
  async load(id) {
39647
39674
  const depsOptimizer = getDepsOptimizer(config);
39648
39675
  if (depsOptimizer?.isOptimizedDepFile(id)) {
@@ -40082,7 +40109,7 @@ function importAnalysisPlugin(config) {
40082
40109
  importedUrls.add(urlWithoutBase);
40083
40110
  if (!isDynamicImport) {
40084
40111
  // for pre-transforming
40085
- staticImportedUrls.add(urlWithoutBase);
40112
+ staticImportedUrls.add({ url: urlWithoutBase, id: resolvedId });
40086
40113
  }
40087
40114
  }
40088
40115
  else if (!importer.startsWith(clientDir) && !ssr) {
@@ -40171,10 +40198,11 @@ function importAnalysisPlugin(config) {
40171
40198
  isDebug$1 &&
40172
40199
  debug$7(`${timeFrom(start)} ${colors$1.dim(`[${importedUrls.size} imports rewritten] ${prettyImporter}`)}`);
40173
40200
  // pre-transform known direct imports
40201
+ // TODO: we should also crawl dynamic imports
40174
40202
  if (config.server.preTransformRequests && staticImportedUrls.size) {
40175
- staticImportedUrls.forEach((url) => {
40203
+ staticImportedUrls.forEach(({ url, id }) => {
40176
40204
  url = unwrapId(removeImportQuery(url)).replace(NULL_BYTE_PLACEHOLDER, '\0');
40177
- transformRequest(url, server, { ssr }).catch((e) => {
40205
+ const request = transformRequest(url, server, { ssr }).catch((e) => {
40178
40206
  if (e?.code === ERR_OUTDATED_OPTIMIZED_DEP) {
40179
40207
  // This are expected errors
40180
40208
  return;
@@ -40182,6 +40210,9 @@ function importAnalysisPlugin(config) {
40182
40210
  // Unexpected error, log the issue but avoid an unhandled exception
40183
40211
  config.logger.error(e.message);
40184
40212
  });
40213
+ if (!config.optimizeDeps.devScan) {
40214
+ delayDepsOptimizerUntil(config, id, () => request);
40215
+ }
40185
40216
  });
40186
40217
  }
40187
40218
  if (s) {
@@ -47603,7 +47634,7 @@ async function getCertificate(cacheDir) {
47603
47634
  return content;
47604
47635
  }
47605
47636
  catch {
47606
- const content = (await import('./dep-cd161504.js')).createCertificate();
47637
+ const content = (await import('./dep-a4f17494.js')).createCertificate();
47607
47638
  promises
47608
47639
  .mkdir(cacheDir, { recursive: true })
47609
47640
  .then(() => promises.writeFile(cachePath, content))
@@ -1,5 +1,5 @@
1
1
  import require$$0 from 'postcss';
2
- import { w as commonjsGlobal } from './dep-0232e200.js';
2
+ import { w as commonjsGlobal } from './dep-52974b5a.js';
3
3
  import path$2 from 'path';
4
4
  import require$$1 from 'crypto';
5
5
  import fs__default from 'fs';
@@ -1,4 +1,4 @@
1
- import { w as commonjsGlobal } from './dep-0232e200.js';
1
+ import { w as commonjsGlobal } from './dep-52974b5a.js';
2
2
  import require$$1 from 'crypto';
3
3
  import 'fs';
4
4
  import 'path';
@@ -1,4 +1,4 @@
1
- import { x as getAugmentedNamespace, y as getDefaultExportFromCjs } from './dep-0232e200.js';
1
+ import { x as getAugmentedNamespace, y as getDefaultExportFromCjs } from './dep-52974b5a.js';
2
2
 
3
3
  import { fileURLToPath as __cjs_fileURLToPath } from 'url';
4
4
  import { dirname as __cjs_dirname } from 'path';
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-0232e200.js';
3
+ import { v as colors, j as createLogger, e as resolveConfig } from './chunks/dep-52974b5a.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-0232e200.js').then(function (n) { return n.B; });
685
+ const { createServer } = await import('./chunks/dep-52974b5a.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-0232e200.js').then(function (n) { return n.A; });
731
+ const { build } = await import('./chunks/dep-52974b5a.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-0232e200.js').then(function (n) { return n.z; });
755
+ const { optimizeDeps } = await import('./chunks/dep-52974b5a.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-0232e200.js').then(function (n) { return n.C; });
778
+ const { preview } = await import('./chunks/dep-52974b5a.js').then(function (n) { return n.C; });
779
779
  try {
780
780
  const server = await preview({
781
781
  root,
@@ -1,7 +1,7 @@
1
1
  import path, { resolve } from 'path';
2
2
  import { fileURLToPath } from 'url';
3
3
 
4
- var version = "3.0.0-alpha.5";
4
+ var version = "3.0.0-alpha.6";
5
5
 
6
6
  const VERSION = version;
7
7
  const DEFAULT_MAIN_FIELDS = [
@@ -23,7 +23,6 @@ import type * as net from 'net';
23
23
  import type { OutgoingHttpHeaders } from 'http';
24
24
  import type { OutputBundle } from 'rollup';
25
25
  import type { OutputChunk } from 'rollup';
26
- import { parse } from 'es-module-lexer';
27
26
  import type { PartialResolvedId } from 'rollup';
28
27
  import type { Plugin as Plugin_3 } from 'rollup';
29
28
  import type { PluginContext } from 'rollup';
@@ -534,6 +533,13 @@ export declare interface DepOptimizationOptions {
534
533
  * vite project root. This will overwrite default entries inference.
535
534
  */
536
535
  entries?: string | string[];
536
+ /**
537
+ * Enable esbuild based scan phase, to get back to the optimized deps discovery
538
+ * strategy used in Vite v2
539
+ * @default false
540
+ * @experimental
541
+ */
542
+ devScan?: boolean;
537
543
  /**
538
544
  * Force optimize listed dependencies (must be resolvable import paths,
539
545
  * cannot be globs).
@@ -639,6 +645,77 @@ export declare type ESBuildTransformResult = Omit<TransformResult_3, 'map'> & {
639
645
  map: SourceMap;
640
646
  };
641
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
+
642
719
  export declare interface ExperimentalOptions {
643
720
  /**
644
721
  * Append fake `&lang.(ext)` when queries are specified, to preseve the file extension for following plugins to process.
@@ -649,7 +726,7 @@ export declare interface ExperimentalOptions {
649
726
  importGlobRestoreExtension?: boolean;
650
727
  }
651
728
 
652
- export declare type ExportsData = ReturnType<typeof parse> & {
729
+ export declare type ExportsData = EsModuleLexerParseReturnType & {
653
730
  hasReExports?: true;
654
731
  jsxLoader?: true;
655
732
  };
@@ -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-0232e200.js';
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-52974b5a.js';
2
2
  import 'fs';
3
3
  import 'path';
4
4
  import 'url';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "3.0.0-alpha.5",
3
+ "version": "3.0.0-alpha.6",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -49,10 +49,11 @@
49
49
  "dev": "rimraf dist && pnpm run build-bundle -w",
50
50
  "build": "rimraf dist && run-s build-bundle build-types",
51
51
  "build-bundle": "rollup --config rollup.config.ts --configPlugin typescript",
52
- "build-types": "run-s build-temp-types patch-types roll-types",
52
+ "build-types": "run-s build-temp-types patch-types roll-types check-dist-types",
53
53
  "build-temp-types": "tsc --emitDeclarationOnly --outDir temp/node -p src/node",
54
54
  "patch-types": "esno scripts/patchTypes.ts",
55
55
  "roll-types": "api-extractor run && rimraf temp",
56
+ "check-dist-types": "tsc --project tsconfig.check.json",
56
57
  "lint": "eslint --ext .ts src/**",
57
58
  "format": "prettier --write --parser typescript \"src/**/*.ts\"",
58
59
  "prepublishOnly": "npm run build"
@@ -0,0 +1,90 @@
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
+ ]
@@ -1,178 +0,0 @@
1
- import type { ModuleFormat, Plugin, RollupOptions, RollupOutput, RollupWarning, RollupWatcher, WarningHandler, WatcherOptions } from 'rollup';
2
- import type { Terser } from 'types/terser';
3
- import type { RollupCommonJSOptions } from 'types/commonjs';
4
- import type { RollupDynamicImportVarsOptions } from 'types/dynamicImportVars';
5
- import type { TransformOptions } from 'esbuild';
6
- import type { InlineConfig, ResolvedConfig } from './config';
7
- export interface BuildOptions {
8
- /**
9
- * Compatibility transform target. The transform is performed with esbuild
10
- * and the lowest supported target is es2015/es6. Note this only handles
11
- * syntax transformation and does not cover polyfills (except for dynamic
12
- * import)
13
- *
14
- * Default: 'modules' - Similar to `@babel/preset-env`'s targets.esmodules,
15
- * transpile targeting browsers that natively support dynamic es module imports.
16
- * https://caniuse.com/es6-module-dynamic-import
17
- *
18
- * Another special value is 'esnext' - which only performs minimal transpiling
19
- * (for minification compat) and assumes native dynamic imports support.
20
- *
21
- * For custom targets, see https://esbuild.github.io/api/#target and
22
- * https://esbuild.github.io/content-types/#javascript for more details.
23
- */
24
- target?: 'modules' | TransformOptions['target'] | false;
25
- /**
26
- * whether to inject module preload polyfill.
27
- * Note: does not apply to library mode.
28
- * @default true
29
- */
30
- polyfillModulePreload?: boolean;
31
- /**
32
- * Directory relative from `root` where build output will be placed. If the
33
- * directory exists, it will be removed before the build.
34
- * @default 'dist'
35
- */
36
- outDir?: string;
37
- /**
38
- * Directory relative from `outDir` where the built js/css/image assets will
39
- * be placed.
40
- * @default 'assets'
41
- */
42
- assetsDir?: string;
43
- /**
44
- * Static asset files smaller than this number (in bytes) will be inlined as
45
- * base64 strings. Default limit is `4096` (4kb). Set to `0` to disable.
46
- * @default 4096
47
- */
48
- assetsInlineLimit?: number;
49
- /**
50
- * Whether to code-split CSS. When enabled, CSS in async chunks will be
51
- * inlined as strings in the chunk and inserted via dynamically created
52
- * style tags when the chunk is loaded.
53
- * @default true
54
- */
55
- cssCodeSplit?: boolean;
56
- /**
57
- * An optional separate target for CSS minification.
58
- * As esbuild only supports configuring targets to mainstream
59
- * browsers, users may need this option when they are targeting
60
- * a niche browser that comes with most modern JavaScript features
61
- * but has poor CSS support, e.g. Android WeChat WebView, which
62
- * doesn't support the #RGBA syntax.
63
- */
64
- cssTarget?: TransformOptions['target'] | false;
65
- /**
66
- * If `true`, a separate sourcemap file will be created. If 'inline', the
67
- * sourcemap will be appended to the resulting output file as data URI.
68
- * 'hidden' works like `true` except that the corresponding sourcemap
69
- * comments in the bundled files are suppressed.
70
- * @default false
71
- */
72
- sourcemap?: boolean | 'inline' | 'hidden';
73
- /**
74
- * Set to `false` to disable minification, or specify the minifier to use.
75
- * Available options are 'terser' or 'esbuild'.
76
- * @default 'esbuild'
77
- */
78
- minify?: boolean | 'terser' | 'esbuild';
79
- /**
80
- * Options for terser
81
- * https://terser.org/docs/api-reference#minify-options
82
- */
83
- terserOptions?: Terser.MinifyOptions;
84
- /**
85
- * Will be merged with internal rollup options.
86
- * https://rollupjs.org/guide/en/#big-list-of-options
87
- */
88
- rollupOptions?: RollupOptions;
89
- /**
90
- * Options to pass on to `@rollup/plugin-commonjs`
91
- */
92
- commonjsOptions?: RollupCommonJSOptions;
93
- /**
94
- * Options to pass on to `@rollup/plugin-dynamic-import-vars`
95
- */
96
- dynamicImportVarsOptions?: RollupDynamicImportVarsOptions;
97
- /**
98
- * Whether to write bundle to disk
99
- * @default true
100
- */
101
- write?: boolean;
102
- /**
103
- * Empty outDir on write.
104
- * @default true when outDir is a sub directory of project root
105
- */
106
- emptyOutDir?: boolean | null;
107
- /**
108
- * Whether to emit a manifest.json under assets dir to map hash-less filenames
109
- * to their hashed versions. Useful when you want to generate your own HTML
110
- * instead of using the one generated by Vite.
111
- *
112
- * Example:
113
- *
114
- * ```json
115
- * {
116
- * "main.js": {
117
- * "file": "main.68fe3fad.js",
118
- * "css": "main.e6b63442.css",
119
- * "imports": [...],
120
- * "dynamicImports": [...]
121
- * }
122
- * }
123
- * ```
124
- * @default false
125
- */
126
- manifest?: boolean | string;
127
- /**
128
- * Build in library mode. The value should be the global name of the lib in
129
- * UMD mode. This will produce esm + cjs + umd bundle formats with default
130
- * configurations that are suitable for distributing libraries.
131
- */
132
- lib?: LibraryOptions | false;
133
- /**
134
- * Produce SSR oriented build. Note this requires specifying SSR entry via
135
- * `rollupOptions.input`.
136
- */
137
- ssr?: boolean | string;
138
- /**
139
- * Generate SSR manifest for determining style links and asset preload
140
- * directives in production.
141
- */
142
- ssrManifest?: boolean | string;
143
- /**
144
- * Set to false to disable reporting compressed chunk sizes.
145
- * Can slightly improve build speed.
146
- */
147
- reportCompressedSize?: boolean;
148
- /**
149
- * Adjust chunk size warning limit (in kbs).
150
- * @default 500
151
- */
152
- chunkSizeWarningLimit?: number;
153
- /**
154
- * Rollup watch options
155
- * https://rollupjs.org/guide/en/#watchoptions
156
- */
157
- watch?: WatcherOptions | null;
158
- }
159
- export interface LibraryOptions {
160
- entry: string;
161
- name?: string;
162
- formats?: LibraryFormats[];
163
- fileName?: string | ((format: ModuleFormat) => string);
164
- }
165
- export declare type LibraryFormats = 'es' | 'cjs' | 'umd' | 'iife';
166
- export declare type ResolvedBuildOptions = Required<BuildOptions>;
167
- export declare function resolveBuildOptions(raw?: BuildOptions): ResolvedBuildOptions;
168
- export declare function resolveBuildPlugins(config: ResolvedConfig): {
169
- pre: Plugin[];
170
- post: Plugin[];
171
- };
172
- /**
173
- * Bundles the app for production.
174
- * Returns a Promise containing the build result.
175
- */
176
- export declare function build(inlineConfig?: InlineConfig): Promise<RollupOutput | RollupOutput[] | RollupWatcher>;
177
- export declare function resolveLibFilename(libOptions: LibraryOptions, format: ModuleFormat, root: string): string;
178
- export declare function onRollupWarning(warning: RollupWarning, warn: WarningHandler, config: ResolvedConfig): void;
@@ -1,2 +0,0 @@
1
- import 'node-forge/lib/pki';
2
- export declare function createCertificate(): string;
@@ -1 +0,0 @@
1
- export {};