diff --git a/.gitignore b/.gitignore index 3c34f29ac..03c14b3cf 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ build/ *.tsbuildinfo .cache .watchmanconfig +coverage diff --git a/babel.config.js b/babel.config.js index d590727a4..c5246556b 100644 --- a/babel.config.js +++ b/babel.config.js @@ -28,4 +28,5 @@ module.exports = { }), ], ], + sourceMaps: true, }; diff --git a/jest.config.js b/jest.config.js index 00f379057..09aa62018 100644 --- a/jest.config.js +++ b/jest.config.js @@ -15,4 +15,10 @@ module.exports = { testMatch: ['/**/__tests__/*{.,-}test.[jt]s'], }, ], + collectCoverageFrom: [ + '**/packages/*/**/*.ts', + '!**/__mocks__/**', + '!**/__tests__/**', + '!**/build/**', + ], }; diff --git a/packages/cli-types/package.json b/packages/cli-types/package.json index d128a06f9..932812119 100644 --- a/packages/cli-types/package.json +++ b/packages/cli-types/package.json @@ -5,6 +5,10 @@ "publishConfig": { "access": "public" }, + "files": [ + "build", + "!build/**/*.map" + ], "types": "build/index.d.ts", "license": "MIT" } diff --git a/packages/cli/package.json b/packages/cli/package.json index 544b70616..faad4fe51 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -12,6 +12,7 @@ }, "files": [ "build", + "!build/**/*.map", "setup_env.sh" ], "engineStrict": true, diff --git a/packages/debugger-ui/package.json b/packages/debugger-ui/package.json index 48723372c..8fc44421e 100644 --- a/packages/debugger-ui/package.json +++ b/packages/debugger-ui/package.json @@ -9,7 +9,8 @@ "build:middleware": "tsc" }, "files": [ - "build" + "build", + "!build/**/*.map" ], "devDependencies": { "@babel/core": "^7.6.4", diff --git a/packages/platform-android/package.json b/packages/platform-android/package.json index bd49ba609..c9874a336 100644 --- a/packages/platform-android/package.json +++ b/packages/platform-android/package.json @@ -17,6 +17,7 @@ }, "files": [ "build", + "!build/**/*.map", "native_modules.gradle" ], "devDependencies": { diff --git a/packages/platform-ios/package.json b/packages/platform-ios/package.json index 8cbb0e66d..b73aa0f87 100644 --- a/packages/platform-ios/package.json +++ b/packages/platform-ios/package.json @@ -19,6 +19,7 @@ }, "files": [ "build", + "!build/**/*.map", "native_modules.rb" ] } diff --git a/packages/tools/package.json b/packages/tools/package.json index 382487f03..e99ac14eb 100644 --- a/packages/tools/package.json +++ b/packages/tools/package.json @@ -18,6 +18,7 @@ "@types/node-fetch": "^2.3.3" }, "files": [ - "build" + "build", + "!build/**/*.map" ] } diff --git a/scripts/build.js b/scripts/build.js index b0c10568d..fc2f39d5a 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -93,9 +93,17 @@ function buildFile(file, silent) { ); } else { const options = Object.assign({}, transformOptions); - const transformed = babel.transformFileSync(file, options).code; + const filename = path.basename(destPath); - fs.writeFileSync(destPath, transformed); + let {code, map} = babel.transformFileSync(file, options); + + if (!file.endsWith('.d.ts') && map.sources.length > 0) { + code = `${code}\n\n//# sourceMappingURL=${filename}.map`; + map.sources = [path.relative(path.dirname(destPath), file)]; + fs.writeFileSync(`${destPath}.map`, JSON.stringify(map)); + } + + fs.writeFileSync(destPath, code); silent || process.stdout.write(