This is an automated email from the ASF dual-hosted git repository.

shenyi pushed a commit to branch enhance-workflow
in repository https://gitbox.apache.org/repos/asf/echarts.git

commit 017a90ce374a1a55df065d0b830cec0b92ce2b84
Author: pissang <[email protected]>
AuthorDate: Tue Apr 20 20:23:03 2021 +0800

    chore: add DTS test in the workflow.
    
    Also throw error when TS compile error.
---
 .github/workflows/nodejs.yml |  3 +++
 build/pre-publish.js         | 24 +++---------------------
 2 files changed, 6 insertions(+), 21 deletions(-)

diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml
index 20354b8..38c7ce5 100644
--- a/.github/workflows/nodejs.yml
+++ b/.github/workflows/nodejs.yml
@@ -28,6 +28,9 @@ jobs:
       - name: build release
         run: |
           npm run release
+      - name: test generated DTS
+        run: |
+          npm run test:dts
 
   # test:
   #   runs-on: ubuntu-latest
diff --git a/build/pre-publish.js b/build/pre-publish.js
index b4f1097..0c5e350 100644
--- a/build/pre-publish.js
+++ b/build/pre-publish.js
@@ -206,7 +206,9 @@ async function runTsCompile(localTs, compilerOptions, 
srcPathList) {
             
console.log(chalk.red(localTs.flattenDiagnosticMessageText(diagnostic.messageText,
 '\n')));
         }
     });
-    assert(!emitResult.emitSkipped, 'ts compile failed.');
+    if (allDiagnostics.length > 0) {
+        throw new Error('TypeScript Compile Failed')
+    }
 }
 module.exports.runTsCompile = runTsCompile;
 
@@ -270,26 +272,6 @@ async function transformDistributionFiles(rooltFolder, 
replacement) {
     }
 }
 
-/**
- * Remove __esModule mark.
- *
- * In the 4.x version. The exported CJS don't have __esModule mark.
- * Developers can use `import echarts from 'echarts/lib/echarts' instead of
- * `import * as echarts from 'echarts/lib/echarts'` to import all the exported 
methods.
- * It's not recommand but developers may still have the chance to do it.
- * But in the tsc export with __esModule mark. This will get an undefined 
export.
- * To avoid breaking this kind of code. We remove __esModule mark manually 
here.
- */
-function removeESmoduleMark() {
-    const filePath = nodePath.resolve(ecDir, 'lib/echarts.js');
-    const code = fs.readFileSync(filePath, 'utf-8')
-        .replace('\nexports.__esModule = true;\n', '');
-    if (code.indexOf('__esModule') >= 0) {
-        throw new Error('Seems still has __esModule mark');
-    }
-    fs.writeFileSync(filePath, code, 'utf-8');
-}
-
 function singleTransformZRRootFolder(code, replacement) {
     return code.replace(/([\"\'])zrender\/src\//g, 
`$1zrender/${replacement}/`);
 }

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to