Reviewed By: rafeca

Differential Revision: D6368078

fbshipit-source-id: 04232ac3762ce4c9581c694a60c1372b2f495af0
This commit is contained in:
Christoph Nakazawa 2017-11-18 10:41:01 -08:00 committed by Facebook Github Bot
parent 2c6aa5c5d8
commit 6d756334a8
3 changed files with 12 additions and 13 deletions

View File

@ -40,13 +40,13 @@
"build-clean": "rm -rf ./packages/*/build",
"build": "node ./scripts/build.js",
"clean-all": "rm -rf ./node_modules && rm -rf ./packages/*/node_modules && yarn run build-clean",
"jest-coverage": "yarn run jest -- --coverage",
"jest-coverage": "yarn run jest --coverage",
"lint": "eslint . --cache",
"lint-fix": "eslint . --fix --cache",
"postinstall": "node ./scripts/build.js",
"publish": "yarn run build-clean && yarn run build && lerna run prepare-release && lerna publish",
"postpublish": "lerna run cleanup-release",
"test-ci": "yarn run typecheck && yarn run lint && yarn run build && yarn run jest-coverage -- -i && node scripts/mapCoverage.js && codecov",
"test-ci": "yarn run typecheck && yarn run lint && yarn run build && yarn run jest-coverage -i && node scripts/mapCoverage.js && codecov",
"test": "yarn run typecheck && yarn run lint && yarn run build && yarn run jest",
"typecheck": "flow check",
"watch": "yarn run build --silent && node ./scripts/watch.js"

View File

@ -12,8 +12,6 @@
'use strict';
const Serializers = require('../Serializers');
const CURRENT_TIME = 1482363367000;
describe('Serializers', () => {
@ -23,6 +21,7 @@ describe('Serializers', () => {
const getRamOptions = jest.fn();
const postProcessModules = jest.fn();
let deltaBundler;
let Serializers;
const deltaResponse = {
pre: new Map([[1, {type: 'script', code: 'pre;', id: 1, path: '/pre.js'}]]),
@ -40,6 +39,8 @@ describe('Serializers', () => {
}
beforeEach(() => {
Serializers = require('../Serializers');
getDelta.mockReturnValueOnce(Promise.resolve(deltaResponse));
getDependenciesFn.mockReturnValue(Promise.resolve(() => new Set()));
getRamOptions.mockReturnValue(

View File

@ -4,8 +4,6 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @format
*/
/**
@ -40,14 +38,14 @@ const IGNORE_PATTERN = '**/__tests__/**';
const PACKAGES_DIR = path.resolve(__dirname, '../packages');
const babelNodeOptions = JSON.parse(
fs.readFileSync(path.resolve(__dirname, '..', '.babelrc'), 'utf8'),
fs.readFileSync(path.resolve(__dirname, '..', '.babelrc'), 'utf8')
);
babelNodeOptions.babelrc = false;
const babelEs5Options = Object.assign(
{},
babelNodeOptions,
{presets: 'env'},
{plugins: [].concat(babelNodeOptions.plugins, 'transform-runtime')},
{plugins: [].concat(babelNodeOptions.plugins, 'transform-runtime')}
);
const fixedWidth = str => {
@ -92,13 +90,13 @@ function buildFile(file, silent) {
const pkgJsonPath = path.resolve(
PACKAGES_DIR,
getPackageName(file),
'package.json',
'package.json'
);
const browser = require(pkgJsonPath).browser;
if (browser) {
if (browser.indexOf(BUILD_ES5_DIR) !== 0) {
throw new Error(
`browser field for ${pkgJsonPath} should start with "${BUILD_ES5_DIR}"`,
`browser field for ${pkgJsonPath} should start with "${BUILD_ES5_DIR}"`
);
}
buildFileFor(file, silent, 'es5');
@ -116,7 +114,7 @@ function buildFileFor(file, silent, env) {
process.stdout.write(
chalk.dim(' \u2022 ') +
path.relative(PACKAGES_DIR, file) +
' (ignore)\n',
' (ignore)\n'
);
} else if (!micromatch.isMatch(file, JS_FILES_PATTERN)) {
fs.createReadStream(file).pipe(fs.createWriteStream(destPath));
@ -127,7 +125,7 @@ function buildFileFor(file, silent, env) {
chalk.red(' \u21D2 ') +
path.relative(PACKAGES_DIR, destPath) +
' (copy)' +
'\n',
'\n'
);
} else {
const transformed = babel.transformFileSync(file, babelOptions).code;
@ -141,7 +139,7 @@ function buildFileFor(file, silent, env) {
path.relative(PACKAGES_DIR, file) +
chalk.green(' \u21D2 ') +
path.relative(PACKAGES_DIR, destPath) +
'\n',
'\n'
);
}
}