Skip to content

Commit 44cbeb3

Browse files
authored
Merge branch 'main' of https://github.com/webpack/webpack.js.org into blog-5-106
2 parents 6f66841 + 87d1880 commit 44cbeb3

File tree

72 files changed

+2822
-3026
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2822
-3026
lines changed

.github/workflows/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020

2121
- name: Dependabot metadata
2222
id: dependabot-metadata
23-
uses: dependabot/fetch-metadata@21025c705c08248db411dc16f3619e6b5f9ea21a # v2.5.0
23+
uses: dependabot/fetch-metadata@ffa630c65fa7e0ecfa0625b5ceda64399aea1b36 # v3.0.0
2424
with:
2525
github-token: "${{ steps.app-token.outputs.token }}"
2626

.github/workflows/testing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ jobs:
9696
uses: ./.github/actions/webpack-persistent-cache
9797

9898
- name: Cypress run
99-
uses: cypress-io/github-action@82482149c343a5dee155d22104111b9319f9dd45 # v7.1.6
99+
uses: cypress-io/github-action@783cb3f07983868532cabaedaa1e6c00ff4786a8 # v7.1.9
100100
with:
101101
browser: chrome
102102
config-file: cypress.config.js

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ The content is available under the [Creative Commons BY 4.0][license-url] licens
4949

5050
## Special Thanks
5151

52-
If you want reach from us at webpack, contact us and we can arrange something in return for your donations!
52+
If you want to reach us at webpack, contact us and we can arrange something in return for your donations!
5353

5454
_Vercel_ has given us a Pro account.
5555

