Skip to content

Commit

Permalink
Merge pull request #3261 from ethereum/issue/3256
Browse files Browse the repository at this point in the history
Fix minified bundle
  • Loading branch information
nivida authored Dec 13, 2019
2 parents 3922046 + 38c5c54 commit 4689592
Show file tree
Hide file tree
Showing 11 changed files with 516 additions and 62 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,6 @@ Released with 1.0.0-beta.37 code base.

### Fixed

- Fix minified bundle (#3256)
- ``defaultBlock`` property handling fixed (#3247)
- ``clearSubscriptions`` does no longer throw an error if no running subscriptions do exist (#3246)
2 changes: 1 addition & 1 deletion dist/web3.min.js

Large diffs are not rendered by default.

27 changes: 20 additions & 7 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ var gulp = require('gulp');
var browserify = require('browserify');
var jshint = require('gulp-jshint');
var uglify = require('gulp-uglify');
var babel = require('gulp-babel');
var rename = require('gulp-rename');
var source = require('vinyl-source-stream');
var exorcist = require('exorcist');
Expand Down Expand Up @@ -167,6 +166,7 @@ packages.forEach(function(pckg, i) {
var stream = browserify(browserifyOptions)
.require(pckg.src, {expose: pckg.expose})
.require('bn.js', {expose: 'BN'}) // expose it to dapp developers
.add('./node_modules/regenerator-runtime')
.add(pckg.src);

if (pckg.ignore) {
Expand All @@ -175,7 +175,24 @@ packages.forEach(function(pckg, i) {
});
}

var bundle = stream.bundle();
var bundle = stream.transform(
"babelify",
{
global: true,
presets: [
[
"@babel/preset-env",
{
useBuiltIns: 'entry',
corejs: 3,
targets: {
ie: 10
}
}
]
]
}
).bundle();

stream = bundle
.pipe(exorcist(path.join(DEST, pckg.fileName + '.js.map')));
Expand All @@ -185,11 +202,7 @@ packages.forEach(function(pckg, i) {
.pipe(exorcist(path.join(WEB3_PACKAGE_DEST, pckg.fileName + '.js.map')));
}

stream = stream.pipe(source(pckg.fileName + '.js'))
.pipe(streamify(babel({
compact: false,
presets: [[ '@babel/preset-env', { "useBuiltIns": "usage", "corejs": 2 } ]]
})));
stream = stream.pipe(source(pckg.fileName + '.js'));

if (pckg.fileName === 'web3') {
stream = stream
Expand Down
25 changes: 19 additions & 6 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,31 @@ if (!process.env.TRAVIS){
process.env.CHROME_BIN = require('puppeteer').executablePath();
}

// BROWSER_BUNDLE_TEST is set for an un-browserified check that both bundles load correctly.
// BROWSER_BUNDLE_TEST is not set for the e2e unit tests, which check that bundle internals are ok.
function getTestFiles(){
switch (process.env.BROWSER_BUNDLE_TEST){
case 'publishedDist': return ["packages/web3/dist/web3.min.js", "test/e2e.minified.js"]
case 'gitRepoDist': return ["dist/web3.min.js", "test/e2e.minified.js"]
default: return ["test/**/e2e*.js"]
}
}

// Only loads browserified preprocessor for the logic unit tests so we can `require` stuff.
function getPreprocessors(){
if (!process.env.BROWSER_BUNDLE_TEST){
return { 'test/**/e2e*.js': [ 'browserify' ] }
}
}

module.exports = function (config) {
var configuration = {
frameworks: [
'mocha',
'browserify'
],
files: [
'test/**/e2e*.js'
],
preprocessors: {
'test/**/e2e*.js': [ 'browserify' ]
},
files: getTestFiles(),
preprocessors: getPreprocessors(),
plugins: [
'karma-chrome-launcher',
'karma-firefox-launcher',
Expand Down
Loading

0 comments on commit 4689592

Please sign in to comment.