Skip to content

No thenable exposed on require('http://..) #5

@factoidforrest

Description

@factoidforrest

In the browser console I am getting the error

Cannot read property 'then' of undefined

I am trying to require from inside an angular router loadChildren. In this way I could load into a module from an entirely different project. Localhost here is just used for testing this idea.

const routes: Routes = [
    { path: ``, loadChildren: () => new Promise(function (resolve) {
        require('http://localhost:3100/testset-module-bundle.js').then((response: any) => {
          resolve(response)
        }
      )
      })
    }
];

I'm aware that wrapping it in another promise like that is kind of dumb, but it's just for test purposes so I have more control.

The bundled code output from webpack looks like:

var routes = [
    { path: "", loadChildren: function () { return new Promise(function (resolve) {
            __webpack_require__(406).then(function (response) {
                resolve(response);
            });
        }); }
    }
];

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions