Skip to content

Commit 17a36b7

Browse files
authored
test: use local vendor instead of unpkg for react umd outputs (#888)
1 parent 15abef2 commit 17a36b7

File tree

8 files changed

+43
-26
lines changed

8 files changed

+43
-26
lines changed

.github/renovate.json5

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@
6868
'@types/node',
6969
'node',
7070
// umd tests need to lock this version
71-
'react-aliased',
71+
'react-18',
72+
'react-dom-18',
7273
],
7374
postUpdateOptions: ['pnpmDedupe'],
7475
}

biome.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@
2121
"ignoreUnknown": true
2222
},
2323
"formatter": {
24-
"ignore": [
25-
"**/.rslib/*",
26-
"./tests/e2e/react-component/public/umd/index.js"
27-
],
24+
"ignore": ["**/.rslib/*", "./tests/e2e/react-component/public/umd/*"],
2825
"indentStyle": "space"
2926
},
3027
"javascript": {
@@ -47,7 +44,7 @@
4744
"enabled": true,
4845
"ignore": [
4946
"./tests/integration/**/*/src/*",
50-
"./tests/e2e/react-component/public/umd/index.js"
47+
"./tests/e2e/react-component/public/umd/*"
5148
],
5249
"rules": {
5350
"recommended": true,

pnpm-lock.yaml

Lines changed: 15 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/e2e/react-component/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
"version": "1.0.0",
44
"private": true,
55
"scripts": {
6+
"build:umd": "cd ../../../examples/react-component-umd && pnpm run build",
67
"dev:bundle": "../../node_modules/.bin/rsbuild dev --environment=bundle",
78
"dev:bundle-false": "../../node_modules/.bin/rsbuild dev --environment=bundleFalse",
8-
"dev:umd": "pnpm umd:build && pnpm umd:copy && ../../node_modules/.bin/rsbuild dev --environment=umd",
9-
"umd:build": "cd ../../../examples/react-component-umd && pnpm run build",
10-
"umd:copy": "rm -rf ./public && mkdir -p ./public/umd && cp ../../../examples/react-component-umd/dist/umd/index.js ./public/umd/index.js"
9+
"dev:umd": "pnpm build:umd && ../../node_modules/.bin/rsbuild dev --environment=umd"
1110
},
1211
"dependencies": {
1312
"@examples/react-component-bundle": "workspace:*",
1413
"@examples/react-component-bundle-false": "workspace:*",
15-
"@examples/react-component-umd": "workspace:*"
14+
"@examples/react-component-umd": "workspace:*",
15+
"react-18": "npm:[email protected]",
16+
"react-dom-18": "npm:[email protected]"
1617
}
1718
}

tests/e2e/react-component/rsbuild.config.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ export default defineConfig({
2323
{
2424
tag: 'script',
2525
attrs: {
26-
src: 'https://unpkg.com/react@18/umd/react.development.js',
26+
src: '/umd/react.development.js',
2727
},
2828
head: true,
2929
append: true,
3030
},
3131
{
3232
tag: 'script',
3333
attrs: {
34-
src: 'https://unpkg.com/react-dom@18/umd/react-dom.development.js',
34+
src: '/umd/react-dom.development.js',
3535
},
3636
head: true,
3737
append: true,
@@ -57,6 +57,20 @@ export default defineConfig({
5757
'react-dom': 'window ReactDom',
5858
'react-dom/client': 'window ReactDom',
5959
},
60+
copy: [
61+
{
62+
from: '../../../examples/react-component-umd/dist/umd/index.js',
63+
to: 'umd/index.js',
64+
},
65+
{
66+
from: 'node_modules/react-18/umd/react.development.js',
67+
to: 'umd/react.development.js',
68+
},
69+
{
70+
from: 'node_modules/react-dom-18/umd/react-dom.development.js',
71+
to: 'umd/react-dom.development.js',
72+
},
73+
],
6074
},
6175
},
6276
},

tests/integration/umd-globals/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ test('correct read globals from CommonJS', async () => {
88
});
99

1010
const { fn } = require(entryFiles.umd);
11-
expect(await fn('ok')).toBe('DEBUG:18.3.0/ok');
11+
expect(await fn('ok')).toBe('DEBUG:18.3.1/ok');
1212
});

tests/integration/umd-globals/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"devDependencies": {
66
"react": "^19.1.0",
7-
"react-aliased": "npm:[email protected].0"
7+
"react-18": "npm:[email protected].1"
88
},
99
"peerDependencies": {
1010
"react": "^18.3.1"

tests/integration/umd-globals/rslib.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default defineConfig({
55
lib: [generateBundleUmdConfig()],
66
output: {
77
externals: {
8-
react: 'react-aliased',
8+
react: 'react-18',
99
},
1010
},
1111
source: {

0 commit comments

Comments
 (0)