Skip to content

[BUG] Middleware is loading .js.map of .js #255

@ivanproskuryakov

Description

@ivanproskuryakov

The Problem comes when a custom middleware based on Typescript is used. Typescript generates two files .js and .js.map - which is used for mapping.
errorhandler js map - resport today - www resport dev resport today 2017-07-26 12-08-38

map.js should be also covered in getExcludedExtensions method https://github.com/strongloop/loopback-boot/blob/master/lib/utils.js#L101

Otherwise, its breaking the execution with the error:

Unhandled rejection SyntaxError: Unexpected token :
/Users/ivan/www/resport.dev/resport.today/build/server/middleware/errorLogger.js.map:1
(function (exports, require, module, __filename, __dirname) { {"version":3,"sources":["server/middleware/errorLogger.ts"],"names":[],"mappings":";AAAA,6CAA0C;AAK1C,iBAAS,cAAM,OAAA,UAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI;IACjC,IAAI,eAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/B,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACnB,CAAC,EAHc,CAGd,CAAC","file":"errorLogger.js","sourcesContent":["import {Logger} from 'app/service/logger';\n\n/**\n * error logger middleware\n */\nexport = () => (err, req, res, next) => {\n  new Logger(req.app).error(err);\n  return next(err);\n};\n"]}
                                                                        ^
SyntaxError: Unexpected token :
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:513:28)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at /Users/ivan/www/resport.dev/resport.today/node_modules/loopback-boot/lib/plugins/middleware.js:259:19
    at Array.forEach (native)
    at Middleware.start (/Users/ivan/www/resport.dev/resport.today/node_modules/loopback-boot/lib/plugins/middleware.js:253:14)
    at executePluginPhase (/Users/ivan/www/resport.dev/resport.today/node_modules/loopback-boot/lib/bootstrapper.js:166:39)

Tested on: 2.25.0, 3.0.1.
Vendors:

    "loopback": "3.9.0",
    "loopback-boot": "3.0.1",
    "loopback-component-explorer": "4.2.0",
    "loopback-component-passport": "3.4.0",
    "loopback-connector-mongodb": "3.2.1",
    "loopback-ds-timestamp-mixin": "3.4.1",

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions