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 prefixing :export for css modules #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

michelfrf
Copy link

@michelfrf michelfrf commented Feb 19, 2021

Avoid prefix for :export since :export block defines the symbols that are going to be exported to the consumer. It can be thought of functionally equivalent to the module.export

Avoid prefix for :export since :export block defines the symbols that are going to be exported to the consumer. It can be thought of functionally equivalent to the module.export
@michelfrf
Copy link
Author

This was causing issues with export since it was prefixing :export which is a ccs modules functionality similar to modules.export, please refer to the following https://github.com/css-modules/icss#export thanks and apologies if I came back to you later.

@michelfrf michelfrf changed the title Update index.js Avoid prefixing :export for css modules Feb 19, 2021
Copy link
Owner

@MadLittleMods MadLittleMods left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add tests

// that are going to be exported to the consumer
if (selector.indexOf(":export") !== -1) {
return selector;
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine to me. But let's add a test for this case so we don't regress on this in the future.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, test added

@MadLittleMods
Copy link
Owner

Thanks for the contribution @michelfrf. Looking good so far 🌵

@michelfrf
Copy link
Author

The test was added let me know if you are happy with the changes.

Comment on lines +24 to +25
// Avoid prefix for :exports since :export block defines the symbols
// that are going to be exported to the consumer
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Avoid prefix for :exports since :export block defines the symbols
// that are going to be exported to the consumer
// Avoid prefix for `:export` blocks because they define the symbols
// that are going to be exported to the consumer,
// https://github.com/css-modules/icss#export

Comment on lines +1 to +8
[id="foo"] {
background: #f00;
}

[id^="bar"] {
background: #0f0;
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can assert the same functionality with just the .foo and :export rules or maybe just :export by itself

Suggested change
[id="foo"] {
background: #f00;
}
[id^="bar"] {
background: #0f0;
}

@@ -119,4 +119,8 @@ describe('postcss-increase-specificity', function() {
it('should not change the descendant rules of @keyframes', function() {
return testPlugin('./test/fixtures/keyframes.css', './test/fixtures/keyframes.expected.css');
});

it('should ignore :export option used in scss files', function() {
return testPlugin('./test/fixtures/scss/export-option.scss', './test/fixtures/scss/export-option.expected.scss');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to use the scss extension here. CSS modules seem like they also applies to .css

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants