Git Product home page Git Product logo

node-libs-browser's Introduction



npm

node builds2 coverage licenses PR's welcome


install size

webpack

Webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable of transforming, bundling, or packaging just about any resource or asset.

Table of Contents

  1. Install
  2. Introduction
  3. Concepts
  4. Contributing
  5. Support
  6. Core Team
  7. Sponsoring
  8. Premium Partners
  9. Other Backers and Sponsors
  10. Gold Sponsors
  11. Silver Sponsors
  12. Bronze Sponsors
  13. Backers
  14. Special Thanks

Install

Install with npm:

npm install --save-dev webpack

Install with yarn:

yarn add webpack --dev

Introduction

Webpack is a bundler for modules. The main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable of transforming, bundling, or packaging just about any resource or asset.

TL;DR

  • Bundles ES Modules, CommonJS, and AMD modules (even combined).
  • Can create a single bundle or multiple chunks that are asynchronously loaded at runtime (to reduce initial loading time).
  • Dependencies are resolved during compilation, reducing the runtime size.
  • Loaders can preprocess files while compiling, e.g. TypeScript to JavaScript, Handlebars strings to compiled functions, images to Base64, etc.
  • Highly modular plugin system to do whatever else your application requires.

Get Started

Check out webpack's quick Get Started guide and the other guides.

Browser Compatibility

Webpack supports all browsers that are ES5-compliant (IE8 and below are not supported). Webpack also needs Promise for import() and require.ensure(). If you want to support older browsers, you will need to load a polyfill before using these expressions.

Concepts

Webpack has a rich plugin interface. Most of the features within webpack itself use this plugin interface. This makes webpack very flexible.

Name Status Install Size Description
mini-css-extract-plugin mini-css-npm mini-css-size Extracts CSS into separate files. It creates a CSS file per JS file which contains CSS.
compression-webpack-plugin compression-npm compression-size Prepares compressed versions of assets to serve them with Content-Encoding
html-webpack-plugin html-plugin-npm html-plugin-size Simplifies creation of HTML files (index.html) to serve your bundles
pug-plugin pug-plugin-npm pug-plugin-size Renders Pug files to HTML, extracts JS and CSS from sources specified directly in Pug.

Webpack enables the use of loaders to preprocess files. This allows you to bundle any static resource way beyond JavaScript. You can easily write your own loaders using Node.js.

Loaders are activated by using loadername! prefixes in require() statements, or are automatically applied via regex from your webpack configuration.

Files

Name Status Install Size Description
val-loader val-npm val-size Executes code as module and considers exports as JS code

JSON

Name Status Install Size Description
cson-npm cson-size Loads and transpiles a CSON file

Transpiling

Name Status Install Size Description
babel-npm babel-size Loads ES2015+ code and transpiles to ES5 using Babel
type-npm type-size Loads TypeScript like JavaScript
coffee-npm coffee-size Loads CoffeeScript like JavaScript

Templating

Name Status Install Size Description
html-npm html-size Exports HTML as string, requires references to static resources
pug-npm pug-size Loads Pug templates and returns a function
pug3-npm pug3-size Compiles Pug to a function or HTML string, useful for use with Vue, React, Angular
md-npm md-size Compiles Markdown to HTML
posthtml-npm posthtml-size Loads and transforms a HTML file using PostHTML
hbs-npm hbs-size Compiles Handlebars to HTML

Styling

Name Status Install Size Description
<style> style-npm style-size Add exports of a module as style to DOM
css-npm css-size Loads CSS file with resolved imports and returns CSS code
less-npm less-size Loads and compiles a LESS file
sass-npm sass-size Loads and compiles a Sass/SCSS file
stylus-npm stylus-size Loads and compiles a Stylus file
postcss-npm postcss-size Loads and transforms a CSS/SSS file using PostCSS

Frameworks

Name Status Install Size Description
vue-npm vue-size Loads and compiles Vue Components
polymer-npm polymer-size Process HTML & CSS with preprocessor of choice and require() Web Components like first-class modules
angular-npm angular-size Loads and compiles Angular 2 Components
riot-npm riot-size Riot official webpack loader
svelte-npm svelte-size Official Svelte loader

Performance

Webpack uses async I/O and has multiple caching levels. This makes webpack fast and incredibly fast on incremental compilations.

Module Formats

