-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
SyntaxError: Cannot use import statement outside a module #4338
Comments
Same errror here |
I believe this is a duplicate of facebook/create-react-app#9938. |
@luin Not really - the issue appears to be that quill is defined as type: module but doesn't define a module See: https://nodejs.org/api/packages.html#dual-commonjses-module-packages
Subpath exports can be used to define both require and module exports, and have types for them https://nodejs.org/api/packages.html#subpath-exports As it stands today this package doesn't appear to fully support dual packages which makes integration with tools like jest challenging. Please consider using one of the dual package approaches outlined in the link |
@chrishoage - thank you for the input. Do you think there is any workaround getting the unit tests running with this package? @luin - do you have any tentative date to fix this? |
We used jest This allowed jest to use the "ADM" build of quill which jest can use with out any extra compilation on quill |
@chrishoage thanks for the hint, that's worked for us! Specifically, in our export default {
//...
moduleNameMapper: {
'^quill$': 'node_modules/quill/dist/quill.js'
},
} For those using an nx monorepo with a root |
@luin please chime in if you have anything else to add |
Please describe the a concise description and fill out the details below. It will help others efficiently understand your request and get to an answer instead of repeated back and forth. Providing a minimal, complete and verifiable example will further increase your chances that someone can help.
Steps for Reproduction
created a basic CRA app. Visit the bare minimum reproducible repo at https://github.com/gitneeraj/test-quill-rte
Expected behavior:
when running the tests
yarn test
should mount the component and test should passActual behavior:
Throws below error -
/home/xx/personal/test-quill/node_modules/quill/quill.js:1
({"Object.":function(module,exports,require,__dirname,__filename,jest){import Quill, { Parchment, Range } from './core.js';
^^^^^^
Platforms:
node - 19 & 20
Include browser, operating system and respective versions
Version:
I have looked at issue #4038 but this does not work anymore
The text was updated successfully, but these errors were encountered: