8000 ts-nameof does not work with Typescript 4.3 and Webpack · Issue #115 · dsherret/ts-nameof · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
ts-nameof does not work with Typescript 4.3 and Webpack #115
Open
@mhienle

Description

@mhienle

Some relevant dependencies used:

    "@types/ts-nameof": "^4.2.1",
    "ts-loader": "^9.2.3",
    "ts-nameof": "^5.0.0",
    "typescript": "^4.3.2",
    "webpack": "^5.41.1",
    "webpack-cli": "^4.7.2",
    "webpack-dev-server": "^3.11.2",

Relevant parts of webpack-config:

    module: {
        rules: [
            {
                test: /\.tsx?$/,
                use: [
                    {
                        loader: 'ts-loader',
                        options: {
                            transpileOnly: true,
                            getCustomTransformers: () => ({ before: [tsNameof] }),
                        },
                    },
                ],
            },
        ],
    },

I get the following error at runtime:

Uncaught ReferenceError: nameof is not defined
    at eval (webpack-internal:///./src/components/Pages/Pages.tsx:36)
    at Object../src/components/Pages/Pages.tsx (bundle.min.app.f52422b76f41c59b99cb.js:15146)
    at __webpack_require__ (bundle.min.app.f52422b76f41c59b99cb.js:23364)
...

As it turns out, the line in bundle.min.app.f52422b76f41c59b99cb.js mentioned in the error contains calls to the function nameof which is indeed not defined anywhere. This seems to happen since Typescript 4.3, at least in my setup: Looking at the minified bundle using the older TS-version 4.2.4, I cannot find such a call, hence everything works fine.

Any help is appreciated! 🙏🏻

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

      0