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

Expose importer in resolve method #131

Open
intrnl opened this issue Mar 5, 2022 · 2 comments
Open

Expose importer in resolve method #131

intrnl opened this issue Mar 5, 2022 · 2 comments

Comments

@intrnl
Copy link

intrnl commented Mar 5, 2022

The resolve method should be given the filename that triggered the resolve, this is necessary especially for nested imports where the file could be located somewhere else.

postcssModules({
  resolve (id, from) {
    return path.resolve(from, id);
  },
});
@intrnl
Copy link
Author

intrnl commented Mar 5, 2022

The resolver method should also be passed when resolving nested dependencies, currently the following case is impossible to do:

Let's say that the project root is also aliased to ~

/* styles/controls.css */
.control {
  border-radius: 4px;
  /* ... */
}

/* components/Button/Button.module.css */
.button {
  composes: control from '~/styles/controls.css';
  /* ... */
}

/* components/Menu/MenuItem.module.css */
.button {
  composes: button from '~/components/Button/Button.module.css';
  /* ... */
}

MenuItem.module.css succeeds in resolving Button.module.css, but because the resolve method isn't passed when parsing the source, it fails when trying to resolve its dependencies.

@KingSora
Copy link
Contributor

@madyankin @intrnl created a PR for this: #142 which implements this behavior in a non-breaking way.

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

Successfully merging a pull request may close this issue.

2 participants