Webpack supports ES2015+, CommonJS and AMD modules out of the box. It performs clever static analysis on the AST of your code. It even has an evaluation engine to evaluate simple expressions. This allows you to support most existing libraries out of the box.

Webpack allows you to split your codebase into multiple chunks. Chunks are loaded asynchronously at runtime. This reduces the initial loading time.

Webpack can do many optimizations to reduce the output size of your JavaScript by deduplicating frequently used modules, minifying, and giving you full control of what is loaded initially and what is loaded at runtime through code splitting. It can also make your code chunks cache friendly by using hashes.

Contributing

We want contributing to webpack to be fun, enjoyable, and educational for anyone, and everyone. We have a vibrant ecosystem that spans beyond this single repo. We welcome you to check out any of the repositories in our organization or webpack-contrib organization which houses all of our loaders and plugins.

Contributions go far beyond pull requests and commits. Although we love giving you the opportunity to put your stamp on webpack, we also are thrilled to receive a variety of other contributions including:

  • Documentation updates, enhancements, designs, or bugfixes
  • Spelling or grammar fixes
  • README.md corrections or redesigns
  • Adding unit, or functional tests
  • Triaging GitHub issues -- especially determining whether an issue still persists or is reproducible.
  • Searching #webpack on twitter and helping someone else who needs help
  • Teaching others how to contribute to one of the many webpack's repos!
  • Blogging, speaking about, or creating tutorials about one of webpack's many features.
  • Helping others in our webpack gitter channel.

To get started have a look at our documentation on contributing.

If you are worried or don't know where to start, you can always reach out to Sean Larkin (@TheLarkInn) on Twitter or simply submit an issue and a maintainer can help give you guidance!

We have also started a series on our Medium Publication called The Contributor's Guide to webpack. We welcome you to read it and post any questions or responses if you still need help.

Looking to speak about webpack? We'd love to review your talk abstract/CFP! You can email it to webpack [at] opencollective [dot] com and we can give pointers or tips!!!

Creating your own plugins and loaders

If you create a loader or plugin, we would <3 for you to open source it, and put it on npm. We follow the x-loader, x-webpack-plugin naming convention.

Support

We consider webpack to be a low-level tool used not only individually but also layered beneath other awesome tools. Because of its flexibility, webpack isn't always the easiest entry-level solution, however we do believe it is the most powerful. That said, we're always looking for ways to improve and simplify the tool without compromising functionality. If you have any ideas on ways to accomplish this, we're all ears!

If you're just getting started, take a look at our new docs and concepts page. This has a high level overview that is great for beginners!!

Looking for webpack 1 docs? Please check out the old wiki, but note that this deprecated version is no longer supported.

If you want to discuss something or just need help, here is our Gitter room where there are always individuals looking to help out!

If you are still having difficulty, we would love for you to post a question to StackOverflow with the webpack tag. It is much easier to answer questions that include your webpack.config.js and relevant files! So if you can provide them, we'd be extremely grateful (and more likely to help you find the answer!)

If you are twitter savvy you can tweet #webpack with your question and someone should be able to reach out and help also.

If you have discovered a 🐜 or have a feature suggestion, feel free to create an issue on GitHub.

License

FOSSA Status

Core Team


Tobias Koppers

Core


Founder of webpack


Johannes Ewald

Loaders & Plugins


Early adopter of webpack


Sean T. Larkin

Public Relations


Founder of the core team


Kees Kluskens

Development


Sponsor


Sponsoring

Most of the core team members, webpack contributors and contributors in the ecosystem do this open source work in their free time. If you use webpack for a serious task, and you'd like us to invest more time on it, please donate. This project increases your income/productivity too. It makes development and applications faster and it reduces the required bandwidth.

This is how we use the donations:

  • Allow the core team to work on webpack
  • Thank contributors if they invested a large amount of time in contributing
  • Support projects in the ecosystem that are of great value for users
  • Support projects that are voted most (work in progress)
  • Infrastructure cost
  • Fees for money handling

Premium Partners

Other Backers and Sponsors

Before we started using OpenCollective, donations were made anonymously. Now that we have made the switch, we would like to acknowledge these sponsors (and the ones who continue to donate using OpenCollective). If we've missed someone, please send us a PR, and we'll add you to this list.

Angular MoonMail MONEI

Gold Sponsors

Become a gold sponsor and get your logo on our README on GitHub with a link to your site.

Silver Sponsors

