MCPcopy Index your code
hub / github.com/adaptlearning/adapt_framework / adaptLoader

Function adaptLoader

grunt/tasks/javascript.js:191–253  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

189
190 // Rework modules names and inject plugins
191 const adaptLoader = function() {
192 return {
193
194 name: 'adaptLoader',
195
196 resolveId(moduleId, parentId) {
197 const isRollupHelper = (moduleId[0] === '\u0000');
198 if (isRollupHelper) {
199 // Ignore as injected rollup module
200 return null;
201 }
202 const mapPart = mapParts.find(part => moduleId.startsWith(part));
203 if (mapPart) {
204 // Remap module, usually coreJS/adapt to core/js/adapt etc
205 moduleId = moduleId.replace(mapPart, options.map[mapPart]);
206 }
207 // Remap ../libraries/ or core/js/libraries/ to libraries/
208 moduleId = Object.entries(externalMap).reduce((moduleId, [ match, replaceWith ]) => moduleId.replace((new RegExp(match, 'g')), replaceWith), moduleId);
209 const isRelative = (moduleId[0] === '.');
210 if (isRelative) {
211 if (!parentId) {
212 // Rework app.js path so that it can be made basePath agnostic in the cache
213 const filename = findFile(path.resolve(moduleId));
214 return {
215 id: filename,
216 external: false
217 };
218 }
219 // Rework relative paths into absolute ones
220 const filename = findFile(path.resolve(parentId + '/../' + moduleId));
221 return {
222 id: filename,
223 external: false
224 };
225 }
226 const externalPart = externalParts.find(part => moduleId.startsWith(part));
227 const isEmpty = (options.external[externalPart] === 'empty:');
228 if (isEmpty) {
229 // External module as is defined as 'empty:', libraries/ bower handlebars etc
230 return {
231 id: moduleId,
232 external: true
233 };
234 }
235 const isES6Import = !fs.existsSync(moduleId);
236 if (isES6Import) {
237 // ES6 imports start inside ./src so need correcting
238 const filename = findFile(path.resolve(cwd, options.baseUrl, moduleId));
239 return {
240 id: filename,
241 external: false
242 };
243 }
244 // Normalize all other absolute paths as conflicting slashes will load twice
245 const filename = findFile(path.resolve(cwd, moduleId));
246 return {
247 id: filename,
248 external: false

Callers 1

javascript.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected