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

[Bug]: ts-loader runs into an error with rspack #6306

Open
pushkargupta9807 opened this issue Apr 20, 2024 · 6 comments
Open

[Bug]: ts-loader runs into an error with rspack #6306

pushkargupta9807 opened this issue Apr 20, 2024 · 6 comments
Assignees
Labels
bug Something isn't working pr welcome

Comments

@pushkargupta9807
Copy link

System Info

System:
OS: Linux 6.2 Ubuntu 20.04.6 LTS (Focal Fossa)
CPU: (32) x64 AMD EPYC 7763 64-Core Processor
Memory: 113.67 GB / 125.78 GB
Container: Yes
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 20.11.0 - /usr/local/share/nvm/versions/node/v20.11.0/bin/node
Yarn: 1.23.19 - /usr/bin/yarn
npm: 10.2.4 - /usr/local/share/nvm/versions/node/v20.11.0/bin/npm
Watchman: 20240317.093234.0 - /usr/local/bin/watchman
Browsers:
Chrome: 124.0.6367.60
npmPackages:
@rspack/cli: 0.6.2 => 0.6.2
@rspack/core: 0.6.2 => 0.6.2

Details

So running into the below error when using ts-loader for some files. (for other files I am using builtin:swc-loader) .

ERROR in ../../someFile.graphql.ts
  × Module build failed:
  ╰─▶   × TypeError: Cannot read properties of undefined (reading 'buildMeta')
        │     at setModuleMeta (/workspaces/teams-modular-packages/node_modules/ts-loader/dist/index.js:62:31)
        │     at makeSourceMapAndFinish (/workspaces/teams-modular-packages/node_modules/ts-loader/dist/index.js:56:5)
        │     at successLoader (/workspaces/teams-modular-packages/node_modules/ts-loader/dist/index.js:39:5)

And this error is coming from the following piece of code in ts-loader:

function setModuleMeta(loaderContext, instance, fileVersion) {
    // _module.meta is not available inside happypack
    if (!instance.loaderOptions.happyPackMode &&
        loaderContext._module.buildMeta !== undefined) {
        // Make sure webpack is aware that even though the emitted JavaScript may be the same as
        // a previously cached version the TypeScript may be different and therefore should be
        // treated as new
        loaderContext._module.buildMeta.tsLoaderFileVersion = fileVersion;
    }
}

I do not run into this error with webpack.
Currently I am getting around this issue with setting happyPackMode as true for rspack.

Reproduce link

No response

Reproduce Steps

try using ts-loader for some .tsx. file -> should repro this error.

@pushkargupta9807 pushkargupta9807 added bug Something isn't working pending triage The issue/PR is currently untouched. labels Apr 20, 2024
@h-a-n-a
Copy link
Collaborator

h-a-n-a commented Apr 22, 2024

LoaderContext does not support _module yet, but PR is welcome

@h-a-n-a h-a-n-a added pr welcome and removed pending triage The issue/PR is currently untouched. labels Apr 22, 2024
@coder-xiaotian
Copy link
Contributor

LoaderContext does not support _module yet, but PR is welcome

I would like to give it a try.

@h-a-n-a
Copy link
Collaborator

h-a-n-a commented Apr 25, 2024

@coder-xiaotian Adding custom fields to buildMeta does not quite reasonable while we need to pass the value back and forth from rust to node. This is not related to this issue, but exposing a readonly _module is fine.

@coder-xiaotian
Copy link
Contributor

@coder-xiaotian Adding custom fields to buildMeta does not quite reasonable while we need to pass the value back and forth from rust to node. This is not related to this issue, but exposing a readonly _module is fine.@coder-xiaotianbuildMeta 中添加自定义字段不太合理,而我们需要在 rust 和节点之间来回传递值。这与此问题无关,但公开只读 _module 就可以了。

Ok, Get it.

@viqcinese-axur
Copy link

Any follow-ups here? Would love to see typescript errors integrated with hot refresh

@coder-xiaotian
Copy link
Contributor

Any follow-ups here? Would love to see typescript errors integrated with hot refresh

I have committed my code to fix ts-loader error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pr welcome
Projects
None yet
Development

No branches or pull requests

4 participants