cypress/e2e/click-menu-scroll-top.cy.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ describe("Click menu", () => {
77
// note that there's no hash in url
88
cy.get('[data-testid="contributors"]').scrollIntoView();
99

10-
const selector = '.sidebar-item__title[href="/concepts/modules/"]';
10+
const selector =
11+
'[data-testid="sidebar-item-title"][href="/concepts/modules/"]';
1112

1213
cy.get(selector).click();
1314
cy.window().then((win) => {

cypress/e2e/pr_4435.cy.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ describe("Open page in new tab", { scrollBehavior: false }, () => {
1010
},
1111
});
1212
// wait for page content to load before asserting scroll
13-
cy.get('.sidebar-item__title[href="/concepts/plugins/"]').should("exist");
13+
cy.get(
14+
'[data-testid="sidebar-item-title"][href="/concepts/plugins/"]',
15+
).should("exist");
1416
// there's one call in Page.jsx when componentDidMount
1517
cy.window().should((win) => {
1618
expect(win.scrollTo).to.be.calledOnce;
1719
});
1820

19-
const selector = '.sidebar-item__title[href="/concepts/plugins/"]';
21+
const selector =
22+
'[data-testid="sidebar-item-title"][href="/concepts/plugins/"]';
2023

2124
// we click the menu
2225
cy.get(selector).click();

jest.config.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ export default {
33
testEnvironment: "node",
44
setupFiles: ["./src/setupTests.js"],
55
transform: {
6-
"^.+\\.jsx?$": "babel-jest",
6+
"^.+\\.(m|c)?jsx?$": "babel-jest",
77
},
88
moduleNameMapper: {
99
"\\.(scss|css)$": "<rootDir>/src/components/__mocks__/styleMock.js",
1010
"\\.svg$": "<rootDir>/src/components/__mocks__/svgMock.js",
11+
"\\.(png|jpg|jpeg|ico)$": "<rootDir>/src/components/__mocks__/fileMock.js",
1112
},
1213
moduleFileExtensions: [
1314
"js",

package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
"main": "n/a",
2323
"scripts": {
2424
"clean-dist": "rimraf ./dist",
25-
"clean-printable": "rimraf src/content/**/printable.mdx",
25+
"clean-printable": "rimraf \"src/content/**/printable.mdx\"",
2626
"preclean": "run-s clean-dist clean-printable",
27-
"clean": "rimraf src/content/**/_*.mdx src/**/_*.json repositories/*.json",
27+
"clean": "rimraf \"src/content/**/_*.mdx\" \"src/**/_*.json\" \"repositories/*.json\"",
2828
"start": "npm run clean-dist && webpack serve --config webpack.dev.mjs --env dev --progress --config-node-env development",
2929
"content": "node src/scripts/build-content-tree.mjs ./src/content ./src/_content.json",
3030
"bundle-analyze": "run-s clean fetch content && webpack --config webpack.prod.mjs --config-node-env production && run-s printable content && webpack --config webpack.ssg.mjs --config-node-env production --env ssg --profile --json > stats.json && webpack-bundle-analyzer stats.json",
@@ -64,7 +64,7 @@
6464
"*.{md,mdx}": [
6565
"npm run lint:markdown"
6666
],
67-
"*.{js,mjs,jsx,css,scss,md,mdx,json}": [
67+
"*.{js,mjs,jsx,css,md,mdx,json}": [
6868
"prettier --write"
6969
]
7070
},
@@ -75,6 +75,7 @@
7575
"dependencies": {
7676
"@docsearch/react": "^4.6.0",
7777
"@react-spring/web": "^10.0.3",
78+
"clsx": "^2.1.1",
7879
"path-browserify": "^1.0.1",
7980
"prop-types": "^15.8.1",
8081
"react": "^19.2.4",
@@ -84,6 +85,7 @@
8485
"react-router-dom": "^7.13.1",
8586
"react-tiny-popover": "^8.1.6",
8687
"react-use": "^17.6.0",
88+
"tailwind-merge": "^3.5.0",
8789
"webpack-pwa-manifest": "^4.3.0",
8890
"workbox-window": "^7.4.0"
8991
},
@@ -131,7 +133,6 @@
131133
"mdast-util-to-string": "^4.0.0",
132134
"mini-css-extract-plugin": "^2.10.1",
133135
"mkdirp": "^3.0.1",
134-
"modularscale-sass": "^3.0.3",
135136
"npm-run-all": "^4.1.1",
136137
"postcss": "^8.5.8",
137138
"postcss-loader": "^8.2.0",
@@ -148,8 +149,6 @@
148149
"remark-gfm": "^4.0.1",
149150
"remark-html": "^16.0.1",
150151
"rimraf": "^6.1.2",
151-
"sass": "^1.97.3",
152-
"sass-loader": "^16.0.6",
153152
"sirv-cli": "^3.0.1",
154153
"sitemap-static": "^0.4.2",
155154
"static-site-generator-webpack-plugin": "^3.4.1",

src/components/CodeBlockWithCopy/CodeBlockWithCopy.jsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import PropTypes from "prop-types";
22
import { useEffect, useRef, useState } from "react";
3-
import "./CodeBlockWithCopy.scss";
3+
import { cn } from "../../utilities/cn.mjs";
44

55
export default function CodeBlockWithCopy({ children }) {
66
const preRef = useRef(null);
@@ -115,10 +115,22 @@ export default function CodeBlockWithCopy({ children }) {
115115
);
116116

117117
return (
118-
<div className="code-block-wrapper">
118+
<div className="code-block-wrapper relative mb-6 group">
119119
<button
120120
onClick={handleCopy}
121-
className={`copy-button ${copyStatus}`}
121+
className={cn(
122+
"copy-button",
123+
"absolute top-2 right-2 z-10 px-[0.7rem] py-[0.4rem] rounded-[0.35rem] border-none cursor-pointer text-xs font-medium text-slate-200",
124+
"opacity-0 group-hover:opacity-100",
125+
"transition-[background-color,transform,opacity] duration-200",
126+
"active:scale-95",
127+
"focus-visible:outline-none focus-visible:opacity-100",
128+
copyStatus === "copied"
129+
? "bg-green-600 hover:bg-green-700"
130+
: copyStatus === "error"
131+
? "bg-red-500 hover:bg-red-700"
132+
: "bg-[#175d96] hover:bg-[#2f85d0]",
133+
)}
122134
aria-label="Copy code to clipboard"
123135
>
124136
{copyStatus === "copied"

src/components/CodeBlockWithCopy/CodeBlockWithCopy.scss

Lines changed: 0 additions & 66 deletions
This file was deleted.
Lines changed: 51 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import PropTypes from "prop-types";
2-
import { Component, isValidElement } from "react";
2+
import { isValidElement, useState } from "react";
33
import Popover from "react-tiny-popover";
44

55
const DEFAULT_CHILDREN_SIZE = 4;
@@ -20,8 +20,8 @@ const addLink = (child, i, url) =>
2020
const Card = ({ body }) => (
2121
// Applied .shadow > .markdown styles: max-height and overflow
2222
<div className="markdown max-h-[48vh] overflow-auto">
23-
{/* Combined .inline and .shadow pre.inline styles:
24-
display: block, margin: 0, padding: 0 with right-padding override
23+
{/* Combined .inline and .shadow pre.inline styles:
24+
display: block, margin: 0, padding: 0 with right-padding override
2525
*/}
2626
<pre className="block m-0 p-0 pr-[15px]">
2727
<code>{body}</code>
@@ -33,71 +33,53 @@ Card.propTypes = {
3333
body: PropTypes.node,
3434
};
3535

36-
export class Details extends Component {
37-
static propTypes = {
38-
url: PropTypes.string,
39-
myChilds: PropTypes.arrayOf(PropTypes.node),
40-
};
41-
42-
constructor(props) {
43-
super(props);
44-
this.state = {
45-
open: false,
46-
};
47-
}
48-
49-
clickOutsideHandler = () => {
50-
this.setState({ open: false });
51-
};
52-
53-
toggleVisibility = () => {
54-
this.setState({ open: !this.state.open });
55-
};
56-
57-
render() {
58-
const { myChilds, url } = this.props;
59-
60-
// Find the index of </default>
61-
const closeDefaultTagIndex = myChilds.findIndex((child) => {
62-
if (isValidElement(child)) {
63-
return (
64-
child.props.className.includes("tag") &&
65-
child.props.children.length === DEFAULT_CHILDREN_SIZE
66-
);
67-
}
68-
69-
return false;
70-
});
71-
72-
const content = [...myChilds];
73-
74-
// Summary is the part of the snippet that would be shown in the code snippet,
75-
// to get it we need to cut the <default></default> enclosing tags
76-
const summary = content
77-
.splice(2, closeDefaultTagIndex - 3)
78-
.map(removeSpaces)
79-
.map((child, i) => addLink(child, i, url));
80-
81-
content.splice(0, DEFAULT_CHILDREN_SIZE); // Remove <default></default> information
82-
83-
const { open } = this.state;
84-
return (
85-
<Popover
86-
isOpen={open}
87-
position={["right", "top"]}
88-
padding={0}
89-
onClickOutside={this.clickOutsideHandler}
90-
// Replaced .shadow with Tailwind equivalents, including the custom rgba box-shadow
91-
containerClassName="overflow-visible rounded shadow-[-1px_1px_10px_0_rgba(255,255,255,0.44)]"
92-
content={<Card body={content} />}
36+
export function Details({ url, myChilds }) {
37+
const [open, setOpen] = useState(false);
38+
39+
// Find the index of </default>
40+
const closeDefaultTagIndex = myChilds.findIndex((child) => {
41+
if (isValidElement(child)) {
42+
return (
43+
child.props.className.includes("tag") &&
44+
child.props.children.length === DEFAULT_CHILDREN_SIZE
45+
);
46+
}
47+
48+
return false;
49+
});
50+
51+
const content = [...myChilds];
52+
53+
// Summary is the part of the snippet that would be shown in the code snippet,
54+
// to get it we need to cut the <default></default> enclosing tags
55+
const summary = content
56+
.splice(2, closeDefaultTagIndex - 3)
57+
.map(removeSpaces)
58+
.map((child, i) => addLink(child, i, url));
59+
60+
content.splice(0, DEFAULT_CHILDREN_SIZE); // Remove <default></default> information
61+
62+
return (
63+
<Popover
64+
isOpen={open}
65+
position={["right", "top"]}
66+
padding={0}
67+
onClickOutside={() => setOpen(false)}
68+
// Replaced .shadow with Tailwind equivalents, including the custom rgba box-shadow
69+
containerClassName="overflow-visible rounded shadow-[-1px_1px_10px_0_rgba(255,255,255,0.44)]"
70+
content={<Card body={content} />}
71+
>
72+
<span
73+
className="code-details-summary-span"
74+
onClick={() => setOpen((prev) => !prev)}
9375
>
94-
<span
95-
className="code-details-summary-span"
96-
onClick={this.toggleVisibility}
97-
>
98-
{summary}
99-
</span>
100-
</Popover>
101-
);
102-
}
76+
{summary}
77+
</span>
78+
</Popover>
79+
);
10380
}
81+
82+
Details.propTypes = {
83+
url: PropTypes.string,
84+
myChilds: PropTypes.arrayOf(PropTypes.node),
85+
};

0 commit comments

Comments
 (0)