Comments (10)
What is the purpose of mock? and what is in util?
What do you expect to be in the different environments?
Why is it not just:
lib
test
:)
from node-libs-browser.
mock
A good example mock for buffer.
I want the mocks to be a very small version of the buildin lib which do not implement any features to the full module, but provide a similar API.
If you now you app do not really use any feature of the vm
module, but some (stupid) 3rd party lib has a reference to it, you may choose to use the mock version.
environements
Run tests with different bundlers and maybe with node. So environments are just the bindings for the bundlers to the test code in test/tests
.
Why is it not just:
lib test
Where would the shared stuff be placed? Intermixed with the modules?
from node-libs-browser.
lib/util
could be better merged into lib
.
from node-libs-browser.
A good example mock for buffer.
I want the mocks to be a very small version of the buildin lib which do not implement any features to the full module, but provide a similar API.
If you now you app do not really use any feature of the vm module, but some (stupid) 3rd party lib has a reference to it, you may choose to use the mock version.
This is not for this library to decide imho. Module authors can make use of the browser field which was created specifically for such things. End users can educate the bundler to further replace files. In browserify we can do bundle.require('/path/to/file', { expose: 'vm' });
to replace the vm that would load for the user if they want to opt out for all. Really this is on a per module level to decide. This module should provide as close to best effort as possible for the core libs and leave it at that. We could have a folder with some examples of smaller things but I would not expose those. Or make a different module.
Different bundlers should instrument themselves properly imho on top of a common test suite. I would not want to repeat tests over and over again. I will make an example that uses mocha testing to also work in travis, locally, and on testling to capture browser support ;)
from node-libs-browser.
This is not for this library to decide imho. Module authors can make use of the browser which was created specifically for such things.
In a perfect world they would do so 👍
End users can educate the bundler to further replace files. In browserify we can do
bundle.require('/path/to/file', { expose: 'vm' });
to replace the vm that would load for the user if they want to opt out for all.
This is the use case I target to with mocks. bundle.require('node-libs-browser/lib/mock/vm', { expose: 'vm' });
Really this is on a per module level to decide.
The authors can do so which the browser
field.
This module should provide as close to best effort as possible for the core libs and leave it at that.
yes.
We could have a folder with some examples of smaller things but I would not expose those. Or make a different module.
So we could have a folder for mocks, but we don't expose it. Anyone could use it by referencing the file directly. I think an extra module is too much for mocks...
Different bundlers should instrument themselves properly imho on top of a common test suite. I would not want to repeat tests over and over again. I will make an example that uses mocha testing to also work in travis, locally, and on testling to capture browser support ;)
That's that want I also wanted to do. A shared test suite with test code (test/tests) plus a few small files which just configure the bundlers to use the test suite (test/environments).
lib - shared stuff/shims i. e. objectKeys.js
core - all libs i. e. assert.js
mock - mocks of all libs i. e. assert.js
test
tests - shared test suite for all environments i. e. timers.test.js
environments - environments to run tests in with references to ../tests
node.js
browserify.js
webpack.js
from node-libs-browser.
Sounds more reasonable. I would do core
files right into lib. And put mock
at the top level as well for shorter paths in direct access. And yes, I would not expose mock directly. Seems cool otherwise although I think we may find the environments thing is not needed.
from node-libs-browser.
So I pushed a new directory structure...
lib - all buildin libs - i.e. assert.js
util - shared stuff of the buildin libs - i.e. objectKeys.js
mock - some mocks for libs - i.e. buffer.js
test
suite - the test cases
browserify - run the test cases with browserify
webpack - run the test cases with webpack
from node-libs-browser.
Exported is a plain list of modules:
require("node-libs-browser");
{
assert: "/path/to/node-libs-browser/lib/assert.js",
events: "/path/to/node-libs-browser/lib/events.js",
http: "/path/to/node-libs-browser/node_modules/http-browserify/index.js",
/* ... */
}
from node-libs-browser.
Nice. What I think I will do is make browser-resolve options take a "map" object like the one above. This way users of that module can pass in their own set of core (if they want). This will make browser-resolve not have to force any particular mappings on people. It will have a default set (based on this module).
from node-libs-browser.
I've done the same as alias
option/plugin for webpack:
- https://github.com/webpack/node-libs-browser/blob/master/test/webpack/webpack.config.js#L14
- https://github.com/webpack/webpack/blob/master/lib/node/NodeSourcePlugin.js#L25
from node-libs-browser.
Related Issues (20)
- The Elliptic package 6.5.2 for Node.js allows ECDSA signature malleability via variations in encoding, leading '\0' bytes, or integer overflows.
- The new version of readable-stream is incompatible HOT 1
- New version of stream browser/ index.js
- dependencies:{"readable-stream": "^2.3.3" } in package.json ,have a mistake in building project HOT 1
- Deprecate the npm package? HOT 1
- good idea why stop develop
- bump url dependency module version to remove querystring dependency
- 请求报错 code: MissingDateHeader
- crypto-browserify needs help
- console polyfill outdated
- Incompatibility between Node.js core libs and webpack's lib HOT 4
- Publish on npm already! HOT 1
- Old path-browserify is very slow on long pathnames (should I say ReDoS'able?) HOT 1
- Module not found: Can't resolve 'util' HOT 2
- process.nextTick polyfill is slow when tab is unfocused
- buffer 4.9.1 can cause errors
- why has this become deprecated? HOT 8
- Compatibility with new readable-stream HOT 3
- TypeError: The "original" argument must be of type Function HOT 5
- path-browserify 0.X won't support path.parse method HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-libs-browser.