MCPcopy
hub / github.com/meteor/meteor / load

Method load

tools/isobuild/bundler.js:1987–2224  ·  view source on GitHub ↗
(bindings)

Source from the content-addressed store, hash-verified

1985 // that is built to put symbols in the global namespace rather than
1986 // in a compartment of Package
1987 load(bindings) {
1988 var self = this;
1989 var ret = new PackageRegistry();
1990
1991 // XXX This is mostly duplicated from
1992 // static-assets/server/boot.js, as is Npm.require below.
1993 // Some way to avoid this?
1994 var getAsset = function (assets, assetPath, encoding, callback) {
1995 assetPath = files.convertToStandardPath(assetPath);
1996 var promise;
1997 if (! callback) {
1998 if (! Fiber.current) {
1999 throw new Error("The synchronous Assets API can " +
2000 "only be called from within a Fiber.");
2001 }
2002
2003 promise = new Promise(function (resolve, reject) {
2004 callback = function (err, res) {
2005 err ? reject(err) : resolve(res);
2006 };
2007 });
2008 }
2009
2010 var _callback = function (err, result) {
2011 if (result && ! encoding) {
2012 // Sadly, this copies in Node 0.10.
2013 result = new Uint8Array(result);
2014 }
2015 callback(err, result);
2016 };
2017
2018 if (!assets || !_.has(assets, assetPath)) {
2019 _callback(new Error("Unknown asset: " + assetPath));
2020 } else {
2021 var buffer = assets[assetPath];
2022 var result = encoding ? buffer.toString(encoding) : buffer;
2023 _callback(null, result);
2024 }
2025
2026 if (promise) {
2027 return promise.await();
2028 }
2029 };
2030
2031 const nodeModulesDirsByPackageName = new Map;
2032
2033 _.each(self.jsToLoad, item => {
2034 _.each(item.nodeModulesDirectories, nmd => {
2035 if (nmd.local) {
2036 // Consider only non-local node_modules directories for build
2037 // plugins.
2038 return;
2039 }
2040
2041 let name = nmd.packageName;
2042 if (name) {
2043 name = colonConverter.convert(name);
2044 }

Callers 8

loadIsopacketFromDiskFunction · 0.80
main.jsFile · 0.80
isopack.jsFile · 0.80
ModalFunction · 0.80
amplify.jsFile · 0.80

Calls 11

ProfileFunction · 0.85
getAssetFunction · 0.85
eachMethod · 0.80
_makeNpmRequireMethod · 0.80
exceptionMethod · 0.80
hasMethod · 0.45
getMethod · 0.45
setMethod · 0.45
extendMethod · 0.45
resolveMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected