question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript: nodeExtractor.requireEntrypoint returns undefined

See original GitHub issue

💬 Questions and Help

Hi everybody,

first I want to thank you for the awesome piece of software you created. Now to my problem.

Problem

Based on the SSR example in this repo, I have created my own example here. The only difference: it is a TypeScript example.

I’ve got the problem, that

const { default: App } = nodeExtractor.requireEntrypoint('main')

always returns undefined (here). Not sure why this happens and how I can fix it.

In my webpack config I use both babel-loader and ts-loader together with typescript-loadable-components-plugin:

// webpack.config.js
module: {
    rules: [
      {
        test: /\.(ts)x?$/,
        exclude: /node_modules/,
        use: [
          {
            loader: 'babel-loader',
          },
          {
            loader: 'ts-loader',
            options: {
              getCustomTransformers: (program) => ({
                before: [createLoadableComponentsTransformer(program, {})],
              }),
            },
          },
        ],
      },
    ],
  },

I noticed that I am also unable to use webpackChunkName (the bundles get ascending numbers, e.g. 0.js, 1.js) but that’s another problem for another issue report https://github.com/acrazing/typescript-loadable-components-plugin/issues/3.

Could you please help me? Thank you very much. I appreciate every type of support.

Expected Result

SSR in a typescript app works similar to the JS example.

Example Repo

Related Issues

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
natterstefancommented, Aug 31, 2020

Hi @theKashey,

FTR: I’ve also had to change the libraryTarget similar to the one in the example. Without this change App was still undefined. So it was the combination of both I guess.

Why did it fix the problem? I have no idea 😅

I have no idea too ^^. I was just happy to find a solution 😄

0reactions
abhishek-mittalcommented, Feb 15, 2022

@natterstefan thanks for the acknowledgment, much appreciated. ✌️

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exports undefined when trying to bundle a typescript library ...
I faced with the same problem. And this solved it for me: In webpack.config.js: output: { ... libraryTarget: 'umd', library: 'MyPackageName' ...
Read more >
2021年08月_weixin_39683734的博客
ajax实现向上正在加载,jQuery实现单行文字间歇向上滚动源代码,app服务器指向dat文件,appdat-系统爱好者,饼图ajax请求数据如何写,Echarts饼状图数据交互请求ajax自定义 ...
Read more >
Getting error "Path" argument must be string while deploying React
I'm trying to integrate Loadable components in my SSR project and that is ... requireEntrypoint() const webExtractor = new ChunkExtractor({ statsFile: ...
Read more >
styled-component的分体渲染,代码分离(不是next.js)。
web/loadable-stats.json');; const nodeExtractor = new ChunkExtractor({ ... requireEntrypoint();; const webExtractor = new ChunkExtractor({ ...
Read more >
Greg Bergé loadable-components Issues
extract interface in typescript ... Why is the fallback of the Suspense component invalid? ... requireEntrypoint crashing to "self is not defined".
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found