Skip to content

Commit

Permalink
dev: fix source map creation
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Nov 15, 2019
1 parent 655274d commit 1f3ba7e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions scripts/build.js
Expand Up @@ -28,7 +28,6 @@ const mkdirp = require('mkdirp');
const babel = require('@babel/core');
const chalk = require('chalk');
const micromatch = require('micromatch');
const prettier = require('prettier');
const {getPackages, adjustToTerminalWidth, OK} = require('./buildUtils');
const browserBuild = require('./browserBuild');

Expand All @@ -44,10 +43,6 @@ const INLINE_REQUIRE_BLACKLIST = /packages\/expect|(jest-(circus|diff|get-type|j

const transformOptions = require('../babel.config.js');

const prettierConfig = prettier.resolveConfig.sync(__filename);
prettierConfig.trailingComma = 'none';
prettierConfig.parser = 'babel';

function getPackageName(file) {
return path.relative(PACKAGES_DIR, file).split(path.sep)[0];
}
Expand Down Expand Up @@ -156,10 +151,15 @@ function buildFile(file, silent) {
});
}

options.sourceFileName = path.relative(path.dirname(destPath), file);

const transformed = babel.transformFileSync(file, options);
const prettyCode = prettier.format(transformed.code, prettierConfig);
transformed.code +=
'\n//# sourceMappingURL=' + path.basename(destPath + '.map');

delete transformed.map.sourcesContent;

fs.writeFileSync(destPath, prettyCode);
fs.writeFileSync(destPath, transformed.code);
fs.writeFileSync(destPath + '.map', JSON.stringify(transformed.map));

silent ||
Expand Down

0 comments on commit 1f3ba7e

Please sign in to comment.