-
-
Notifications
You must be signed in to change notification settings - Fork 24
Fix relative imports. #30
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -122,9 +122,6 @@ describe('styled-jsx-plugin-sass', () => { | |
|
|
||
| assert.equal( | ||
| plugin(file.toString(), { | ||
| sassOptions: { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should keep this I guess, tests should still pass with the old setup
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, that test explicitly uses a relative import (i.e. starts with
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In other words. The test as is, is verifying an undesirable behavior. You shouldn't have to add to |
||
| includePaths: [path.join(__dirname, 'fixtures')] | ||
| }, | ||
| babel: { filename } | ||
| }).trim(), | ||
| cleanup(` | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure about this, I thought with v1 we agreed that this should work when setting the
includePathviasassOptions. cc @atombenderUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Relative paths do not work properly in
v1, they can easily resolve to the wrong file if you have two files with the same name in different directoriesIn this scenario, with your current implementation, it is going to search in order of the includePaths. This means both imports will resolve to the file inside
foo-component. That's definitely not whatbar-componentwanted.I am happy to add a regression tests that proves all that ⬆️ if it increases your comfort level, but we're really just testing
node-sassimplementation details at that point. The test as I've got it checks that explicit relative imports will work without modifyingincludePaths.The problem you resolved in
v1was that you were clobbering the users intendedincludePathssettings in an effort to get relative paths to work.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha thank you for the exhaustive explanation. How do you solve this issue in a standalone node-sass setup?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with the current implementation is that
node-sassdoesn't know the file location, it is only being provided the files contents. In a standalonenode-sasssetup, that would never happen (it's reading in the file contents itself, and it already knows the file path from the CLI or config).This is simply giving node-sass the extra bit of information it needs to process the
@importcommand properly.