brandonroberts / angular-router-loader

A Webpack loader that enables string-based module loading with the Angular Router

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: can't convert undefined to object

Luke265 opened this issue · comments

commented

I'm keep getting TypeError: can't convert undefined to object error when lazy loading child modules. But when I change arrow function to function in https://github.com/brandonroberts/angular-router-loader/blob/master/src/utils.js#L36, example below:

  var result = [
    'loadChildren: function() { return System.import(\'' + filePath + '\')',
    '  .then(function(module) {',
    '    return module[\'' + moduleName + '\'];',
    '  });}'
  ];

The error goes away. Should I create PR?

package.json:

{
  "dependencies": {
    "@angular/animations": "^4.0.1",
    "@angular/common": "^4.0.1",
    "@angular/compiler": "^4.0.1",
    "@angular/compiler-cli": "^4.0.1",
    "@angular/core": "^4.0.1",
    "@angular/forms": "^4.0.1",
    "@angular/http": "^4.0.1",
    "@angular/platform-browser": "^4.0.1",
    "@angular/platform-browser-dynamic": "^4.0.1",
    "@angular/platform-server": "^4.0.1",
    "@angular/router": "^4.0.1",
    "@angular/tsc-wrapped": "4.0.1",
    "@angularclass/hmr": "1.2.2",
    "@angularclass/hmr-loader": "3.0.2",
    "@types/jasmine": "^2.5.46",
    "angular2-contextmenu": "^0.8.2",
    "angular2-dropzone-wrapper": "^2.0.3",
    "angular2-express-engine": "2.1.0-rc.1",
    "angular2-google-maps": "^0.17.0",
    "angular2-modal": "^2.0.3",
    "angular2-platform-node": "2.1.0-rc.1",
    "angular2-universal": "2.1.0-rc.1",
    "angular2-universal-polyfills": "2.1.0-rc.1",
    "body-parser": "1.17.1",
    "compression": "1.6.2",
    "cookie-parser": "1.4.3",
    "core-js": "2.4.1",
    "express": "4.15.2",
    "hammerjs": "~2.0.8",
    "html-minify-loader": "^1.1.0",
    "methods": "1.1.2",
    "ng2-bootstrap": "^1.6.3",
    "ng2-dnd": "^4.0.2",
    "ng2-dropdown": "0.0.21",
    "ng2-nouislider": "^1.6.0",
    "nouislider": "^9.2.0",
    "rxjs": "5.3.0",
    "socket.io-client": "^1.7.3",
    "typescript": "^2.3.0-dev.20170226",
    "zone.js": "0.8.5"
  },
  "devDependencies": {
    "@types/body-parser": "~1.16.3",
    "@types/compression": "~0.0.33",
    "@types/cookie-parser": "~1.3.30",
    "@types/core-js": "~0.9.41",
    "@types/express": "~4.0.35",
    "@types/express-serve-static-core": "~4.0.44",
    "@types/hammerjs": "~2.0.34",
    "@types/ip": "~0.0.29",
    "@types/jasmine": "~2.5.47",
    "@types/mime": "~0.0.29",
    "@types/node": "~7.0.12",
    "@types/protractor": "~4.0.0",
    "@types/selenium-webdriver": "~3.0.1",
    "@types/serve-static": "~1.7.31",
    "angular-router-loader": "~0.6.0",
    "angular2-template-loader": "~0.6.2",
    "awesome-typescript-loader": "^3.1.2",
    "codelyzer": "~3.0.0-beta.4",
    "compression-webpack-plugin": "~0.4.0",
    "copy-webpack-plugin": "~4.0.1",
    "css-loader": "~0.28.0",
    "css-to-string-loader": "^0.1.2",
    "es6-promise": "~4.1.0",
    "es6-promise-loader": "~1.0.2",
    "file-loader": "^0.11.1",
    "html-webpack-plugin": "~2.28.0",
    "imports-loader": "~0.7.1",
    "ip": "~1.1.5",
    "istanbul-instrumenter-loader": "~2.0.0",
    "json-loader": "~0.5.4",
    "karma": "~1.6.0",
    "karma-chrome-launcher": "~2.0.0",
    "karma-coverage": "~1.1.1",
    "karma-jasmine": "~1.1.0",
    "karma-mocha-reporter": "~2.2.3",
    "karma-phantomjs-launcher": "~1.0.4",
    "karma-remap-coverage": "~0.1.4",
    "karma-sourcemap-loader": "~0.3.7",
    "karma-webpack": "~2.0.3",
    "node-sass": "~4.5.2",
    "nodemon": "~1.11.0",
    "npm-run-all": "~4.0.2",
    "phantomjs-polyfill": "~0.0.2",
    "phantomjs-prebuilt": "~2.1.14",
    "protractor": "~5.1.1",
    "raw-loader": "~0.5.1",
    "rimraf": "~2.6.1",
    "sass-loader": "^6.0.3",
    "script-loader": "^0.7.0",
    "source-map-loader": "~0.2.1",
    "string-replace-loader": "~1.2.0",
    "to-string-loader": "~1.1.5",
    "ts-helpers": "~1.1.2",
    "ts-node": "~3.0.2",
    "tslint": "~5.1.0",
    "tslint-loader": "~3.5.2",
    "typescript": "~2.2.2",
    "watch-run": "~1.2.5",
    "webpack": "2.3.3",
    "webpack-bundle-analyzer": "^2.3.1",
    "webpack-dev-middleware": "~1.10.1",
    "webpack-dev-server": "2.4.2",
    "webpack-merge": "~4.1.0"
  }
}

Can you reproduce this a repo or share some code? I don't see why this would cause an error. Have you also tried with the default loader?

commented

Sorry for the trouble. It's everything okay now. There was a problem in my tsconfig.json and webpack. This problem has occurred when I targeted es6. Still trying to figure out why this happened, but your plugin has nothing to do with it :)