Skip to content

Commit

Permalink
attempt to fix build tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pradeepnschrodinger committed Mar 23, 2020
1 parent 12cb830 commit 8cff569
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 16 deletions.
25 changes: 14 additions & 11 deletions build_helpers/buildNPMInternals.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ var glob = require('glob');
var path = require('path');
var fs = require('fs');
var babel = require('@babel/core');
var mkdirp = require('mkdirp');

var internalPath = path.join(__dirname, '../internal');
var sourcePath = path.join(__dirname, '../src');
if (!fs.existsSync(internalPath)) {
fs.mkdirSync(internalPath);
}

var providesModuleRegex = /@providesModule ([^\s*]+)/;
var moduleRequireRegex = /require\((?:'|")([\w\.\/]+)(?:'|")\)/gm;
var excludePathRegex = /^(react|lodash|redux|reselect)($|\/)/;
var findDEVRegex = /__DEV__/g;
Expand All @@ -33,16 +34,18 @@ var babelConf = JSON.parse(

function processFile(fileName) {
var contents = fs.readFileSync(fileName, {encoding: 'utf8'});
var providesModule = providesModuleRegex.exec(contents);
if (providesModule) {
contents = babel.transform(contents, babelConf).code;
contents = contents.replace(moduleRequireRegex, replaceRequirePath);
contents = contents.replace(findDEVRegex, 'process.env.NODE_ENV !== \'production\'');
fs.writeFileSync(
path.join(internalPath, providesModule[1] + '.js'),
contents
);
}
var outputPath = path.join(internalPath, path.relative(sourcePath, fileName));

// we create the directory explicitly because `fs.writeFileSync` requires parent directory to exist
mkdirp.sync(path.dirname(outputPath));

contents = babel.transform(contents, babelConf).code;
contents = contents.replace(moduleRequireRegex, replaceRequirePath);
contents = contents.replace(findDEVRegex, 'process.env.NODE_ENV !== \'production\'');
fs.writeFileSync(
outputPath,
contents
);
}

glob.sync(path.join(__dirname, '../src/**/*.js')).forEach(processFile);
2 changes: 1 addition & 1 deletion src/FixedDataTableContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import React from 'react';
import { bindActionCreators } from 'redux';
import invariant from 'invariant';
import invariant from './stubs/invariant';
import pick from 'lodash/pick';

import * as ActionTypes from './actions/ActionTypes';
Expand Down
2 changes: 1 addition & 1 deletion src/helper/convertColumnElementsToData.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import React from 'react';
import forEach from 'lodash/forEach';
import invariant from 'invariant';
import invariant from '../stubs/invariant';
import map from 'lodash/map';
import pick from 'lodash/pick';

Expand Down
2 changes: 1 addition & 1 deletion src/vendor_upstream/core/getVendorPrefixedName.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @typechecks
*/

import invariant from 'invariant';
import invariant from '../../stubs/invariant';

import ExecutionEnvironment from './ExecutionEnvironment';
import camelize from './camelize';
Expand Down
2 changes: 1 addition & 1 deletion src/vendor_upstream/struct/IntegerBufferSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import Heap from './Heap';

import invariant from 'invariant';
import invariant from '../../stubs/invariant';

// Data structure that allows to store values and assign positions to them
// in a way to minimize changing positions of stored values when new ones are
Expand Down
2 changes: 1 addition & 1 deletion src/vendor_upstream/struct/PrefixIntervalTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

'use strict';

import invariant from 'invariant';
import invariant from '../../stubs/invariant';

var parent = node => Math.floor(node / 2);

Expand Down

0 comments on commit 8cff569

Please sign in to comment.