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/loader don't work with ProvidePlugin #319

Closed
Dozalex opened this issue Feb 24, 2019 · 4 comments
Closed

linaria/loader don't work with ProvidePlugin #319

Dozalex opened this issue Feb 24, 2019 · 4 comments
Labels
bundler: webpack 📦 Issue is related to webpack bundler cat: modules aliasing 🔗 Issue related to modules aliasing enhancement: proposal 💬 Improvement of current behaviour that needs to be discussed needs: investigation 🔎 Issue has to be investigated for reason or solution skip autolabeling Use it to disable auto laberer bot for an issue/pr

Comments

@Dozalex
Copy link

Dozalex commented Feb 24, 2019

Do you want to request a feature or report a bug?
feature

What is the current behavior?
linaria/loader don't work if it used in webpack alias - no css bundle.

If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can yarn install and yarn test.

webpack.config

 new webpack.ProvidePlugin({
      React        : 'react',
      Component    : ['react', 'Component'],
      PureComponent: ['react', 'PureComponent'],
      PropTypes    : 'prop-types',
      styled       : ['linaria/react', 'styled'], // not work
      css          : ['linaria', 'css'], // not work
    }),

In components using styled and css without import.

What is the expected behavior?
linaria/loader works

Please provide your exact Babel configuration and mention your Linaria, Node, Yarn/npm version and operating system.

.babelrc

{
  "presets": [["@babel/env", { "modules": false }], "@babel/react", "linaria/babel"],
  "plugins": [
    "react-hot-loader/babel",
    "@babel/plugin-proposal-class-properties",
    ["@babel/plugin-transform-runtime",
      {
        "regenerator": true
      }
    ]
  ]
}

"linaria": "1.1.4",
"node": "11.5.0",
"yarn": "1.12.3",
macOS Mojave

@Dozalex Dozalex changed the title linaria/loader` don't work if it used in webpack alias - no css bundle. linaria/loader don't work if it used in webpack alias Feb 24, 2019
@Dozalex
Copy link
Author

Dozalex commented Feb 25, 2019

@satya164 maybe need more info? It looks like #284 but with linaria alias

@zamotany zamotany changed the title linaria/loader don't work if it used in webpack alias linaria/loader don't work with ProvidePlugin Feb 25, 2019
@zamotany
Copy link
Contributor

Hey @Dozalex, thanks for reaching us.
The use case of yours is not actually a bug, it's a feature. When linaria is running babel to extract CSS, it checks if there's any import for styled or css. In that case there isn't - the JS that linaria has, doesn't have any import for styled/css. We can add option to disable a check, but then if some dependency is provided with ProvidePlugin and also used inside styled/css interpolation it will fail, since linaria doesn't know that this dependency is provided.

We will try to research if we can get provided dependencies from Webpack or any information about those, which we can use, but if we cannot there's not much we can do about it.

@zamotany zamotany added enhancement: proposal 💬 Improvement of current behaviour that needs to be discussed needs: investigation 🔎 Issue has to be investigated for reason or solution labels Feb 25, 2019
@jayu jayu added the cat: modules aliasing 🔗 Issue related to modules aliasing label Apr 1, 2020
@github-actions github-actions bot added bundler: webpack 📦 Issue is related to webpack bundler cat: typings 👮 Typescript types related issues labels Apr 16, 2020
@jayu jayu added skip autolabeling Use it to disable auto laberer bot for an issue/pr and removed cat: typings 👮 Typescript types related issues labels Apr 16, 2020
@Anber
Copy link
Collaborator

Anber commented Sep 3, 2021

Compatibility with webpack resolve plugins has been added in #830

@Anber Anber closed this as completed Sep 3, 2021
@ionut-botizan
Copy link

Can you please re-open the issue? This still doesn't work.

The resolver options are not the same thing as the ProvidePlugin and they achieve different things:

  • The resolver options tell Webpack how to resolve a package/path mentioned in an import
  • The ProviderPlugin tells Webpack how to resolve a variable when there's no import at all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bundler: webpack 📦 Issue is related to webpack bundler cat: modules aliasing 🔗 Issue related to modules aliasing enhancement: proposal 💬 Improvement of current behaviour that needs to be discussed needs: investigation 🔎 Issue has to be investigated for reason or solution skip autolabeling Use it to disable auto laberer bot for an issue/pr
Projects
None yet
Development

No branches or pull requests

5 participants