novemberborn / cached-module-loader Goto Github PK
View Code? Open in Web Editor NEWHighly experimental bundler and loader of Node.js modules
Highly experimental bundler and loader of Node.js modules
I think the API for that module could be simple and export only one factory function, which returns a modified require()
:
const cachedRequire = require('cached-module-loader'){
cachePath: join(__dirname, '.module-cache'),
ignore: [/regex/, /to/, /ignore/]
});
const babel = cachedRequire('babel-core');
const got = cachedRequire('got');
cachedRequire()
's source would be something along:
function cachedRequire(moduleId) {
if (!isCacheExists(moduleId)) {
bundleDependencies(moduleId);
}
return loadInThisContext(moduleId);
}
What do you think?
module
object must be the same (aside from module.parent
).It's ridiculously slow for this use case.
The cachedData
Script API is only supported in Node.js v6. This module should probably work with older Node.js versions, even without cachedData
.
Module caches may include lots of files. These are dependent on file system location, Node.js version, and indeed package version. This package should explain appropriate caching strategies.
I reckon that the cache should be discarded when the Node.js version changes. Perhaps we should generate a cache key that takes the version into account, allowing caches for different versions to live side-by-side.
The cache contains hardcoded file paths, so we need an easy way to verify the presumed location of the sources.
Integration with package-hash
should be easy.
Perhaps we can resolve the npm modules the cache depends on. Then the respective package.json
files could be hashed and verified before using the cache.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.