@dcloudio/uni-cli-shared 3.0.0-alpha-3030520211229002 → 3.0.0-alpha-3030520211229003

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.
@@ -58,5 +58,12 @@ export declare function parseScriptDescriptor(filename: string, ast: Program, op
58
58
  * @param dynamicImport
59
59
  * @returns
60
60
  */
61
- export declare function transformDynamicImports(code: string, imports: ImportDeclaration[], dynamicImport: (name: string, source: string) => string): Promise<string>;
61
+ export declare function transformDynamicImports(code: string, imports: ImportDeclaration[], { id, sourceMap, dynamicImport, }: {
62
+ id?: string;
63
+ sourceMap?: boolean;
64
+ dynamicImport: (name: string, source: string) => string;
65
+ }): Promise<{
66
+ code: string;
67
+ map: null;
68
+ }>;
62
69
  export {};
@@ -376,15 +376,21 @@ async function parseVueComponentImports(importer, imports, resolve) {
376
376
  * @param dynamicImport
377
377
  * @returns
378
378
  */
379
- async function transformDynamicImports(code, imports, dynamicImport) {
379
+ async function transformDynamicImports(code, imports, { id, sourceMap, dynamicImport, }) {
380
380
  if (!imports.length) {
381
- return code;
381
+ return {
382
+ code,
383
+ map: null,
384
+ };
382
385
  }
383
386
  const s = new magic_string_1.default(code);
384
387
  for (let i = 0; i < imports.length; i++) {
385
388
  const { start, end, specifiers: [specifier], source, } = imports[i];
386
389
  s.overwrite(start, end, dynamicImport(specifier.local.name, source.value) + ';');
387
390
  }
388
- return s.toString();
391
+ return {
392
+ code: s.toString(),
393
+ map: null,
394
+ };
389
395
  }
390
396
  exports.transformDynamicImports = transformDynamicImports;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
+ import type { OutputOptions, PluginContext, RenderedChunk } from 'rollup';
2
3
  import { Plugin } from '../plugin';
3
4
  import { ResolvedConfig } from '../config';
4
- import type { OutputOptions, PluginContext, RenderedChunk } from 'rollup';
5
5
  export declare const assetUrlRE: RegExp;
6
6
  export declare const chunkToEmittedAssetsMap: WeakMap<RenderedChunk, Set<string>>;
7
7
  /**
@@ -27,9 +27,10 @@ const path_1 = __importDefault(require("path"));
27
27
  const url_1 = require("url");
28
28
  const lite_1 = __importDefault(require("mime/lite"));
29
29
  const fs_1 = __importStar(require("fs"));
30
- const utils_1 = require("../utils");
31
30
  const magic_string_1 = __importDefault(require("magic-string"));
32
31
  const crypto_1 = require("crypto");
32
+ const utils_1 = require("../utils");
33
+ const utils_2 = require("../../../../vite/utils/utils");
33
34
  exports.assetUrlRE = /__VITE_ASSET__([a-z\d]{8})__(?:\$_(.*?)__)?/g;
34
35
  // urls in JS must be quoted as strings, so when replacing them we need
35
36
  // a different regex
@@ -99,7 +100,7 @@ function assetPlugin(config) {
99
100
  if (s) {
100
101
  return {
101
102
  code: s.toString(),
102
- map: config.build.sourcemap ? s.generateMap({ hires: true }) : null,
103
+ map: (0, utils_2.withSourcemap)(config) ? s.generateMap({ hires: true }) : null,
103
104
  };
104
105
  }
105
106
  else {
@@ -2,5 +2,6 @@ import type { ResolvedConfig } from 'vite';
2
2
  export * from './ast';
3
3
  export * from './url';
4
4
  export * from './plugin';
5
+ export * from './utils';
5
6
  export declare const buildInCssSet: Set<string>;
6
7
  export declare function isCombineBuiltInCss(config: ResolvedConfig): boolean;
@@ -14,6 +14,7 @@ exports.isCombineBuiltInCss = exports.buildInCssSet = void 0;
14
14
  __exportStar(require("./ast"), exports);
15
15
  __exportStar(require("./url"), exports);
16
16
  __exportStar(require("./plugin"), exports);
17
+ __exportStar(require("./utils"), exports);
17
18
  // 内置组件css列表,h5平台需要合并进去首页css中
18
19
  exports.buildInCssSet = new Set();
19
20
  function isCombineBuiltInCss(config) {
@@ -0,0 +1,2 @@
1
+ import type { ResolvedConfig } from 'vite';
2
+ export declare function withSourcemap(config: ResolvedConfig): boolean;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withSourcemap = void 0;
4
+ function withSourcemap(config) {
5
+ if (config.command === 'serve') {
6
+ return true;
7
+ }
8
+ return !!config.build.sourcemap;
9
+ }
10
+ exports.withSourcemap = withSourcemap;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "3.0.0-alpha-3030520211229002",
3
+ "version": "3.0.0-alpha-3030520211229003",
4
4
  "description": "@dcloudio/uni-cli-shared",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -21,8 +21,8 @@
21
21
  "@babel/core": "^7.16.5",
22
22
  "@babel/parser": "^7.16.4",
23
23
  "@babel/types": "^7.16.0",
24
- "@dcloudio/uni-i18n": "3.0.0-alpha-3030520211229002",
25
- "@dcloudio/uni-shared": "3.0.0-alpha-3030520211229002",
24
+ "@dcloudio/uni-i18n": "3.0.0-alpha-3030520211229003",
25
+ "@dcloudio/uni-shared": "3.0.0-alpha-3030520211229003",
26
26
  "@rollup/pluginutils": "^4.1.2",
27
27
  "@vue/compiler-core": "3.2.26",
28
28
  "@vue/compiler-dom": "3.2.26",