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

Avoid emotion/react dependency #313

Open
alexfreixa opened this issue Apr 24, 2024 · 1 comment
Open

Avoid emotion/react dependency #313

alexfreixa opened this issue Apr 24, 2024 · 1 comment

Comments

@alexfreixa
Copy link

alexfreixa commented Apr 24, 2024

Describe your question

Hello!

Im using your "Image" component for my block creations which is working so good!

Now I'm having a small issue, related to @emotion/react dependecy that @10up/block-components is using.

I was creating multiple blocks and I suddendly realized I'm having more alert messages like this, all the same:

You are loading @emotion/react when it is already loaded. Running multiple instances may cause problems. This can happen if multiple versions are used, or if multiple builds of the same version are used.

The more blocks I create, the more messages like these accumulate.
This happens after creating my block folders in the "src" folder and doing the "npm run build".

Any idea how can I fix this and only load this dependency once? Sorry if this is not the right place for this question, maybe it's not related at all. I'm a newbie in custom block themes creation.

This is what I see when I run: npm ls @emotion/react

@10up/[email protected]
├── @emotion/[email protected]
└─┬ @emotion/[email protected]
└── @emotion/[email protected] deduped

This is what I have in my package-lock.json, where "@emotion/react" is called many times and different versions. (I've deleted some json parts for this question)

"node_modules/@10up/block-components": { "version": "1.18.1", "resolved": "https://registry.npmjs.org/@10up/block-components/-/block-components-1.18.1.tgz", "integrity": "sha512-ZglHvEdgt6OoutAstUzPP2JombTy+wc9ZKTB1AsEWvs8sAMeYsOvy98hJlps42zl0UKtUlwFS/Ut27PMzC3t5g==", "dependencies": { ... "@emotion/react": "^11.10.5", ... } }

Here too:

"node_modules/@10up/block-components": { "version": "1.18.1", "resolved": "https://registry.npmjs.org/@10up/block-components/-/block-components-1.18.1.tgz", "integrity": "sha512-ZglHvEdgt6OoutAstUzPP2JombTy+wc9ZKTB1AsEWvs8sAMeYsOvy98hJlps42zl0UKtUlwFS/Ut27PMzC3t5g==", "dependencies": { ... "@emotion/react": "^11.10.5", ... } }

And finally here too:

"node_modules/@emotion/react": { "version": "11.11.4", "resolved": "https://registry.npmjs.org/@emotion/react/-/react-11.11.4.tgz", }

@alexfreixa
Copy link
Author

I just fixed it.

When creating a new block, in my index.js, I had an error alert that said:

Parsing error: 'import' and 'export' may appear only with 'sourceType: module'eslint

So I added "sourceType": "module" to my .eslintrc file:

"parserOptions": {
				"ecmaVersion": "latest",
				"sourceType": "module"
			}

I don't have the duplicated message alert.

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

1 participant