UNPKG

812 BJavaScriptView Raw
1/**
2 * When building NativeScript angular apps without webpack (`tns run android`) the moduleId: module.id is necessary.
3 * When building with webpack the angular compiler and webpack handle relative paths in the modules and no longer need moduleId
4 * to be set, however webpack emits numbers for module.id and angular has typecheck for moduleId to be a string.
5 */
6module.exports = function (source, map) {
7 this.cacheable();
8
9 // Strips occurences of `moduleId: module.id,`, since it is no longer needed for webpack builds
10 const noModuleIdsSource = source.replace(/moduleId\:\s*module\.id\s*(\,)?/g, result =>
11 // Try to preserve char count so sourcemaps may remain intact
12 "/*" + result.substring(2, result.length - 2) + "*/"
13 );
14
15 this.callback(null, noModuleIdsSource, map);
16};
\No newline at end of file