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

plugin-sass: fixes issue with regex not matching imports #1932

Merged
merged 3 commits into from
Dec 11, 2020

Conversation

m9dfukc
Copy link
Contributor

@m9dfukc m9dfukc commented Dec 11, 2020

Changes

If the folder structure of the project contains "_" the current regex fails to find an entry in the importedByMap.

Because the sass specification allows partials to be imported without the starting "_", the importedByMap could contain entries where the filename doesn't match. This fix ensures that these files will be found, even if the folder structure contains underscores.

old behaviour:
"/a/b/c/_foo_/_index.scss".replace(/([\\\/])_/, '$1') === "/a/b/c/foo_/_index.scss"

new behaviour:
"/a/b/c/_foo_/_index.scss".replace(/(.*[\\\/])_/, '$1') === "/a/b/c/_foo_/index.scss"

Testing

This was tested manually by trying out different folder- and filenames.

Docs

Bug fix only pull request.

@vercel
Copy link

vercel bot commented Dec 11, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/pikapkg/snowpack/lgo2b7ti9
✅ Preview: https://snowpack-git-main.pikapkg.vercel.app

// check no ext, no underscore: "index" (/a/b/c/foo/index)
this._markImportersAsChanged(filePathNoExt.replace(/([\\\/])_/, '$1'));
this._markImportersAsChanged(filePathNoExt.replace(/(.*[\\\/])_/, '$1'));
Copy link
Owner

Choose a reason for hiding this comment

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

bah, just realized that this will match this:

 /foo/_Playground/snowpack-test/src/base.sass

Going to replace with something closer to your original and then merge: \/_(?!.*\/)

✅  /Users/fks/Downloads/_Playground_/snowpack-test/src/_base.sass
✅  /Users/fks/Downloads/_Playground/snowpack-test/src/_base.sass
✅  /Users/fks/Downloads/Playground/snowpack-test/src/_base.sass
🆇  /Users/fks/Downloads/_Playground/snowpack-test/src/base.sass

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 this pull request may close these issues.

None yet

2 participants