-
Notifications
You must be signed in to change notification settings - Fork 331
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
Path to sass-mq is dependent on specific node_modules location #636
Comments
Thanks for raising! Do you have an example of the build where this fails for us to reproduce? It may help us fix this quicker. 😄 |
@marksy was having this issue, I think on this branch, though perhaps he can confirm https://github.com/penx/govuk-react/tree/feature/sassExtract |
failing that I could try create a simple example if that would help? |
@NickColley @igloosi I have created a failing example with instructions here https://github.com/penx/govuk-monorepo-example |
Note that Webpack sass-loader provides a mechanism to load dependencies from node_modules: @import "~sass-mq/mq"; However this doesn't seem to be a standard Sass convention, but personally I think it is preferred to importing from an assumed relative path to node_modules. |
@penx thanks so much for the failing example! 🙌 |
the proposed change in #637 should fix that |
@igloosi that may work, but would require the parent project to know where the package was hoisted to (which could potentially vary) rather than defer this resolution to node. Any reason for this instead of Eyeglass? |
failing that we could have the govuk-frontend Sass => JS variables conversion go in to its own project that wasn't a monorepo and do the conversion as part of its build, then have govuk-react depend on this interim package |
@penx (while we try and find other solutions) is it possible to avoid hoisting node_modules? Or avoiding yarn? |
@NickColley using a monorepo is pretty core to the current architecture of govuk-react, and I am pretty certain other monorepo approaches (lerna + npm) would have the same issue, but if we move the conversion to another repo then this may work, unless I'm missing something @marksy? |
I think I'm maybe misunderstanding but is hoisting node_modules required for a monorepo approach? Looks to have more context on hoisting: https://yarnpkg.com/blog/2018/02/15/nohoist/ |
Good point, I thought it was, which led me to find this: https://yarnpkg.com/blog/2018/02/15/nohoist/ So we could probably use that. Related, I thought lerna hoisted by default but apparently it doesn't https://github.com/lerna/lerna/blob/master/doc/hoist.md Also in the above link
I think it would still be good to have hoisting support in the medium term though could see why this may be low priority 😀 |
Interestingly I seem to have the same issue when not in a monorepo! https://github.com/penx/govuk-frontend-js
Error: Can not determine imported file for url './node_modules/sass-mq/mq.scss' imported in govuk-frontend-js/node_modules/@govuk-frontend/globals/helpers/_media-queries.scss |
There are a number of scenarios where assuming the sass-mq dependency lives in the same project breaks that have been outlined in #636. As Sass does not allow dynamic imports we cannot provide a variable to override path to sass-mq stylesheet. To fix this and avoid external dependencies of Frontend, we've moved the functionality into the project.
@penx this will be fixed in the next release of Frontend |
This line is causing us an issue:
govuk-frontend/dist/components/globals/helpers/_media-queries.scss
Line 14 in ad2022e
This assumes that
sass-mq
is installed in anode_modules
folder relative to the root folder used by the Sass build system.This isn't always the case, e.g.
govuk-frontend
actually lives in./node_modules/govuk-frontend/node_modules/sass-mq
govuk-frontend
I suspect this can be fixed by swapping it with
@import "sass-mq/mq"
, which will leave node to deal with the module resolution.The text was updated successfully, but these errors were encountered: