You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I stumbled upon a project that may provide the cross-environment module loading goodness Marcus has been dreaming about. The issue title / repo description pretty much says it all. I haven't tested any of this personally, but I'm optimistic.
I believe the CommonJs Strict example is the most compatible flavor out there. I'm not a Node developer. If CommonJs is just for loading backend Node dependencies, then this may not be the best flavor. However, the project is well documented, and I expect a little bit of reading will answer most questions.
I'd love to polish this into a PR, but I have a bunch on my plate right now.
// Uses CommonJS, AMD or browser globals to create a module.// If you just want to support Node, or other CommonJS-like environments that// support module.exports, and you are not creating a module that has a// circular dependency, then see returnExports.js instead. It will allow// you to export a function as the module value.// Defines a module "commonJsStrict" that depends another module called "b".// Note that the name of the module is implied by the file name. It is best// if the file name and the exported global have matching names.// If the 'b' module also uses this type of boilerplate, then// in the browser, it will create a global .b that is used below.// If you do not want to support the browser global path, then you// can remove the `root` use and the passing `this` as the first arg to// the top function.(function(root,factory){if(typeofdefine==='function'&&define.amd){// AMD. Register as an anonymous module.define(['exports','b'],factory);}elseif(typeofexports==='object'){// CommonJSfactory(exports,require('b'));}else{// Browser globalsfactory((root.commonJsStrict={}),root.b);}}(this,function(exports,b){//use b in some fashion.// attach properties to the exports object to define// the exported module properties.exports.action=function(){};}));
The text was updated successfully, but these errors were encountered:
https://github.com/umdjs/umd
I stumbled upon a project that may provide the cross-environment module loading goodness Marcus has been dreaming about. The issue title / repo description pretty much says it all. I haven't tested any of this personally, but I'm optimistic.
I believe the CommonJs Strict example is the most compatible flavor out there. I'm not a Node developer. If CommonJs is just for loading backend Node dependencies, then this may not be the best flavor. However, the project is well documented, and I expect a little bit of reading will answer most questions.
I'd love to polish this into a PR, but I have a bunch on my plate right now.
Hope it helps.
https://github.com/umdjs/umd/blob/master/commonjsStrict.js:
The text was updated successfully, but these errors were encountered: