diff --git a/ace-loader/src/gen-abc.js b/ace-loader/src/gen-abc.js index a52b3def7f76552204cceeb7b688819adfb03deb..dac39c0a760f65a3cadecaea8df6c4ce7ff09fe1 100644 --- a/ace-loader/src/gen-abc.js +++ b/ace-loader/src/gen-abc.js @@ -20,8 +20,6 @@ const SUCCESS = 0; const FAIL = 1; const red = '\u001b[31m'; const reset = '\u001b[39m'; -const TS2ABC = 'ts2abc'; -const ES2ABC = 'es2abc'; function js2abcByWorkers(jsonInput, cmd) { const inputPaths = JSON.parse(jsonInput); @@ -30,7 +28,8 @@ function js2abcByWorkers(jsonInput, cmd) { const input = inputPaths[i].path.replace(/\.temp\.js$/, "_.js"); const cacheOutputPath = inputPaths[i].cacheOutputPath; const cacheAbcFilePath = cacheOutputPath.replace(/\.temp\.js$/, ".abc"); - const singleCmd = `${cmd} "${cacheOutputPath}" -o "${cacheAbcFilePath}" --source-file "${input}"`; + const sourceFile = inputPaths[i].sourceFile; + const singleCmd = `${cmd} "${cacheOutputPath}" -o "${cacheAbcFilePath}" --source-file "${sourceFile}"`; try { childProcess.execSync(singleCmd); } catch (e) { diff --git a/ace-loader/src/genAbc-plugin.js b/ace-loader/src/genAbc-plugin.js index a0d7b1f8bc70528cdec9885bb54c3d485a8888ed..d63f10b399417f09a0d4cb536e2f8a10f1d6dce0 100644 --- a/ace-loader/src/genAbc-plugin.js +++ b/ace-loader/src/genAbc-plugin.js @@ -198,9 +198,18 @@ function writeFileSync(inputString, buildPath, keyPath, jsBundleFile, isToBin) { fs.writeFileSync(cacheOutputPath, inputString); if (fs.existsSync(cacheOutputPath)) { let fileSize = fs.statSync(cacheOutputPath).size; + let sourceFile = output.replace(/\.temp\.js$/, "_.js"); + if (!isDebug && (process.env.aceBuildJson && fs.existsSync(process.env.aceBuildJson))) { + const buildJsonInfo = JSON.parse(fs.readFileSync(process.env.aceBuildJson).toString()); + sourceFile = toUnixPath(sourceFile.replace(buildJsonInfo.projectRootPath + path.sep, '')); + } else { + sourceFile = toUnixPath(sourceFile); + } output = toUnixPath(output); cacheOutputPath = toUnixPath(cacheOutputPath); - intermediateJsBundle.push({path: output, size: fileSize, cacheOutputPath: cacheOutputPath}); + intermediateJsBundle.push({ + path: output, size: fileSize, cacheOutputPath: cacheOutputPath, sourceFile: sourceFile + }); } else { console.debug(red, `ERROR Failed to convert file ${jsBundleFile} to bin. ${output} is lost`, reset); process.exitCode = FAIL; @@ -679,7 +688,7 @@ function generateFileOfBundle(inputPaths) { const cacheOutputPath = info.cacheOutputPath; const recordName = 'null_recordName'; const moduleType = 'script'; - const sourceFile = info.path.replace(/\.temp\.js$/, "_.js"); + const sourceFile = info.sourceFile; const abcFilePath = cacheOutputPath.replace(/\.temp\.js$/, ".abc"); filesInfo += `${cacheOutputPath};${recordName};${moduleType};${sourceFile};${abcFilePath}\n`; });