Skip to content

Commit

Permalink
chore: update @svgr/webpack to version 6 (#5958)
Browse files Browse the repository at this point in the history
* chore: update @svgr/webpack to version 6

* svgr changelog https://github.com/gregberge/svgr/releases
* SVGO 2 changelog https://github.com/svg/svgo/releases/tag/v2.0.0
* depend on maintained svgo version
* although svgr 6 is in alpha, it fixes a few issues
  with webpack 5 (gregberge/svgr@1a8cc98)
  and React (gregberge/svgr@3700aba)
* see also #5703

* Fix config

* fix e2e test

* Fix again

* Update to stable

Co-authored-by: Josh-Cena <sidachen2003@gmail.com>
  • Loading branch information
ludofischer and Josh-Cena committed Nov 29, 2021
1 parent 0e6ec24 commit 5678911
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 206 deletions.
31 changes: 17 additions & 14 deletions .github/workflows/tests-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,22 @@ jobs:
- name: Installation
run: yarn
- name: Generate test-website project against main branch
run: |
KEEP_CONTAINER=true yarn test:build:website -s
mv test-website ../test-website
run: yarn test:build:website -s
env:
KEEP_CONTAINER: true
- name: Install test-website project with Yarn v1
run: cd ../test-website && yarn install
run: yarn install
working-directory: ../test-website
env:
npm_config_registry: http://localhost:4873
- name: Start test-website project
run: cd ../test-website && yarn start --no-open
run: yarn start --no-open
working-directory: ../test-website
env:
E2E_TEST: true
- name: Build test-website project
run: cd ../test-website && yarn build
run: yarn build
working-directory: ../test-website
env:
CI: true

Expand All @@ -63,15 +66,12 @@ jobs:
cache: yarn
- name: Installation
run: yarn

- name: Generate test-website project against main branch
run: |
KEEP_CONTAINER=true yarn test:build:website -s
mv test-website ../test-website
run: yarn test:build:website -s
env:
KEEP_CONTAINER: true
- name: Install test-website project with Yarn Berry and nodeLinker = ${{ matrix.nodeLinker }}
run: |
cd ../test-website
# we have to switch to berry first before setting the version we want
yarn set version berry
# temporary using canary for #5342
Expand All @@ -84,13 +84,16 @@ jobs:
yarn config set enableGlobalCache true
yarn install
working-directory: ../test-website
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: false # Yarn berry should create the lockfile, despite CI env
- name: Start test-website project
run: cd ../test-website && yarn start --no-open
run: yarn start --no-open
working-directory: ../test-website
env:
E2E_TEST: true
- name: Build test-website project
run: cd ../test-website && yarn build
run: yarn build
working-directory: ../test-website
env:
CI: true
4 changes: 4 additions & 0 deletions admin/scripts/test-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ npx --no-install lerna publish --exact --yes --no-verify-access --no-git-reset -
# Revert version changes
git diff --name-only -- '*.json' | sed 's, ,\\&,g' | xargs git checkout --


# The website is generated outside the repo to minimize chances of yarn resolving the wrong version
cd ..

# Build skeleton website with new version
npm_config_registry="$CUSTOM_REGISTRY_URL" npm init docusaurus@"$NEW_VERSION" test-website classic $EXTRA_OPTS

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@docusaurus/core": "2.0.0-beta.9",
"@docusaurus/preset-classic": "2.0.0-beta.9",
"@mdx-js/react": "^1.6.21",
"@svgr/webpack": "^5.5.0",
"@svgr/webpack": "^6.0.0",
"clsx": "^1.1.1",
"file-loader": "^6.2.0",
"prism-react-renderer": "^1.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-docusaurus/templates/classic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@docusaurus/core": "2.0.0-beta.9",
"@docusaurus/preset-classic": "2.0.0-beta.9",
"@mdx-js/react": "^1.6.21",
"@svgr/webpack": "^5.5.0",
"@svgr/webpack": "^6.0.0",
"clsx": "^1.1.1",
"file-loader": "^6.2.0",
"prism-react-renderer": "^1.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-docusaurus/templates/facebook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@docusaurus/core": "2.0.0-beta.9",
"@docusaurus/preset-classic": "2.0.0-beta.9",
"@mdx-js/react": "^1.6.21",
"@svgr/webpack": "^5.5.0",
"@svgr/webpack": "^6.0.0",
"clsx": "^1.1.1",
"file-loader": "^6.2.0",
"react": "^17.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"@docusaurus/utils-common": "2.0.0-beta.9",
"@docusaurus/utils-validation": "2.0.0-beta.9",
"@slorber/static-site-generator-webpack-plugin": "^4.0.0",
"@svgr/webpack": "^5.5.0",
"@svgr/webpack": "^6.0.0",
"autoprefixer": "^10.3.5",
"babel-loader": "^8.2.2",
"babel-plugin-dynamic-import-node": "2.3.0",
Expand Down
11 changes: 10 additions & 1 deletion packages/docusaurus/src/webpack/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,16 @@ describe('getFileLoaderUtils()', () => {
loader: '@svgr/webpack',
options: expect.objectContaining({
svgoConfig: {
plugins: [{removeViewBox: false}],
plugins: [
{
name: 'preset-default',
params: {
overrides: {
removeViewBox: false,
},
},
},
],
},
}),
}),
Expand Down
11 changes: 10 additions & 1 deletion packages/docusaurus/src/webpack/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,16 @@ export function getFileLoaderUtils(): FileLoaderUtils {
prettier: false,
svgo: true,
svgoConfig: {
plugins: [{removeViewBox: false}],
plugins: [
{
name: 'preset-default',
params: {
overrides: {
removeViewBox: false,
},
},
},
],
},
titleProp: true,
ref: ![path],
Expand Down

0 comments on commit 5678911

Please sign in to comment.