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

@linaria/babel doesn't work #704

Closed
ym-project opened this issue Nov 23, 2020 · 8 comments
Closed

@linaria/babel doesn't work #704

ym-project opened this issue Nov 23, 2020 · 8 comments
Assignees
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked bundler: webpack 📦 Issue is related to webpack bundler needs: complete repro 🖥️ Issue need to have complete repro provided

Comments

@ym-project
Copy link

Environment

packages

  • "@babel/cli": "^7.12.7"
  • "@babel/core": "^7.12.7"
  • "@linaria/babel": "^3.0.0-beta.0"
  • "@linaria/webpack4-loader": "^3.0.0-beta.0"
  • "babel-loader": "^8.2.1"
  • "webpack": "^4.44.2"
  • "webpack-cli": "^4.2.0"

software

  • nodejs: v15.2.1
  • os: ArchLinux 5.5.13-arch2-1

Description

When I try to bundle the project I get an error:

ERROR in ./src/index.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Cannot find module '@linaria/babel-preset-babel' from '.../linaria-test'
- If you want to resolve "@linaria/babel", use "module:@linaria/babel"
    at Function.resolveSync [as sync] (.../linaria-test/node_modules/resolve/lib/sync.js:90:15)
    at resolveStandardizedName (.../linaria-test/node_modules/@babel/core/lib/config/files/plugins.js:101:31)
    at resolvePreset (.../linaria-test/node_modules/@babel/core/lib/config/files/plugins.js:58:10)
    at loadPreset (.../linaria-test/node_modules/@babel/core/lib/config/files/plugins.js:77:20)
    at createDescriptor (.../linaria-test/node_modules/@babel/core/lib/config/config-descriptors.js:154:9)
    at .../linaria-test/node_modules/@babel/core/lib/config/config-descriptors.js:109:50
    at Array.map (<anonymous>)
    at createDescriptors (.../linaria-test/node_modules/@babel/core/lib/config/config-descriptors.js:109:29)
    at createPresetDescriptors (.../linaria-test/node_modules/@babel/core/lib/config/config-descriptors.js:101:10)
    at presets (.../linaria-test/node_modules/@babel/core/lib/config/config-descriptors.js:47:19)

As I understand babel can not to find @linaria/babel. Instead of necessary package babel try to find @linaria/babel-preset-babel. Previous version (2.0) has linaria/babel package and it works great.

Reproducible Demo

https://github.com/ym-project/linaria-babel-bug

@ym-project ym-project added bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided needs: triage 🏷 Issue needs to be checked and prioritized labels Nov 23, 2020
@github-actions github-actions bot added bundler: webpack 📦 Issue is related to webpack bundler and removed needs: triage 🏷 Issue needs to be checked and prioritized labels Nov 23, 2020
@Anber
Copy link
Collaborator

Anber commented Nov 23, 2020

Hi @ym-project

I've also faced that problem. As a workaround, you can replace @linaria/babel in a config with module:@linaria/babel.

@Anber Anber self-assigned this Nov 23, 2020
@ym-project
Copy link
Author

Hi @ym-project

I've also faced that problem. As a workaround, you can replace @linaria/babel in a config with module:@linaria/babel.

Your solution requires an additional dependency

Error: [BABEL] .../linaria-test/src/index.js: Cannot find module '@linaria/shaker'

But after installing it's ok.

@Anber
Copy link
Collaborator

Anber commented Nov 23, 2020

Yep, it's correct dependency. Just forgot to add it to the documentation.

@shaodahong
Copy link

I use require.resolve(@linaria/babel) to resolved.

@ym-project
Copy link
Author

ym-project commented Nov 27, 2020

I use require.resolve(@linaria/babel) to resolved.

It's a kludge too. Also if your config file is *.json, .babelrc, ..., you can't do it.

I never write a babel plugin and never work with a monorepo. What's really wrong with this plugin?

@Anber
Copy link
Collaborator

Anber commented Dec 7, 2020

According to https://github.com/babel/babel/blob/208acb1d6c216b265fd49b9d393237a45725ff6a/packages/babel-core/src/config/files/plugins.js#L79, Babel tries to standardize all names of plugins and presets. If we rename @linaria/babel to @linaria/babel-preset it will be possible to use short @linaria as a preset name.
@satya164 @thymikee what do you think?

@satya164
Copy link
Member

satya164 commented Dec 7, 2020

According to https://github.com/babel/babel/blob/208acb1d6c216b265fd49b9d393237a45725ff6a/packages/babel-core/src/config/files/plugins.js#L79, Babel tries to standardize all names of plugins and presets. If we rename @linaria/babel to @linaria/babel-preset it will be possible to use short @linaria as a preset name.
@satya164 @thymikee what do you think?

Sounds good to me

@Anber
Copy link
Collaborator

Anber commented Dec 8, 2020

@linaria/babel was renamed to @linaria/babel-preset in 3.0.0-beta.1. It should fix the issue.

@Anber Anber closed this as completed Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked bundler: webpack 📦 Issue is related to webpack bundler needs: complete repro 🖥️ Issue need to have complete repro provided
Projects
None yet
Development

No branches or pull requests

4 participants