Last active
January 15, 2016 20:22
-
-
Save cuth/aaea4769d738656bd9d9 to your computer and use it in GitHub Desktop.
Disable AMD when requiring a file.
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
const safeRequire = require('./safe-require'); | |
const umdStyleMod = safeRequire('umd-style-mod', () => require('umd-style-mod')); |
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
'use strict'; | |
/* global define */ | |
const cache = {}; | |
module.exports = function (name, req) { | |
if (cache.hasOwnProperty(name)) { | |
return cache[name]; | |
} | |
if (typeof define === 'function' && define.amd) { | |
const temp = define.amd; | |
define.amd = false; | |
cache[name] = req(); | |
define.amd = temp; | |
} else { | |
cache[name] = req(); | |
} | |
return cache[name]; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment