From a78a05f9b4f40dd223d85da42887dcf8e546a45e Mon Sep 17 00:00:00 2001 From: Zak Barbuto Date: Thu, 14 Sep 2017 09:34:25 +0930 Subject: [PATCH] Ignore source maps in boot --- lib/utils.js | 6 ++++++ test/compiler.test.js | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/lib/utils.js b/lib/utils.js index 0035183..56dad1f 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -102,6 +102,12 @@ function getExcludedExtensions() { return { '.json': '.json', '.node': 'node', + /** + * This is a temporary workaround for #246 + * See discussion here for full description of the underlying issue + * https://github.com/strongloop/loopback-boot/pull/245#issuecomment-311052798 + */ + '.map': 'map', }; } diff --git a/test/compiler.test.js b/test/compiler.test.js index efd4655..47d94a9 100644 --- a/test/compiler.test.js +++ b/test/compiler.test.js @@ -2632,6 +2632,28 @@ describe('compiler', function() { }); }); + it('ignores sourcmap files when loading middleware', + function(done) { + var middleware = appdir.writeFileSync('my-middleware.js', + '// I am the middleware'); + var sourcemap = appdir.writeFileSync('my-middleware.js.map', + '// I am a sourcemap'); + appdir.writeConfigFileSync('middleware.json', { + 'routes': { + './my-middleware': {}, + }, + }); + + boot.compile(appdir.PATH, function(err, context) { + if (err) return done(err); + var instructions = context.instructions; + + expect(instructions.middleware.middleware[0]).have.property( + 'sourceFile', middleware); + done(); + }); + }); + describe('config with relative paths in params', function() { var RELATIVE_PATH_PARAMS = [ '$!./here',