Hot module replacement doesn't work with tsconfig target es5 #966

Closed
opened 2025-08-09 17:18:21 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @t0x1c123 on 3/3/2017

Hello I have a problem. I switched target in tsconfig from es6 to es5. The reason why is that i want to use react-helmet and with target es6 i get error like this:

Call to Node module failed with error: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function

with import like this: import * as Helmet from 'react-helmet';

So I manage it to work by switching target from es6 to es5 but hot reload is now broken. In console output looks everything fine no errors but nothing changes.

My tsconfig.js

  "compilerOptions": {
    "baseUrl": ".",
    "moduleResolution": "node",
    "target": "es5",
    "jsx": "preserve",
    "experimentalDecorators": true,
    "sourceMap": true,
    "skipDefaultLibCheck": true,
    "lib": ["es6", "dom"],
    "types": [ "webpack-env" ],
    "paths": {
      // Fix "Duplicate identifier" errors caused by multiple dependencies fetching their own copies of type definitions.
      // We tell TypeScript which type definitions module to treat as the canonical one (instead of combining all of them).
      "history": ["./node_modules/@types/history/index"],
      "redux": ["./node_modules/@types/redux/index"],      
      "react": ["./node_modules/@types/react/index"]
    }
  },
  "exclude": [
      "bin",
      "node_modules"
  ]
}
*Originally created by @t0x1c123 on 3/3/2017* Hello I have a problem. I switched target in tsconfig from es6 to es5. The reason why is that i want to use react-helmet and with target es6 i get error like this: Call to Node module failed with error: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function with import like this: import * as Helmet from 'react-helmet'; So I manage it to work by switching target from es6 to es5 but hot reload is now broken. In console output looks everything fine no errors but nothing changes. My tsconfig.js ```javascript{ "compilerOptions": { "baseUrl": ".", "moduleResolution": "node", "target": "es5", "jsx": "preserve", "experimentalDecorators": true, "sourceMap": true, "skipDefaultLibCheck": true, "lib": ["es6", "dom"], "types": [ "webpack-env" ], "paths": { // Fix "Duplicate identifier" errors caused by multiple dependencies fetching their own copies of type definitions. // We tell TypeScript which type definitions module to treat as the canonical one (instead of combining all of them). "history": ["./node_modules/@types/history/index"], "redux": ["./node_modules/@types/redux/index"], "react": ["./node_modules/@types/react/index"] } }, "exclude": [ "bin", "node_modules" ] } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#966
No description provided.