Skip to content

Introduce Webpack for browser bundling#33

Merged
pvorb merged 3 commits intopvorb:masterfrom
caub:master
Apr 25, 2017
Merged

Introduce Webpack for browser bundling#33
pvorb merged 3 commits intopvorb:masterfrom
caub:master

Conversation

@caub
Copy link
Copy Markdown
Contributor

@caub caub commented Mar 18, 2017

No description provided.

@caub
Copy link
Copy Markdown
Contributor Author

caub commented Apr 24, 2017

@pvorb is this PR ok? I don't think adding webpack is too much a problem, it's a dev-dep

Copy link
Copy Markdown
Owner

@pvorb pvorb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove old Node.js versions?

Edit: See full review below.

Copy link
Copy Markdown
Owner

@pvorb pvorb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this went unnoticed for some reason.

I really like the idea of using Webpack in order to provide a minified version of this module. I know this is how you do NPM modules in 2016+ but this module hasn't changed much since the beginnings of Node and I am not willing to invest much of my time in advancing tooling as it's unlikely to change a lot in the future.

Your PR is valid, but needs some minor improvements before I will accept it.

Comment thread .travis.yml
language: node_js
node_js:
- 0.6
- 0.8
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove old Node.js versions?

Copy link
Copy Markdown
Contributor Author

@caub caub Apr 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think webpack fails to install with them, on travis

npm WARN engine [email protected]: wanted: {"node":">= 0.8.x"} (current: {"node":"0.6.21-pre","npm":"1.1.37"})
npm WARN engine [email protected]: wanted: {"node":">=4.3.0 <5.0.0 || >=5.10"} (current: {"node":"0.6.21-pre","npm":"1.1.37"})

0.12 works though

0.6 and 0.8 are probably old enough to be skipped

Thanks for the reviews, didn't know for webpack -p (5.9kB vs 5.7kB before, but that's fine).

Yes I think it'd be nice to package it for browser, easily accessible from things like https://unpkg.com/md5@latest/dist/md5.min.js

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The origin file is 5.86kB by the way, so this even got worse by -p. I start to wonder if this is even worth the hassle.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After gzip the original file is 1837 bytes. md5.min.js is 2474 after gzip. Webpack really seems to make things worse.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before switching to -p, things weren't that much better:

$ ls -l md5*
-rw-r--r-- 1 Paul 197121 5996 Aug 31  2016 md5.js
-rw-r--r-- 1 Paul 197121 1837 Aug 31  2016 md5.js.gz

$ ls -l dist/md5*
-rw-r--r-- 1 Paul 197121 5878 Apr 25 00:36 dist/md5.min.js
-rw-r--r-- 1 Paul 197121 2378 Apr 25 00:36 dist/md5.min.js.gz

Copy link
Copy Markdown
Contributor Author

@caub caub Apr 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes but md5.js has some requires at the top, so it can't really be compared to dist/md5.min.js which is bundled.

Ah sorry for the confusion, I was comparing 5.9 vs 5.7 (that I had with UglifyJS plugin before, for dist/md5.min.js too)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, you're right. It's easy to miss that point. :)

Comment thread demo/index.html Outdated
<output id="output"></output>
<style>
output::before {
content: "output:";
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use two spaces for indentation throughout the PR.

Comment thread demo/index.html Outdated
reader.onload = e => {
resolve(e.target.result)
}
});
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use ES6 syntax as it's not supported by every browser around.

Comment thread package.json Outdated
"devDependencies": {
"mocha": "~2.3.4"
"mocha": "~2.3.4",
"webpack": "^2.2.1"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be "webpack": "~2.2.1"

Comment thread demo/index.html Outdated
}


</script> No newline at end of file
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All files need to end with a new line character.

Comment thread webpack.config.js Outdated
comments: false
}
})
],
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the UglifyJsPlugin obsolete? webpack -p should already compress the script.

@pvorb pvorb changed the title browser + example Introduce Webpack for browser bundling Apr 25, 2017
@pvorb pvorb merged commit 4de642a into pvorb:master Apr 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants