-
Notifications
You must be signed in to change notification settings - Fork 8
fix: pin cascade-layer order and classify workspace symlinks #247
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| @layer paragon, shell, app, site, brand; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| @layer paragon, shell, app, site, brand; | ||
|
|
||
| .flex-basis-0 { | ||
| flex-basis: 0 !important; | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import { | ||
| APP_RESOURCE, | ||
| BRAND_PACKAGE, | ||
| } from './getStylesheetRule'; | ||
|
|
||
| describe('stylesheet classification', () => { | ||
| describe('BRAND_PACKAGE', () => { | ||
| const re = BRAND_PACKAGE.name as RegExp; | ||
|
|
||
| it('matches @openedx/brand-*', () => { | ||
| expect(re.test('@openedx/brand-openedx')).toBe(true); | ||
| }); | ||
|
|
||
| it('matches @edx/brand-*', () => { | ||
| expect(re.test('@edx/brand-foo')).toBe(true); | ||
| }); | ||
|
|
||
| it('matches bare @openedx/brand', () => { | ||
| expect(re.test('@openedx/brand')).toBe(true); | ||
| }); | ||
|
|
||
| it('does not match unrelated scoped packages', () => { | ||
| expect(re.test('@openedx/paragon')).toBe(false); | ||
| expect(re.test('@openedx/branding')).toBe(false); | ||
| }); | ||
| }); | ||
|
|
||
| describe('APP_RESOURCE', () => { | ||
| it('matches a node_modules path', () => { | ||
| expect(APP_RESOURCE.test('/site/node_modules/some-pkg/index.js')).toBe(true); | ||
| }); | ||
|
|
||
| it('matches an npm-workspace packages path', () => { | ||
| expect(APP_RESOURCE.test('/site/packages/some-pkg/index.js')).toBe(true); | ||
| }); | ||
|
|
||
| it('does not match a site source path', () => { | ||
| expect(APP_RESOURCE.test('/site/src/component.scss')).toBe(false); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,19 @@ | ||
| import HtmlWebpackPlugin from 'html-webpack-plugin'; | ||
| import path from 'path'; | ||
|
|
||
| // Generates an HTML file in the output directory. | ||
| /* | ||
| * Generates an HTML file in the output directory. | ||
| * | ||
| * `cssLayerOrder` is listed first so its <link> is injected before any other | ||
| * stylesheet. That file contains the `@layer paragon, shell, app, site, brand;` | ||
| * statement, which locks in cascade-layer priority before any layer name is | ||
| * mentioned by the rest of the CSS the browser parses. | ||
| */ | ||
| export default function getHtmlWebpackPlugin() { | ||
| return new HtmlWebpackPlugin({ | ||
| inject: true, // Appends script tags linking to the webpack bundles at the end of the body | ||
| inject: true, | ||
| template: path.resolve(process.cwd(), 'public/index.html'), | ||
| chunks: ['app'], | ||
| chunks: ['cssLayerOrder', 'app'], | ||
| chunksSortMode: 'manual', | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Not blocking, and out-of-scope for this PR, but the more I think about it the more I feel using a regex to match brand packages is a bit odd.
With the npm aliasing method used by MFEs, there were no restrictions on what site operators could name their brand packages.
I'm not sure how many site operators are using brand packages that don't match the regex, so it's possible this is a non-issue, but I figured it's worth flagging to at least think about.
Uh 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.
The alternative is to do what Atlas does, which is to require metadata in the package.json. I don't dislike that idea, not only for brand but for apps: that would give us a way to have an app layer literally just for apps, not as a catch-all. (And to put the node_modules stuff in its own layer before anything else).
But we can do this in a subsequent series of PRs.