Become a silver sponsor and get your logo on our README on GitHub with a link to your site.

Bronze Sponsors

Become a bronze sponsor and get your logo on our README on GitHub with a link to your site.

Backers

Become a backer and get your image on our README on GitHub with a link to your site.

Special Thanks to

(In chronological order)

node-libs-browser's People

Contributors

bmeurer avatar brendo avatar defunctzombie avatar devongovett avatar dignifiedquire avatar fahrradflucht avatar goto-bus-stop avatar gruns avatar jdiaz5513 avatar jhnns avatar jondlm avatar jtangelder avatar lencioni avatar mcollina avatar phated avatar philikon avatar semigradsky avatar simenb avatar sokra avatar terinjokes avatar zenflow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-libs-browser's Issues

Use stream-http

Browserify has stopped using http-browserify and moved to stream-http which actually supports true response streaming and has lots of bug fixes.

webpack should probably switch over too.

This would fix this bug when WebTorrent is built with webpack.

cc @jhiesey

Unable to commit my node_modules

I am bringing in webpack via npm, and when I try to commit my node_modules, I get the following error:

fatal: Not a git repository: /Users/Mathias/Projects/punycode.js/.git/modules/vendor/docdown

Essentially, the node_modules/webpack/node_modules/node-libs-browser/node_modules/url/node_modules/punycode/vendor/docdown directory has a .git file in it. It looks like this problem has been fixed in newer versions. However, node-libs-browser is using an older version of the url package that has this problem.

I tested this by creating a new directory and running:

npm install [email protected]

If I instead do:

npm install url

there is no problem.

I think that bumping the version from ~0.7.9 in the package.json to ~0.10.1 would resolve this issue. I'd be happy to submit a pull request but I'm not sure how to verify this doesn't break anything.

Needs better documentation

@webpack

This repo would ideally give a bit more details in the readme, for easy reference.

  • which modules are implemented (for example, 'process') and which are not (for example, 'fs')
  • how the implemented modules differ from their node counterparts

I would gladly volunteer to take this task if it pleases you.

I'll note that it's of particular importance to me that the browser member of process (i.e. process.browser) gets documented. It would be a brief mention, and I would by no means go into details or examples of how to use it, but I will breifly argue it's significance to you here...

You can reference process.browser in isomorphic code that

  • adjusts it's behavior depending on which environment it's in
  • is fully portable within the nodejs/iojs/browserify/webpack ecosystem, and
  • is concise and Don't Repeat Yourself (DRY)

That said, I intend on doing a thorough documentation of each module, not just process, should you welcome my offer to help.

So, I guess my question is: Would you like to see a PR with enhanced documentation as described?

Uncaught TypeError: os.homedir is not a function

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
After compiling a bundle with deps which use os.homedir function (for example is-reachable) i've got the error in the runtime: Uncaught TypeError: os.homedir is not a function
In the bundle os.homedir is undefined.

What is the expected behavior?
os.homedir shoud be a function

Please update os-browserify package to the latest version (0.3.0) to get support of os.homedir function in bundle.


This issue was moved from webpack/webpack#5512 by @sokra. Orginal issue was by @Deadly0.

Buffer is broken for target: "webworker"

The buffer module currently used (v4) performs a check of a variable explicitly on the global variable, something like if(global.TYPED_ARRAY_SUPPORT). As mentioned in #31, global is not polyfilled—at least it isn’t when building a Webpack bundle for the webworker target. As a result, code that relies on Webpack polyfilling the buffer module will break in webworkers.

This can be trivially fixed by updating to the latest version of the buffer module (5), but in #45 it seems that sticking to an older version is a deliberate decision.

how to install?

npm install --save node-libs-browser?

Can this info be included in the readme?

Investigate replacing `gozala/events` module

Currently events is polyfilled with gozala/events. However, it is far behind the latest Node version, and perhaps more concerningly its unit tests are failing and they are not run in a wide array of browsers, so upgrading it is dangerous (though I have a PR in to do so).

Unfortunately it doesn't look like there's other solid isomorphic event implementations which match the Node API, at least none that my Google-fu could find. I would be happy to spend a weekend getting something drafted up if there's interest in updating this; an updated implementation to be tested both in Node via and in browsers via Browserstack or SauceLabs.

buffer 4.9.1 can cause errors

Calling a read function on the embedded buffer without any argument will throw an exception.
This is major incompatibility issue with node.js buffer.

Error message thrown: "RangeError: offset is not uint"

Corresponding issue: feross/buffer#237

I suggest to reconsider PR: #68, which does fix the issue

Compatibility with new readable-stream

Hi,

to use recent readable-stream, I had to patch your module:

--- a/index.js
+++ b/index.js
@@ -22,11 +22,11 @@
 exports.readline                                       = null;
 exports.repl                                           = null;
 exports.stream                                         = require.resolve('stream-browserify');
-exports._stream_duplex                         = require.resolve('readable-stream/duplex.js');
-exports._stream_passthrough                    = require.resolve('readable-stream/passthrough.js');
-exports._stream_readable                       = require.resolve('readable-stream/readable.js');
-exports._stream_transform                      = require.resolve('readable-stream/transform.js');
-exports._stream_writable                       = require.resolve('readable-stream/writable.js');
+exports._stream_duplex                         = require.resolve('readable-stream/lib/_stream_duplex.js');
+exports._stream_passthrough                    = require.resolve('readable-stream/lib/_stream_passthrough.js');
+exports._stream_readable                       = require.resolve('readable-stream/lib/_stream_readable.js');
+exports._stream_transform                      = require.resolve('readable-stream/lib/_stream_transform.js');
+exports._stream_writable                       = require.resolve('readable-stream/lib/_stream_writable.js');
 exports.string_decoder                         = require.resolve('string_decoder');
 exports.sys                                                    = require.resolve('util/util.js');
 exports.timers                                         = require.resolve('timers-browserify');

Would like to use my own polyfills with Webpack 'node' option

I am looking to use my own polyfills/shims with Webpack

e.g.:

//webpack.config.js

node: {
 assert: require.resolve('oresoftware-assert'),
 fs: require.resolve('oresoftware-fs')
}

is this already supported? I don't believe I have seen this documented, but it would be a great feature, please advise

Version bumps causing problems with fake timers in tests.

The new version bump for process 0.10.x is causing sinon fake timers + bluebird + webpack to make all bluebird promises "freeze" (because it's now using setTimeout instead of the other method it used to (mutation/etc selection process had in 0.8)

Having a hard time figuring how how to undo this problem because webpack itself lists the dep on node-libs-browser to be ~0.4.0 and the bump here is definitely causing problems in all of our test suites that use sinon + bluebird.

Tests status

module tested status one browser status all browsers
events yes pass
punycode yes pass
querystring yes fail
timers some
buffer separate
vm separate
zlib separate
crypto some separate
assert no
child_process no
http/https no
path no
stream no
util/sys no

process.nextTick polyfill is slow when tab is unfocused

The nextTick polyfill is supplied by https://github.com/defunctzombie/node-process/blob/master/browser.js which uses timers. See: defunctzombie/node-process#86.

Because timers are often throttled when a tab is not active to improve battery life, they only run at 1Hz (once every second). This has a drastic performance impact in those scenarios.

It seems that the author won't change this for the time being, see: webtorrent/webtorrent#1568 (comment)

It would be cool to just map nextTick to setImmediate, as we are already providing that polyfill.

Any chance of updating latest pre-1.0 version to use newer version of buffer?

Hi
I'm currently using latest stable version of webpack (1.13.0) that relies on "node-libs-browser": ">= 0.4.0 <=0.6.0" which in turn uses "buffer": "^3.0.3". Any chance of bumping that up to utilize buffer 4.3.0 that's used by node-libs-browser v1.0? I'm running into an issue that was resolved in buffer since 3.0.3 and would prefer not to edit the buffer source under node_modules manually on x of the build machines.

TypeError: The "original" argument must be of type Function

What does this error mean, and how do I resolve it?

TypeError: The "original" argument must be of type Function
    at promisify (util.js?eed9:602)
    at Object.eval (index.js?b048:9)
    at eval (index.js:277)
    at Object../node_modules/readdirp/index.js (printable.js:5067)
    at __webpack_require__ (runtime.js:854)
    at fn (runtime.js:151)
    at Object.eval (index.js?b44e:7)
    at eval (index.js:942)
    at Object../node_modules/chokidar/index.js (printable.js:1206)
    at __webpack_require__ (runtime.js:854)

fs undefined

In my js file I have:

var fs = require('fs');

when I tried fs.readFileSync(..somefile);

Error is: fs.readFileSync is not a function

Is there any setup needed?

Updated and more complete version of the zlib shim

There is a new version of the browserify-zlib shim to zlib available at https://github.com/ipfs/browserify-zlib, it fixes some bugs and more importantly, it adds support for dictionaries.

It seems that not a lot of people use that feature, but it is essential for libp2p-spdy in the browser, which is part of js-libp2p and js-ipfs. Right now we are replacing the shim in our build tool, but it would improve the experience a lot if everyone using it could just rely on webpack to use the correct version of the shim.

We've a open PR -- browserify/browserify-zlib#18 -- to the bundled browserify-zlib in browserify, but 8 months have passed since it was open, the author and maintainer seems to be lacking the time to review. What else an we do to move this forward?

Thank you :)

