Skip to content

__esModule in ts cause breaking change #51473

Closed

Description

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,
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions