Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[esnext] tsconfig.server.json remove "module":"commonjs" issue #195

Open
AmaelN opened this issue Dec 18, 2019 · 1 comment
Open

[esnext] tsconfig.server.json remove "module":"commonjs" issue #195

AmaelN opened this issue Dec 18, 2019 · 1 comment

Comments

@AmaelN
Copy link

AmaelN commented Dec 18, 2019

Hi,

Using commonjs, there is not isssue. Everything is working fine

I've spent the morning on this issue and I've created a sample to reproduce the issue:

When I remove the "module":"commonjs" from tsconfig.server.js from tour of heroes

"compilerOptions": {
  "outDir": "../out-tsc/app",
  "baseUrl": "./",
  //"module": "commonjs",
  "types": []
},

It will use by default "esnext" module

and include a hello world wt-lazy and add it to the app.component.ts then npm run build:ssr

.html

<wt-lazy [location]="helloLocation"
         [inputs]="{name:'World'}"></wt-lazy>

app.component.ts

helloLocation = {
        moduleId: 'wt-hello',
        selector: 'app-hello'
    };

app.module.ts

 imports: [
...
 ReactiveComponentLoaderModule.forRoot(),
        ReactiveComponentLoaderModule.withModule({
            moduleId: 'wt-hello',
            loadChildren: () => import('src/app/hello/hello.module').then(m => m.HelloModule)
        }),
]

under dist/server/, i will find a file name hello-hello-module-ngfactory.js

If I run the server with node dist/server

I will get the following error

Running on the server with appId=tour-of-heroes
ERROR TypeError: Cannot read property 'call' of undefined
    at __webpack_require__ (C:\dev\test\universal\dist\server.js:69485:30)
    at Function.requireEnsure [as e] (C:\dev\test\universal\dist\server.js:69504
:25)
    at Object.ɵ0 [as loadChildren] (C:\dev\test\universal\dist\server.js:69819:3
8)
    at ReactiveComponentLoader.<anonymous> (C:\dev\test\universal\dist\server.js
:157144:65)
    at step (C:\dev\test\universal\dist\server.js:34967:23)
    at Object.next (C:\dev\test\universal\dist\server.js:34948:53)
    at C:\dev\test\universal\dist\server.js:34941:71
    at new ZoneAwarePromise (C:\dev\test\universal\dist\server.js:1068:33)
    at __awaiter (C:\dev\test\universal\dist\server.js:34937:12)
    at ReactiveComponentLoader._getModuleFactory (C:\dev\test\universal\dist\ser
ver.js:157133:71)

For the moment, I have a solution using commonjs module nevertheless whenever you have time it will be good to be able to use 'esnext'

Thanks in advance

@AmaelN
Copy link
Author

AmaelN commented Dec 18, 2019

I'm using "@wishtack/reactive-component-loader": "^1.1.1",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant