- The solution must be 100% backward-compatible.
- In the far future, developers should be able to write Node programs and libraries without knowledge of the CommonJS module system.
- Module resolution rules should be reasonably compatible with the module resolution rules used by browsers.
- The ability to import a legacy package is important for adoption.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var webpack = require('webpack'); | |
var MemoryFS = require('memory-fs'); | |
var SingleEntryDependency = require('webpack/lib/dependencies/SingleEntryDependency'); | |
var fs = new MemoryFS(); | |
fs.mkdirpSync('/src'); | |
fs.writeFileSync('/src/app.js', 'require("./dep.js")', 'utf-8'); | |
fs.writeFileSync('/src/dep.js', 'module.exports = function(msg){console.log(msg)}', 'utf-8'); | |
fs.writeFileSync('/src/extra-entry.js', 'require("./dep.js")', 'utf-8'); |
This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.
Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:
getTweetsFor("domenic", function (err, results) {
// the rest of your code goes here.
NewerOlder