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

__esModule in ts cause breaking change #51473

Closed
Jack-Works opened this issue Nov 10, 2022 · 2 comments · Fixed by #51474
Closed

__esModule in ts cause breaking change #51473

Jack-Works opened this issue Nov 10, 2022 · 2 comments · Fixed by #51474

Comments

@Jack-Works
Copy link
Contributor

In #51387 the codebase changed to use ESBuild. And now require('typescript') will include __esModule: true and that is a breaking change.

> require("typescript").version
'4.9.2-rc'
> require("typescript").__esModule
undefined
>
> require('typescript').version
'5.0.0-dev.20221109'
> require('typescript').__esModule
true
>

This crashes https://github.com/hipstersmoothie/react-docgen-typescript-plugin

TypeError: Cannot read properties of undefined (reading 'JsxEmit')
    at DocgenPlugin.getOptions (node_modules/@storybook/react-docgen-typescript-plugin/dist/plugin.js:246:39)

It's output code uses tslib.importDefault to import typescript.

const typescript_1 = tslib_1.__importDefault(require("typescript"));
let compilerOptions = {
    jsx: typescript_1.default.JsxEmit.React,
    //   ~~~~~~~~~~~~~~~~~~~~ ts namespace before, undefined after
    module: typescript_1.default.ModuleKind.CommonJS,
    target: typescript_1.default.ScriptTarget.Latest,
};
@jakebailey
Copy link
Member

Thanks for testing this so early. This is unfortunate.

Can you try with "typescript": "npm:@typescript-deploys/pr-build@5.0.0-pr-51474-2" and see if the issue goes away? (from #51474)

@Jack-Works
Copy link
Contributor Author

yes, this fixes the problem

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

Successfully merging a pull request may close this issue.

2 participants