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

Can't access lib/cjs files #621

Closed
Ketler13 opened this issue May 15, 2024 · 3 comments
Closed

Can't access lib/cjs files #621

Ketler13 opened this issue May 15, 2024 · 3 comments

Comments

@Ketler13
Copy link

Describe the bug
First of all, thank you for the very useful package.

In the application I use these lines of code to import stuff I need for custom editor:

import MonacoContainer from '@monaco-editor/react/lib/cjs/MonacoContainer';
import useMount from '@monaco-editor/react/lib/cjs/hooks/useMount';
import useUpdate from '@monaco-editor/react/lib/cjs/hooks/useUpdate';
import usePrevious from '@monaco-editor/react/lib/cjs/hooks/usePrevious';
import {
  noop,
  getOrCreateModel,
  isUndefined,
} from '@monaco-editor/react/lib/cjs/utils';

That works fine at least in 4.3.1. I can see cjs folder exists in node_modules.
But with the latest 4.6.0 version structure is different and looks like main.js does not export those items.
Maybe this is something with my package manager (pnpm) because I can see those hooks and MonacoContainer still exist in the source code.

To Reproduce

Steps to reproduce the behavior:
Install 4.6.0 version of the package

Expected behavior
I expect to still be able to import those elements.

Screenshots
Before (4.3.1):
Screenshot 2024-05-15 at 09 40 36

After (4.6.0):
Screenshot 2024-05-15 at 09 41 13

Desktop (please complete the following information):

  • OS: MacOS
  • Node: 20
  • pnpm: 9.1.1

Additional context
I use pnpm and nx monorepo, not sure if that matters though.

@suren-atoyan
Copy link
Owner

That is correct, we no more support cjs, umd, etc, only js/mjs.

@Ketler13
Copy link
Author

Sorry, but is it possible to still access MonacoContainer, useMount, useUpdate, usePrevious, getOrCreateModel?

@suren-atoyan
Copy link
Owner

Ah, I see what you are saying. Unfortunately, with the current build these utilities/hooks are not available.

  • for useMount, useUpdate and usePreviouse you can use react-use or write your own implementations (they are pretty small), check this to get some inspiration
  • for noop you can use lodash/noop, or write your own implementation. For this and for other utilities check this

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

No branches or pull requests

2 participants