diff --git a/compiler/package.json b/compiler/package.json index 075a5ac32da15dbd157b627ed6211fc1e5d7b4e9..0be7accf29368c082af1cd41fb2f51a9bcddcea0 100644 --- a/compiler/package.json +++ b/compiler/package.json @@ -13,13 +13,13 @@ "build": "npm run generateDeclarations && ./node_modules/.bin/babel ./src --out-dir lib --extensions .ts && node uglify-source.js lib", "create": "node ./lib/create.js --env projectName", "compile": "webpack --config webpack.config.js --env buildMode=debug projectName", - "test": "npm run build && mocha test/test.js && mocha test/test.js --partialUpdate", + "test": "npm run build && mocha test/test.js && mocha test/test.js --partialUpdate && npm run arkTest", "generateDeclarations": "node ./build_declarations_file.js ../../../interface/sdk-js/api/@internal/component/ets ./declarations ./lib", "postinstall": "node npm-install.js", "fastbuild": "rollup -c rollup.config.js", "run:arkTest": "mocha \"arkTest_build/ark_compiler_ut/**/*.test.js\"", "run:cleanArkTest": "rm -rf arkTest_build", - "arkTest": "npm run build && ./node_modules/.bin/babel ./test/ark_compiler_ut --out-dir arkTest_build/ark_compiler_ut --extensions .ts && npm run run:arkTest && npm run run:cleanArkTest" + "arkTest": "./node_modules/.bin/babel ./test/ark_compiler_ut --out-dir arkTest_build/ark_compiler_ut --extensions .ts && npm run run:arkTest && npm run run:cleanArkTest" }, "devDependencies": { "@babel/cli": "7.20.7", diff --git a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts index 83d7c2ad70ffd1d89694ea33245a31ce1be72a0c..a2be1dd7307312baf9636badbaa3619b544ba156 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts @@ -125,8 +125,12 @@ export class ModuleSourceFile { moduleInfo.getNodeByType(ROLLUP_IMPORT_NODE, ROLLUP_EXPORTNAME_NODE, ROLLUP_EXPORTALL_NODE, ROLLUP_DYNAMICIMPORT_NODE); + let hasDynamicImport: boolean = false; for (let nodeSet of moduleNodeMap.values()) { nodeSet.forEach(node => { + if (!hasDynamicImport && node.type === ROLLUP_DYNAMICIMPORT_NODE) { + hasDynamicImport = true; + } if (node.source) { if (node.source.type === ROLLUP_LITERAL_NODE) { const ohmUrl: string | undefined = @@ -143,16 +147,18 @@ export class ModuleSourceFile { }); } - // update sourceMap - const relativeSourceFilePath = - toUnixPath(this.moduleId.replace(ModuleSourceFile.projectConfig.projectRootPath + path.sep, '')); - const updatedMap = code.generateMap({ - source: relativeSourceFilePath, - file: `${path.basename(this.moduleId)}`, - includeContent: false, - hires: true - }); - newSourceMaps[relativeSourceFilePath] = await updateSourceMap(newSourceMaps[relativeSourceFilePath], updatedMap); + if (hasDynamicImport) { + // update sourceMap + const relativeSourceFilePath: string = + toUnixPath(this.moduleId.replace(ModuleSourceFile.projectConfig.projectRootPath + path.sep, '')); + const updatedMap: any = code.generateMap({ + source: relativeSourceFilePath, + file: `${path.basename(this.moduleId)}`, + includeContent: false, + hires: true + }); + newSourceMaps[relativeSourceFilePath] = await updateSourceMap(newSourceMaps[relativeSourceFilePath], updatedMap); + } this.source = code.toString(); }