There is also an issue open on browserify for this: browserify/browserify#1672 which suffers from the same problem.

cc @diasdavid

Dependency `assert` broken; webpack 2.

I encountered Error Uncaught TypeError: util.inherits is not a function while upgrading to webpack 2.

I traced the cause to the dependency "inherits": "2.0.1" instead of "^2.0.1" or the like in util, which is used by assert, which is used by node-libs-browser.


My current hideous workaround is adding to package.json:

"dependencies": {
  "inherits": "^2.0.3"

and to webpack.config.js:

resolve: {
  alias: {
    inherits$: path.resolve(__dirname, 'node_modules/inherits')

I also filed a bug with util at Outdated dependency inherits causes trouble upstream; Webpack 2.

Module not found: Can't resolve 'util'

Description

I create a app with create-react-app with --typescript, and add some lib to it. But when I execute start script, a compilation error has occurred:

Failed to compile.

./node_modules/browserify-zlib/lib/index.js
Module not found: Can't resolve 'util' in 'E:\sourcecode\frontend\AppDev-web\node_modules\browserify-zlib\lib'

I'm not explicit import browserify-zlib, so I search it in project, in yarn.lock file, I found this:

node-libs-browser@^2.0.0:
  version "2.2.0"
  resolved "https://registry.npmjs.org/node-libs-browser/-/node-libs-browser-2.2.0.tgz#c72f60d9d46de08a940dedbb25f3ffa2f9bbaa77"
  integrity sha512-5MQunG/oyOaBdttrL40dA7bUfPORLRWMUJLQtMg7nluxUvk5XwnLdL9twQHFAjRx/y7mIMkLKT9++qPbbk6BZA==
  dependencies:
    assert "^1.1.1"
    browserify-zlib "^0.2.0"
    buffer "^4.3.0"
    console-browserify "^1.1.0"
    constants-browserify "^1.0.0"
    crypto-browserify "^3.11.0"
    domain-browser "^1.1.1"
    events "^3.0.0"
    https-browserify "^1.0.0"
    os-browserify "^0.3.0"
    path-browserify "0.0.0"
    process "^0.11.10"
    punycode "^1.2.4"
    querystring-es3 "^0.2.0"
    readable-stream "^2.3.3"
    stream-browserify "^2.0.1"
    stream-http "^2.7.2"
    string_decoder "^1.0.0"
    timers-browserify "^2.0.4"
    tty-browserify "0.0.0"
    url "^0.11.0"
    util "^0.11.0"
    vm-browserify "0.0.4"
  • I tried add util package, still not work
  • I tried add util in webpack.config.js like this:
    node: {
      util: 'empty',
      module: 'empty',
      dgram: 'empty',
      dns: 'mock',
      fs: 'empty',
      net: 'empty',
      tls: 'empty',
      child_process: 'empty',
    },

still not work

Info

create-react-app: version: 2.1.8
webpack.config.js
package.json
tsconfig.json

Anybody know anything about this?

Update to crypto-browserify 3.11.0 in your 0.5.3 version

The version 0.5.3 of node-libs-browser currently depends on :

"crypto-browserify": "^3.2.6",

Which it self depends on [email protected] which was unlicensed.
This poses a problem for any webpack users since webpack uses version 0.5.3 of node-libs-browser.

Can you please release a new 0.5.4 version with crypto-browseriify 3.11.0 ?

This way, all sub licenses of webpack are conform with the license of webpack it self.

Old path-browserify is very slow on long pathnames (should I say ReDoS'able?)

Currently used here [email protected]:

time node -e "require('path-browserify').extname(crypto.randomBytes(2 ** 23).toString('base64'))"
real    0m5.619s

Node 11 built-in path module:

time node -e "path.extname(crypto.randomBytes(2 ** 23).toString('base64'))"
real    0m0.133s

Latest [email protected]:

time node -e "require('path-browserify').extname(crypto.randomBytes(2 ** 23).toString('base64'))"
real    0m0.137s

Currently the fact that webpack pulls [email protected] via this module forces me to install [email protected] and alias it manually in webpack.config.js like this:

	resolve: {
		alias: {
			path: 'path-browserify',
		},
	},

I hope you can update it to 1.0.0.

EDIT: Turns out there is already a PR for this #79

0.4.2: diffie-hellman cannot find ./lib/primes

Hello,

Looks like the update from a couple hours ago could be bringing in a bug with a downstream dependency.

Dependencies go:

  • webpack 1.5.1 depends on node-libs-browser ~0.4.0
  • node-libs-browser 0.4.2 depends on crypto-browserify ^3.9.13
  • crypto-browserify 3.9.13 depends on diffie-hellman ^3.0.1
  • diffie-hellman 3.0.1 breaks

Error in browser is: Cannot find module "./lib/primes", which is required from diffie-hellman/browser.js

Looks like there exists a ./lib/primes.json in that package, so maybe configuring webpack to auto check ".json" suffixes would work, I'll try that.

Will also learn about npm-shrinkwrap after this.

Any other tips for resolving issue? Thank you.

Merge xxx-browserify or not?

Should the xxx-browserify modules and authors merged into this package?

Pro:

  • less fragmentation
  • more maintainers for all node buildin libs
  • easier sharing of small common fragments, i.e. shims
  • easier to maintain

Contra:

  • less modular
  • "holy fuck. why are there 20 files and 1000s of lines of code in one repo"

Problems merging:

  • xxx-browserify modules could not longer be used alone
    • they can transform into wrappers for this package

Problems splitting:

  • duplicated effort to have each module tested in testling
  • no aggregated test results
    • repo for aggregating results
    • badge wouldn't update

Modules not found

When running webpack-dev-server 1.9.0, we get the following errors from node-libs-browser:

ERROR in .//node-libs-browser//crypto-browserify/pbkdf2.js
Module not found: Error: Cannot resolve module 'pbkdf2-compat/pbkdf2' in H:\XXX\node_modules\node-libs-browser\node_modules\crypto-browserify
@ .//node-libs-browser//crypto-browserify/pbkdf2.js 1:19-50

ERROR in .//node-libs-browser//crypto-browserify/create-hash.js
Module not found: Error: Cannot resolve module 'sha.js' in H:\XXX\node-libs-browser\node_modules\crypto-browserify
@ .//node-libs-browser//crypto-browserify/create-hash.js 1:17-34

ERROR in .//node-libs-browser//crypto-browserify/create-hash.js
Module not found: Error: Cannot resolve module 'ripemd160' in H:\XXX\node_m
odules\node-libs-browser\node_modules\crypto-browserify
@ .//node-libs-browser//crypto-browserify/create-hash.js 4:27-47

ERROR in .//node-libs-browser//buffer/index.js
Module not found: Error: Cannot resolve module 'base64-js' in H:\XXX\node_m
odules\node-libs-browser\node_modules\buffer
@ .//node-libs-browser//buffer/index.js 8:13-33

ERROR in .//node-libs-browser//buffer/index.js
Module not found: Error: Cannot resolve module 'ieee754' in H:\XXX\node_mod
ules\node-libs-browser\node_modules\buffer
@ .//node-libs-browser//buffer/index.js 9:14-32

ERROR in .//node-libs-browser//buffer/index.js
Module not found: Error: Cannot resolve module 'is-array' in H:\XXX\node_mo
dules\node-libs-browser\node_modules\buffer
@ .//node-libs-browser//buffer/index.js 10:14-33

console polyfill outdated

As mentioned here the current console polyfill is missing functions (such as, say console.table).

It would be nice if the polyfill was switched into something more current, like this one.

Update dependencies

I did a quick research for breaking changes of outdated modules. This was necessary because it was unclear why @sokra chose to update to 1.0.0 for webpack 2 but not for webpack 1. This is the result:

Major version bumps (including 0.x changes)

buffer

Breaking change was feross/buffer@5daca86

@fanatid wrote:

v4.x uses Uint8Array by default and Object as shim
v5.x uses only Uint8Array and print error if TypedArrays not supported

Since we should still support IE9 and IE10 out-of-the-box, we should stick to v4 for now.

constants-browserify

The update should be no problem. Some constants have been changed but the usage is very unlikely.

https-browserify

No breaking change

os-browserify

No breaking change

readable-stream

Breaking change was nodejs/readable-stream@53ff397

Doesn't seem to be really breaking? readable-stream was not using semver prior v2.

stream-browserify

The funny thing is: stream-browserify is also using readable-stream for quite some time. We should just use readable-stream.

url

Possible breaking change in defunctzombie/node-url@e5b6f59

However, since this commit brings the url module in parity with node 0.12, it is very unlikely that there is currently frontend code out there which relies on such an old implementation of the url module. It is more likely that we actually fix code because developers assume a more recent implementation of the url module.


We should also switch all dependencies to the caret operator ^ to exclude breaking changes from 0.x modules.

@sokra @TheLarkInn @bebraw @SpaceK33z

npm ERR! No compatible version found: node-libs-browser@^0.6.0

Doing a fresh npm install this morning :

npm ERR! No compatible version found: node-libs-browser@^0.6.0
npm ERR! Valid install targets:
npm ERR! 1.0.0, 0.5.3, 0.5.2, 0.5.1, 0.5.0, 0.4.3, 0.4.2, 0.4.1, 0.4.0, 0.3.1, 0.3.0, 0.2.1, 0.2.0, 0.1.2, 0.1.1, 0.1.0

This is breaking npm install

Did the new 0.6.0 get pushed to npm ? Who is referencing it ? (most likely babel)

Directory structure

Refactor to a better drectory structure:

lib
  core - all libs
  mock - mocks of all libs
  util - shared stuff
  e5util - shared stuff without shims
test
  tests - shared test code for all environments
  environments - environments to run tests in with references to ../tests
    node
    browserify
    webpack

Incompatibility between Node.js core libs and webpack's lib

I've collected the gap between Node.js core lib and webpack/browserify's shim lib.

Latest results is in following repository.

Env

  • Node.js 10.0.0
  • webpack 4.6.0

Gap list

Node.js Browser shim Issue Link
assert defunctzombie/commonjs-assert Error code and Error message are different Issue, Article
assert.deepEqual does't support Map, Set, Iterator etc... Issue, Document, Release
require("assert").strict Docs, Release
buffer feross/buffer ---
child_process --- ---
cluster --- ---
console Raynos/console-browserify ---
constants juliangruber/constants-browserify ---
crypto crypto-browserify/crypto-browserify ---
dgram --- ---
dns --- ---
domain bevry/domain-browser ---
events Gozala/events eventNames Issue
getMaxListeners Issue
prependListener Issue
prependOnceListener Issue
off Issue
fs --- ---
http jhiesey/stream-http ---
https substack/https-browserify ---
module --- ---
net --- ---
os CoderPuppy/os-browserify os.constants
path substack/path-browserify path.posix Issue
path.parse(path) Issue
path.win32
path.format(pathObject)
process shtylman/node-process process.channel
process.platform Issue
process.execArgv Issue
process.cpuUsage([previousValue])
process.emitWarning(warning[, options])
punycode bestiejs/punycode.js ---
querystring mike-spainhower/querystring ---
readline --- ---
repl --- ---
stream substack/stream-browserify ---
string_decoder rvagg/string_decoder --- Repository
sys defunctzombie/node-util ---
timers jryans/timers-browserify ---
tls --- ---
tty substack/tty-browserify ---
url defunctzombie/node-url url.URL(WHATWG URL) Release, Document, Issue
url.format does't support WHATWG URL Release, Document
util defunctzombie/node-util util.callbackify(original)
util.inspect.custom
util.inspect.defaultOptions
util.promisify(original)
util.promisify.custom
util.inspect() options maxArrayLength, breakLength
util.isDeepStrictEqual
vm substack/vm-browserify vm.isContext(sandbox)
zlib devongovett/browserify-zlib zlib.bytesRead

Tests

Also, I've written the test for these new methods/properties.

Node.js 10 pass the tests, but the code that is bundled by webpack is failed.

global polyfill

Not sure if this is the right place to post this issue.
According to the webpack docs global is polyfilled by default but it turns out to be undefined in my build.
Am I missing something?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.