From 8cff56921701b78d73103f5e376baa98c05763b9 Mon Sep 17 00:00:00 2001 From: pradeepnschrodinger Date: Mon, 23 Mar 2020 14:43:25 +0000 Subject: [PATCH] attempt to fix build tests --- build_helpers/buildNPMInternals.sh | 25 +++++++++++-------- src/FixedDataTableContainer.js | 2 +- src/helper/convertColumnElementsToData.js | 2 +- .../core/getVendorPrefixedName.js | 2 +- .../struct/IntegerBufferSet.js | 2 +- .../struct/PrefixIntervalTree.js | 2 +- 6 files changed, 19 insertions(+), 16 deletions(-) diff --git a/build_helpers/buildNPMInternals.sh b/build_helpers/buildNPMInternals.sh index e95d19eb..d43b15ad 100755 --- a/build_helpers/buildNPMInternals.sh +++ b/build_helpers/buildNPMInternals.sh @@ -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; @@ -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); diff --git a/src/FixedDataTableContainer.js b/src/FixedDataTableContainer.js index bbf358dd..58bdeb3c 100644 --- a/src/FixedDataTableContainer.js +++ b/src/FixedDataTableContainer.js @@ -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'; diff --git a/src/helper/convertColumnElementsToData.js b/src/helper/convertColumnElementsToData.js index 0edb4f02..732850a9 100644 --- a/src/helper/convertColumnElementsToData.js +++ b/src/helper/convertColumnElementsToData.js @@ -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'; diff --git a/src/vendor_upstream/core/getVendorPrefixedName.js b/src/vendor_upstream/core/getVendorPrefixedName.js index c9329c46..7741a288 100644 --- a/src/vendor_upstream/core/getVendorPrefixedName.js +++ b/src/vendor_upstream/core/getVendorPrefixedName.js @@ -10,7 +10,7 @@ * @typechecks */ -import invariant from 'invariant'; +import invariant from '../../stubs/invariant'; import ExecutionEnvironment from './ExecutionEnvironment'; import camelize from './camelize'; diff --git a/src/vendor_upstream/struct/IntegerBufferSet.js b/src/vendor_upstream/struct/IntegerBufferSet.js index 305d534e..3f3c927d 100644 --- a/src/vendor_upstream/struct/IntegerBufferSet.js +++ b/src/vendor_upstream/struct/IntegerBufferSet.js @@ -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 diff --git a/src/vendor_upstream/struct/PrefixIntervalTree.js b/src/vendor_upstream/struct/PrefixIntervalTree.js index 7a6bdb7c..5a09109a 100644 --- a/src/vendor_upstream/struct/PrefixIntervalTree.js +++ b/src/vendor_upstream/struct/PrefixIntervalTree.js @@ -13,7 +13,7 @@ 'use strict'; -import invariant from 'invariant'; +import invariant from '../../stubs/invariant'; var parent = node => Math.floor(node / 2);