Skip to content

update for esm - #130

Open
tonisives wants to merge 1 commit into
react-simple-code-editor:mainfrom
tonisives:esm
Open

tonisives wants to merge 1 commit into
react-simple-code-editor:mainfrom
tonisives:esm

Conversation

@tonisives

Copy link
Copy Markdown

Motivation

Code editor does not work in vite component libraries or vite-federation

I think this is specific to my frontend, which uses type: "module" and some specific tsconfig options

{
  "compilerOptions": {
    "target": "es2022",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "types": [
      "vite/client"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx"
  },
  "include": [
    "src",
    "src/setupTests.ts"
  ]
}

However, I think this configuration is quite modern, and might be preferrable.

For this tsConfig, and when using code editor in a Component library or a federation remote, the code editor fails with undefined, calling useState error. Eg, it doesn't find React.

Test plan

I tested this PR with federation plugin, and it works.

Note that this is just a quick mockup and can be used as basis for a proper PR.

This branch has not been deployed

No deployments
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 this pull request may close these issues.

1 participant