From f5f5b6214a8e9dc08aea08bb411531c943ad0b53 Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Sun, 25 Aug 2024 09:50:32 +0800 Subject: [PATCH] test: add e2e cases --- package.json | 7 +- pnpm-lock.yaml | 183 +++++++++++++--------- src/index.ts | 3 + test/basic/index.test.ts | 44 ------ test/basic/src/index.js | 1 - test/sfc-basic/index.test.ts | 28 ++++ test/sfc-basic/rsbuild.config.ts | 10 ++ test/sfc-basic/src/A.vue | 29 ++++ test/sfc-basic/src/B.vue | 14 ++ test/sfc-basic/src/index.js | 7 + test/sfc-css-modules/index.test.ts | 30 ++++ test/sfc-css-modules/rsbuild.config.ts | 10 ++ test/sfc-css-modules/src/App.vue | 29 ++++ test/sfc-css-modules/src/index.js | 7 + test/sfc-css-modules/src/style.module.css | 3 + test/sfc-lang-pcss/index.test.ts | 23 +++ test/sfc-lang-pcss/rsbuild.config.ts | 10 ++ test/sfc-lang-pcss/src/App.vue | 9 ++ test/sfc-lang-pcss/src/index.js | 7 + test/sfc-lang-postcss/index.test.ts | 23 +++ test/sfc-lang-postcss/rsbuild.config.ts | 10 ++ test/sfc-lang-postcss/src/App.vue | 9 ++ test/sfc-lang-postcss/src/index.js | 7 + test/sfc-lang-ts/index.test.ts | 23 +++ test/sfc-lang-ts/rsbuild.config.ts | 10 ++ test/sfc-lang-ts/src/App.vue | 22 +++ test/sfc-lang-ts/src/index.js | 7 + test/sfc-style/index.test.ts | 28 ++++ test/sfc-style/rsbuild.config.ts | 11 ++ test/sfc-style/src/App.vue | 22 +++ test/sfc-style/src/a.less | 3 + test/sfc-style/src/index.js | 8 + test/split-chunk/index.test.ts | 49 ++++++ test/split-chunk/rsbuild.config.ts | 8 + test/split-chunk/src/index.js | 3 + 35 files changed, 572 insertions(+), 125 deletions(-) delete mode 100644 test/basic/index.test.ts delete mode 100644 test/basic/src/index.js create mode 100644 test/sfc-basic/index.test.ts create mode 100644 test/sfc-basic/rsbuild.config.ts create mode 100644 test/sfc-basic/src/A.vue create mode 100644 test/sfc-basic/src/B.vue create mode 100644 test/sfc-basic/src/index.js create mode 100644 test/sfc-css-modules/index.test.ts create mode 100644 test/sfc-css-modules/rsbuild.config.ts create mode 100644 test/sfc-css-modules/src/App.vue create mode 100644 test/sfc-css-modules/src/index.js create mode 100644 test/sfc-css-modules/src/style.module.css create mode 100644 test/sfc-lang-pcss/index.test.ts create mode 100644 test/sfc-lang-pcss/rsbuild.config.ts create mode 100644 test/sfc-lang-pcss/src/App.vue create mode 100644 test/sfc-lang-pcss/src/index.js create mode 100644 test/sfc-lang-postcss/index.test.ts create mode 100644 test/sfc-lang-postcss/rsbuild.config.ts create mode 100644 test/sfc-lang-postcss/src/App.vue create mode 100644 test/sfc-lang-postcss/src/index.js create mode 100644 test/sfc-lang-ts/index.test.ts create mode 100644 test/sfc-lang-ts/rsbuild.config.ts create mode 100644 test/sfc-lang-ts/src/App.vue create mode 100644 test/sfc-lang-ts/src/index.js create mode 100644 test/sfc-style/index.test.ts create mode 100644 test/sfc-style/rsbuild.config.ts create mode 100644 test/sfc-style/src/App.vue create mode 100644 test/sfc-style/src/a.less create mode 100644 test/sfc-style/src/index.js create mode 100644 test/split-chunk/index.test.ts create mode 100644 test/split-chunk/rsbuild.config.ts create mode 100644 test/split-chunk/src/index.js diff --git a/package.json b/package.json index 8dc8612..426d7eb 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,9 @@ "main": "./dist/index.js", "module": "./dist/index.mjs", "types": "./dist/index.d.ts", - "files": ["dist"], + "files": [ + "dist" + ], "scripts": { "build": "tsup", "dev": "tsup --watch", @@ -38,7 +40,8 @@ "devDependencies": { "@biomejs/biome": "^1.8.3", "@playwright/test": "^1.45.3", - "@rsbuild/core": "^1.0.1-beta.11", + "@rsbuild/core": "^1.0.1-beta.16", + "@rsbuild/plugin-less": "1.0.1-beta.16", "@types/node": "^20.14.13", "nano-staged": "^0.8.0", "playwright": "^1.45.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3a01833..9a8e90e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -22,8 +22,11 @@ importers: specifier: ^1.45.3 version: 1.45.3 '@rsbuild/core': - specifier: ^1.0.1-beta.11 - version: 1.0.1-beta.11 + specifier: ^1.0.1-beta.16 + version: 1.0.1-beta.16 + '@rsbuild/plugin-less': + specifier: 1.0.1-beta.16 + version: 1.0.1-beta.16(@rsbuild/core@1.0.1-beta.16) '@types/node': specifier: ^20.14.13 version: 20.14.13 @@ -287,17 +290,17 @@ packages: '@jridgewell/trace-mapping@0.3.25': resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==} - '@module-federation/runtime-tools@0.2.3': - resolution: {integrity: sha512-capN8CVTCEqNAjnl102girrkevczoQfnQYyiYC4WuyKsg7+LUqfirIe1Eiyv6VSE2UgvOTZDnqvervA6rBOlmg==} + '@module-federation/runtime-tools@0.5.1': + resolution: {integrity: sha512-nfBedkoZ3/SWyO0hnmaxuz0R0iGPSikHZOAZ0N/dVSQaIzlffUo35B5nlC2wgWIc0JdMZfkwkjZRrnuuDIJbzg==} - '@module-federation/runtime@0.2.3': - resolution: {integrity: sha512-N+ZxBUb1mkmfO9XT1BwgYQgShtUTlijHbukqQ4afFka5lRAT+ayC7RKfHJLz0HbuexKPCmPBDfdmCnErR5WyTQ==} + '@module-federation/runtime@0.5.1': + resolution: {integrity: sha512-xgiMUWwGLWDrvZc9JibuEbXIbhXg6z2oUkemogSvQ4LKvrl/n0kbqP1Blk669mXzyWbqtSp6PpvNdwaE1aN5xQ==} - '@module-federation/sdk@0.2.3': - resolution: {integrity: sha512-W9zrPchLocyCBc/B8CW21akcfJXLl++9xBe1L1EtgxZGfj/xwHt0GcBWE/y+QGvYTL2a1iZjwscbftbUhxgxXg==} + '@module-federation/sdk@0.5.1': + resolution: {integrity: sha512-exvchtjNURJJkpqjQ3/opdbfeT2wPKvrbnGnyRkrwW5o3FH1LaST1tkiNviT6OXTexGaVc2DahbdniQHVtQ7pA==} - '@module-federation/webpack-bundler-runtime@0.2.3': - resolution: {integrity: sha512-L/jt2uJ+8dwYiyn9GxryzDR6tr/Wk8rpgvelM2EBeLIhu7YxCHSmSjQYhw3BTux9zZIr47d1K9fGjBFsVRd/SQ==} + '@module-federation/webpack-bundler-runtime@0.5.1': + resolution: {integrity: sha512-mMhRFH0k2VjwHt3Jol9JkUsmI/4XlrAoBG3E0o7HoyoPYv1UFOWyqAflfANcUPgbYpvqmyLzDcO+3IT36LXnrA==} '@nodelib/fs.scandir@2.1.5': resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} @@ -400,61 +403,66 @@ packages: cpu: [x64] os: [win32] - '@rsbuild/core@1.0.1-beta.11': - resolution: {integrity: sha512-z0/cYT5R2IQmPxonmoVwlSpaN/NuyoJi+XhHLbLHP1kCsyBNKUdUelCUOOOZYJqG1w2tAhvY2rox8Chxyh96Gg==} + '@rsbuild/core@1.0.1-beta.16': + resolution: {integrity: sha512-/0s6E3bKqyxUby2X4H11xQppuXpPWqZzPWkynUX19o9T2K7FuPw5cyuE0iL3f2XlGucmgftSn06Am5HsQV+A+w==} engines: {node: '>=16.7.0'} hasBin: true - '@rspack/binding-darwin-arm64@1.0.0-beta.3': - resolution: {integrity: sha512-v+2TFNWttB0ZqEkYP2pf3qpm7O8bJiVcl9Ym90lL+uMfYNRzzrGd57tu7NBp/6nhE3T3emxiFvaeVDpqIqykZQ==} + '@rsbuild/plugin-less@1.0.1-beta.16': + resolution: {integrity: sha512-uZ0YwUTEX2c0o63hfF4Xz0SIaSlPfqRWyvKSB2c8/He8u/8nlBXcjCHbmiCA5lzp134y5SwfhO7nC6CdY7LdWA==} + peerDependencies: + '@rsbuild/core': ^1.0.1-beta.16 + + '@rspack/binding-darwin-arm64@1.0.0-rc.0': + resolution: {integrity: sha512-4S/+q8HN69ErWUjGDePExqiNuKIEGYKEoT+91+Wz55jQV4NY1mNGRojKVKjZkz7MvbPEZ1howtpDcHuUE2+QhQ==} cpu: [arm64] os: [darwin] - '@rspack/binding-darwin-x64@1.0.0-beta.3': - resolution: {integrity: sha512-OM4jqlt23j2W9gxAqwrjf86TLnJ6u6lNeli/haJmfjaj8maHYY7LkEo7imK3MqfGXCFExQbsY367O+epZQ2pcQ==} + '@rspack/binding-darwin-x64@1.0.0-rc.0': + resolution: {integrity: sha512-IN96SG6yRz4JwlzuNrhdApEg4J2UI9S8uD38vrJvH9TOO/Dv1puL82EpqTYBZYfbaddZsiZG9+5LNnsU9OEXJg==} cpu: [x64] os: [darwin] - '@rspack/binding-linux-arm64-gnu@1.0.0-beta.3': - resolution: {integrity: sha512-NV3i1mIBSEN5nmf83TvX0M3jb6CzAPdaydFytQ6p8WP6UWZnJIJ19HEqZiab+R4kYhs7I27wbWJuJGpADTEKvQ==} + '@rspack/binding-linux-arm64-gnu@1.0.0-rc.0': + resolution: {integrity: sha512-gqURooSNYGlwvgLE1xu8rz68E4Mfa2MONGTNMkre5aIYX2ZOd/MKGaB/R062Oj/78BIHmIGWcoz5GnBxBwToyw==} cpu: [arm64] os: [linux] - '@rspack/binding-linux-arm64-musl@1.0.0-beta.3': - resolution: {integrity: sha512-rusWEqc+niYk6LD9y+2lFtT4x/3T5PKUk2dYuRTRUGIl01BhOFoqnavLq40mQMgrXZCD4htUjSM5C1pjD0FkFw==} + '@rspack/binding-linux-arm64-musl@1.0.0-rc.0': + resolution: {integrity: sha512-302IJXw7F4YpHUEVJA2bkzlNfYp26jKXIddHpG4A3diw0/+5w1C4eDGrC9kuq642kFtu4nwP/8rjP0090/Orxw==} cpu: [arm64] os: [linux] - '@rspack/binding-linux-x64-gnu@1.0.0-beta.3': - resolution: {integrity: sha512-vVP3bgOictg5glmByVSML5sIxiJAMZ46h2kSWdIHv1eb/zg9Jw48mNiymtOXjNgkBenvYiERgAaOlBqAX+ySMw==} + '@rspack/binding-linux-x64-gnu@1.0.0-rc.0': + resolution: {integrity: sha512-VsHzd7iAwZA3j48PSj9beKva9wqde1BP2K3AF0aZe7amQoatG57YZtiOthZSWyDlwEm7VCuE6/4Jgf8vOQJX2g==} cpu: [x64] os: [linux] - '@rspack/binding-linux-x64-musl@1.0.0-beta.3': - resolution: {integrity: sha512-al7Rwikv0wQLNrWoyymUqZdWwRUjyyovUFzlSh8A1pR84UTPyeRdXmmO6+F8b5KBvK7QkFBnb3eeALMGvQw9Qw==} + '@rspack/binding-linux-x64-musl@1.0.0-rc.0': + resolution: {integrity: sha512-M6/SC33xWdlV2pmR3O3MrhfBZBpicMCl+GrJ0MXFb9ziC7auuuLfMmfqMakorphfL2yOOwSfcfZF8V2iiYoENw==} cpu: [x64] os: [linux] - '@rspack/binding-win32-arm64-msvc@1.0.0-beta.3': - resolution: {integrity: sha512-GtxVR+HgSRyD2ybQ+Pk0rXcv9t1ndU/FWrYV7A2jY47dndwa/BNXLclRdyWBfmA1cBZVM8MfLUAVmSKz8hg8Aw==} + '@rspack/binding-win32-arm64-msvc@1.0.0-rc.0': + resolution: {integrity: sha512-ob510ObXoIBAMjPE8iBwvhWQ8Hd4v7bJSgImUBhSGExYI+z8b/gl8tNg8y1fttLtNO8j05rj9QFsGcZmv89Zsg==} cpu: [arm64] os: [win32] - '@rspack/binding-win32-ia32-msvc@1.0.0-beta.3': - resolution: {integrity: sha512-4ccqbsPfNFXQ1BkN40Z2SuNfun1XvfdsbjG87NwjAWPEKH1I9lTZg7IeLIHdm+WvGwNSdg9xk8tu/ZA9aeLANA==} + '@rspack/binding-win32-ia32-msvc@1.0.0-rc.0': + resolution: {integrity: sha512-1A+3JorREQJqBcTLEY0LhGMb5B3Qlz/LmRr3K+gNBZinscZU+DKiDnZkSGdn8FuCn40E39T8V4i73mxQCqVuvQ==} cpu: [ia32] os: [win32] - '@rspack/binding-win32-x64-msvc@1.0.0-beta.3': - resolution: {integrity: sha512-QL0c+lP7gz6gR5lo8bhrx1VsvlgE3wkOReu96k5cscf9I349L+xeRMr7L5EsfcFyiK2mG8RjvlhLWIz9CFZ3IQ==} + '@rspack/binding-win32-x64-msvc@1.0.0-rc.0': + resolution: {integrity: sha512-t6E4t668CvP+DqNDluYJMivrDtFZ0iQhUYxXd0UUhDSwXKTbGW2tOwBXGaZ3gzj9OpqWCUVJ3pqP11KiBckorw==} cpu: [x64] os: [win32] - '@rspack/binding@1.0.0-beta.3': - resolution: {integrity: sha512-TJA2vC5UdNKVhogU9O1pwFGCD90dYtRXWRRXqI+fYgXdlOqqXYAjzON/CIuF9ZHUCL29TNKPQKMTNTpK3Q+exA==} + '@rspack/binding@1.0.0-rc.0': + resolution: {integrity: sha512-mx0x4ho0ndHpOnSjAEOoQZohTqJLYOl4hLEvQLEnXIPTdMjZtpiLUyuyKtzv6DrXDV5La3bsZuzbcdMyqkSWpg==} - '@rspack/core@1.0.0-beta.3': - resolution: {integrity: sha512-BOI3UHuWV2kjRJjvuMLIhwY86NpDS3CTePR/+PmEfRkrGy/BZd4Z+Sp8H0nw0RWUq9JU7nrwdGF+zj4aQCC2Jg==} + '@rspack/core@1.0.0-rc.0': + resolution: {integrity: sha512-sxS6QfVm7FbuKIYai8CyxMv5WH3MVdQmowVEqIZ/Fa8+PX17/sO5dg8tAFYAEzpCe/4dC93eYh9APr3Vc4ditQ==} engines: {node: '>=16.0.0'} peerDependencies: '@swc/helpers': '>=0.5.1' @@ -462,8 +470,8 @@ packages: '@swc/helpers': optional: true - '@rspack/lite-tapable@1.0.0-beta.3': - resolution: {integrity: sha512-K/OwOFX4SsILeSAJtmVCoBZUPaXLNFGeIXerK0SY09in8+0i21c+luZAhjlD0mH9+cD2A/zBGL+GIEPKkW6IwQ==} + '@rspack/lite-tapable@1.0.0': + resolution: {integrity: sha512-7MZf4lburSUZoEenwazwUDKHhqyfnLCGnQ/tKcUtztfmVzfjZfRn/EaiT0AKkYGnL2U8AGsw89oUeVyvaOLVCw==} engines: {node: '>=16.0.0'} '@swc/helpers@0.5.11': @@ -813,8 +821,8 @@ packages: whiskers: optional: true - core-js@3.37.1: - resolution: {integrity: sha512-Xn6qmxrQZyB0FFY8E3bgRXei3lWDJHhvI+u0q9TKIYM49G8pAr0FgnnrFRAmsbptZL1yxRADVXn+x5AGsbBfyw==} + core-js@3.38.1: + resolution: {integrity: sha512-OP35aUorbU3Zvlx7pjsFdu1rGNnD4pgw/CWoYzRY3t2EzoVT7shKHY1dlAy3f41cGIO7ZDPQimhGFTlEYkG/Hw==} cross-spawn@7.0.3: resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} @@ -849,6 +857,10 @@ packages: supports-color: optional: true + deepmerge@4.3.1: + resolution: {integrity: sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==} + engines: {node: '>=0.10.0'} + dir-glob@3.0.1: resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} engines: {node: '>=8'} @@ -1255,6 +1267,9 @@ packages: resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==} engines: {node: '>=8.10.0'} + reduce-configs@1.0.0: + resolution: {integrity: sha512-/JCYSgL/QeXXsq0Lv/7kOZfqvof7vyzHWfyNQPt3c6vc73mU4WRyT8RJ6ZH5Ci08vUOqXwk7jkZy6BycHTDD9w==} + resolve-from@5.0.0: resolution: {integrity: sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==} engines: {node: '>=8'} @@ -1671,21 +1686,21 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.4.15 - '@module-federation/runtime-tools@0.2.3': + '@module-federation/runtime-tools@0.5.1': dependencies: - '@module-federation/runtime': 0.2.3 - '@module-federation/webpack-bundler-runtime': 0.2.3 + '@module-federation/runtime': 0.5.1 + '@module-federation/webpack-bundler-runtime': 0.5.1 - '@module-federation/runtime@0.2.3': + '@module-federation/runtime@0.5.1': dependencies: - '@module-federation/sdk': 0.2.3 + '@module-federation/sdk': 0.5.1 - '@module-federation/sdk@0.2.3': {} + '@module-federation/sdk@0.5.1': {} - '@module-federation/webpack-bundler-runtime@0.2.3': + '@module-federation/webpack-bundler-runtime@0.5.1': dependencies: - '@module-federation/runtime': 0.2.3 - '@module-federation/sdk': 0.2.3 + '@module-federation/runtime': 0.5.1 + '@module-federation/sdk': 0.5.1 '@nodelib/fs.scandir@2.1.5': dependencies: @@ -1754,65 +1769,71 @@ snapshots: '@rollup/rollup-win32-x64-msvc@4.19.1': optional: true - '@rsbuild/core@1.0.1-beta.11': + '@rsbuild/core@1.0.1-beta.16': dependencies: - '@rspack/core': 1.0.0-beta.3(@swc/helpers@0.5.11) - '@rspack/lite-tapable': 1.0.0-beta.3 + '@rspack/core': 1.0.0-rc.0(@swc/helpers@0.5.11) + '@rspack/lite-tapable': 1.0.0 '@swc/helpers': 0.5.11 caniuse-lite: 1.0.30001651 - core-js: 3.37.1 + core-js: 3.38.1 optionalDependencies: fsevents: 2.3.3 - '@rspack/binding-darwin-arm64@1.0.0-beta.3': + '@rsbuild/plugin-less@1.0.1-beta.16(@rsbuild/core@1.0.1-beta.16)': + dependencies: + '@rsbuild/core': 1.0.1-beta.16 + deepmerge: 4.3.1 + reduce-configs: 1.0.0 + + '@rspack/binding-darwin-arm64@1.0.0-rc.0': optional: true - '@rspack/binding-darwin-x64@1.0.0-beta.3': + '@rspack/binding-darwin-x64@1.0.0-rc.0': optional: true - '@rspack/binding-linux-arm64-gnu@1.0.0-beta.3': + '@rspack/binding-linux-arm64-gnu@1.0.0-rc.0': optional: true - '@rspack/binding-linux-arm64-musl@1.0.0-beta.3': + '@rspack/binding-linux-arm64-musl@1.0.0-rc.0': optional: true - '@rspack/binding-linux-x64-gnu@1.0.0-beta.3': + '@rspack/binding-linux-x64-gnu@1.0.0-rc.0': optional: true - '@rspack/binding-linux-x64-musl@1.0.0-beta.3': + '@rspack/binding-linux-x64-musl@1.0.0-rc.0': optional: true - '@rspack/binding-win32-arm64-msvc@1.0.0-beta.3': + '@rspack/binding-win32-arm64-msvc@1.0.0-rc.0': optional: true - '@rspack/binding-win32-ia32-msvc@1.0.0-beta.3': + '@rspack/binding-win32-ia32-msvc@1.0.0-rc.0': optional: true - '@rspack/binding-win32-x64-msvc@1.0.0-beta.3': + '@rspack/binding-win32-x64-msvc@1.0.0-rc.0': optional: true - '@rspack/binding@1.0.0-beta.3': + '@rspack/binding@1.0.0-rc.0': optionalDependencies: - '@rspack/binding-darwin-arm64': 1.0.0-beta.3 - '@rspack/binding-darwin-x64': 1.0.0-beta.3 - '@rspack/binding-linux-arm64-gnu': 1.0.0-beta.3 - '@rspack/binding-linux-arm64-musl': 1.0.0-beta.3 - '@rspack/binding-linux-x64-gnu': 1.0.0-beta.3 - '@rspack/binding-linux-x64-musl': 1.0.0-beta.3 - '@rspack/binding-win32-arm64-msvc': 1.0.0-beta.3 - '@rspack/binding-win32-ia32-msvc': 1.0.0-beta.3 - '@rspack/binding-win32-x64-msvc': 1.0.0-beta.3 - - '@rspack/core@1.0.0-beta.3(@swc/helpers@0.5.11)': - dependencies: - '@module-federation/runtime-tools': 0.2.3 - '@rspack/binding': 1.0.0-beta.3 - '@rspack/lite-tapable': 1.0.0-beta.3 + '@rspack/binding-darwin-arm64': 1.0.0-rc.0 + '@rspack/binding-darwin-x64': 1.0.0-rc.0 + '@rspack/binding-linux-arm64-gnu': 1.0.0-rc.0 + '@rspack/binding-linux-arm64-musl': 1.0.0-rc.0 + '@rspack/binding-linux-x64-gnu': 1.0.0-rc.0 + '@rspack/binding-linux-x64-musl': 1.0.0-rc.0 + '@rspack/binding-win32-arm64-msvc': 1.0.0-rc.0 + '@rspack/binding-win32-ia32-msvc': 1.0.0-rc.0 + '@rspack/binding-win32-x64-msvc': 1.0.0-rc.0 + + '@rspack/core@1.0.0-rc.0(@swc/helpers@0.5.11)': + dependencies: + '@module-federation/runtime-tools': 0.5.1 + '@rspack/binding': 1.0.0-rc.0 + '@rspack/lite-tapable': 1.0.0 caniuse-lite: 1.0.30001651 optionalDependencies: '@swc/helpers': 0.5.11 - '@rspack/lite-tapable@1.0.0-beta.3': {} + '@rspack/lite-tapable@1.0.0': {} '@swc/helpers@0.5.11': dependencies: @@ -2081,7 +2102,7 @@ snapshots: dependencies: bluebird: 3.7.2 - core-js@3.37.1: {} + core-js@3.38.1: {} cross-spawn@7.0.3: dependencies: @@ -2110,6 +2131,8 @@ snapshots: dependencies: ms: 2.1.2 + deepmerge@4.3.1: {} + dir-glob@3.0.1: dependencies: path-type: 4.0.0 @@ -2468,6 +2491,10 @@ snapshots: dependencies: picomatch: 2.3.1 + reduce-configs@1.0.0: + dependencies: + browserslist: 4.23.3 + resolve-from@5.0.0: {} reusify@1.0.4: {} diff --git a/src/index.ts b/src/index.ts index 5b7ec16..859cae2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,11 @@ +import { createRequire } from 'node:module'; import type { RsbuildPlugin, RspackChain } from '@rsbuild/core'; import { type VueLoaderOptions, VueLoaderPlugin } from 'vue-loader'; import { VueLoader15PitchFixPlugin } from './VueLoader15PitchFixPlugin.js'; import { applySplitChunksRule } from './splitChunks.js'; +const require = createRequire(import.meta.url); + export type SplitVueChunkOptions = { /** * Whether to enable split chunking for Vue-related dependencies (e.g., vue, vue-loader). diff --git a/test/basic/index.test.ts b/test/basic/index.test.ts deleted file mode 100644 index bb77fe9..0000000 --- a/test/basic/index.test.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { dirname } from 'node:path'; -import { fileURLToPath } from 'node:url'; -import { expect, test } from '@playwright/test'; -import { createRsbuild } from '@rsbuild/core'; -import { pluginVue2 } from '../../src'; -import { getRandomPort } from '../helper'; - -const __dirname = dirname(fileURLToPath(import.meta.url)); - -test('should render page as expected', async ({ page }) => { - const rsbuild = await createRsbuild({ - cwd: __dirname, - rsbuildConfig: { - plugins: [pluginVue2()], - server: { - port: getRandomPort(), - }, - }, - }); - - const { server, urls } = await rsbuild.startDevServer(); - - await page.goto(urls[0]); - expect(await page.evaluate('window.test')).toBe(1); - - await server.close(); -}); - -test('should build succeed', async ({ page }) => { - const rsbuild = await createRsbuild({ - cwd: __dirname, - rsbuildConfig: { - plugins: [pluginVue2()], - }, - }); - - await rsbuild.build(); - const { server, urls } = await rsbuild.preview(); - - await page.goto(urls[0]); - expect(await page.evaluate('window.test')).toBe(1); - - await server.close(); -}); diff --git a/test/basic/src/index.js b/test/basic/src/index.js deleted file mode 100644 index 5482fa1..0000000 --- a/test/basic/src/index.js +++ /dev/null @@ -1 +0,0 @@ -window.test = 1; diff --git a/test/sfc-basic/index.test.ts b/test/sfc-basic/index.test.ts new file mode 100644 index 0000000..ee51819 --- /dev/null +++ b/test/sfc-basic/index.test.ts @@ -0,0 +1,28 @@ +import { dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { expect, test } from '@playwright/test'; +import { createRsbuild, loadConfig } from '@rsbuild/core'; + +const __dirname = dirname(fileURLToPath(import.meta.url)); + +test('should build basic Vue sfc correctly', async ({ page }) => { + const rsbuild = await createRsbuild({ + cwd: __dirname, + rsbuildConfig: (await loadConfig({ cwd: __dirname })).content, + }); + + await rsbuild.build(); + const { server, urls } = await rsbuild.preview(); + + await page.goto(urls[0]); + + const button1 = page.locator('#button1'); + const button2 = page.locator('#button2'); + const list1 = page.locator('.list1'); + + await expect(button1).toHaveText('A: 0'); + await expect(button2).toHaveText('B: 0'); + await expect(list1).toHaveCount(3); + + await server.close(); +}); diff --git a/test/sfc-basic/rsbuild.config.ts b/test/sfc-basic/rsbuild.config.ts new file mode 100644 index 0000000..ad4735e --- /dev/null +++ b/test/sfc-basic/rsbuild.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from '@rsbuild/core'; +import { pluginVue2 } from '@rsbuild/plugin-vue2'; +import { getRandomPort } from '../helper'; + +export default defineConfig({ + plugins: [pluginVue2()], + server: { + port: getRandomPort(), + }, +}); diff --git a/test/sfc-basic/src/A.vue b/test/sfc-basic/src/A.vue new file mode 100644 index 0000000..88ea53b --- /dev/null +++ b/test/sfc-basic/src/A.vue @@ -0,0 +1,29 @@ + + + diff --git a/test/sfc-basic/src/B.vue b/test/sfc-basic/src/B.vue new file mode 100644 index 0000000..3739620 --- /dev/null +++ b/test/sfc-basic/src/B.vue @@ -0,0 +1,14 @@ + + + diff --git a/test/sfc-basic/src/index.js b/test/sfc-basic/src/index.js new file mode 100644 index 0000000..c6101da --- /dev/null +++ b/test/sfc-basic/src/index.js @@ -0,0 +1,7 @@ +import Vue from 'vue'; +import A from './A.vue'; + +new Vue({ + el: '#root', + render: (h) => h(A), +}); diff --git a/test/sfc-css-modules/index.test.ts b/test/sfc-css-modules/index.test.ts new file mode 100644 index 0000000..7a88241 --- /dev/null +++ b/test/sfc-css-modules/index.test.ts @@ -0,0 +1,30 @@ +import { dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { expect, test } from '@playwright/test'; +import { createRsbuild, loadConfig } from '@rsbuild/core'; + +const __dirname = dirname(fileURLToPath(import.meta.url)); + +test('should build Vue sfc with CSS Modules correctly in prod build', async ({ + page, +}) => { + const rsbuild = await createRsbuild({ + cwd: __dirname, + rsbuildConfig: (await loadConfig({ cwd: __dirname })).content, + }); + + await rsbuild.build(); + const { server, urls } = await rsbuild.preview(); + + await page.goto(urls[0]); + + const test1 = page.locator('#test1'); + const test2 = page.locator('#test2'); + const test3 = page.locator('#test3'); + + await expect(test1).toHaveCSS('color', 'rgb(255, 0, 0)'); + await expect(test2).toHaveCSS('color', 'rgb(0, 0, 255)'); + await expect(test3).toHaveCSS('color', 'rgb(0, 128, 0)'); + + await server.close(); +}); diff --git a/test/sfc-css-modules/rsbuild.config.ts b/test/sfc-css-modules/rsbuild.config.ts new file mode 100644 index 0000000..ad4735e --- /dev/null +++ b/test/sfc-css-modules/rsbuild.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from '@rsbuild/core'; +import { pluginVue2 } from '@rsbuild/plugin-vue2'; +import { getRandomPort } from '../helper'; + +export default defineConfig({ + plugins: [pluginVue2()], + server: { + port: getRandomPort(), + }, +}); diff --git a/test/sfc-css-modules/src/App.vue b/test/sfc-css-modules/src/App.vue new file mode 100644 index 0000000..603b375 --- /dev/null +++ b/test/sfc-css-modules/src/App.vue @@ -0,0 +1,29 @@ + + + + + diff --git a/test/sfc-css-modules/src/index.js b/test/sfc-css-modules/src/index.js new file mode 100644 index 0000000..0850ce8 --- /dev/null +++ b/test/sfc-css-modules/src/index.js @@ -0,0 +1,7 @@ +import Vue from 'vue'; +import App from './App.vue'; + +new Vue({ + el: '#root', + render: (h) => h(App), +}); diff --git a/test/sfc-css-modules/src/style.module.css b/test/sfc-css-modules/src/style.module.css new file mode 100644 index 0000000..fa95e11 --- /dev/null +++ b/test/sfc-css-modules/src/style.module.css @@ -0,0 +1,3 @@ +.green { + color: green; +} diff --git a/test/sfc-lang-pcss/index.test.ts b/test/sfc-lang-pcss/index.test.ts new file mode 100644 index 0000000..2fdef73 --- /dev/null +++ b/test/sfc-lang-pcss/index.test.ts @@ -0,0 +1,23 @@ +import { dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { expect, test } from '@playwright/test'; +import { createRsbuild, loadConfig } from '@rsbuild/core'; + +const __dirname = dirname(fileURLToPath(import.meta.url)); + +test('should build Vue sfc with lang="pcss" correctly', async ({ page }) => { + const rsbuild = await createRsbuild({ + cwd: __dirname, + rsbuildConfig: (await loadConfig({ cwd: __dirname })).content, + }); + + await rsbuild.build(); + const { server, urls } = await rsbuild.preview(); + + await page.goto(urls[0]); + + const button = page.locator('#button'); + await expect(button).toHaveCSS('color', 'rgb(255, 0, 0)'); + + await server.close(); +}); diff --git a/test/sfc-lang-pcss/rsbuild.config.ts b/test/sfc-lang-pcss/rsbuild.config.ts new file mode 100644 index 0000000..ad4735e --- /dev/null +++ b/test/sfc-lang-pcss/rsbuild.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from '@rsbuild/core'; +import { pluginVue2 } from '@rsbuild/plugin-vue2'; +import { getRandomPort } from '../helper'; + +export default defineConfig({ + plugins: [pluginVue2()], + server: { + port: getRandomPort(), + }, +}); diff --git a/test/sfc-lang-pcss/src/App.vue b/test/sfc-lang-pcss/src/App.vue new file mode 100644 index 0000000..39acb9e --- /dev/null +++ b/test/sfc-lang-pcss/src/App.vue @@ -0,0 +1,9 @@ + + + diff --git a/test/sfc-lang-pcss/src/index.js b/test/sfc-lang-pcss/src/index.js new file mode 100644 index 0000000..0850ce8 --- /dev/null +++ b/test/sfc-lang-pcss/src/index.js @@ -0,0 +1,7 @@ +import Vue from 'vue'; +import App from './App.vue'; + +new Vue({ + el: '#root', + render: (h) => h(App), +}); diff --git a/test/sfc-lang-postcss/index.test.ts b/test/sfc-lang-postcss/index.test.ts new file mode 100644 index 0000000..9dd271c --- /dev/null +++ b/test/sfc-lang-postcss/index.test.ts @@ -0,0 +1,23 @@ +import { dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { expect, test } from '@playwright/test'; +import { createRsbuild, loadConfig } from '@rsbuild/core'; + +const __dirname = dirname(fileURLToPath(import.meta.url)); + +test('should build Vue sfc with lang="postcss" correctly', async ({ page }) => { + const rsbuild = await createRsbuild({ + cwd: __dirname, + rsbuildConfig: (await loadConfig({ cwd: __dirname })).content, + }); + + await rsbuild.build(); + const { server, urls } = await rsbuild.preview(); + + await page.goto(urls[0]); + + const button = page.locator('#button'); + await expect(button).toHaveCSS('color', 'rgb(255, 0, 0)'); + + await server.close(); +}); diff --git a/test/sfc-lang-postcss/rsbuild.config.ts b/test/sfc-lang-postcss/rsbuild.config.ts new file mode 100644 index 0000000..ad4735e --- /dev/null +++ b/test/sfc-lang-postcss/rsbuild.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from '@rsbuild/core'; +import { pluginVue2 } from '@rsbuild/plugin-vue2'; +import { getRandomPort } from '../helper'; + +export default defineConfig({ + plugins: [pluginVue2()], + server: { + port: getRandomPort(), + }, +}); diff --git a/test/sfc-lang-postcss/src/App.vue b/test/sfc-lang-postcss/src/App.vue new file mode 100644 index 0000000..c25769b --- /dev/null +++ b/test/sfc-lang-postcss/src/App.vue @@ -0,0 +1,9 @@ + + + diff --git a/test/sfc-lang-postcss/src/index.js b/test/sfc-lang-postcss/src/index.js new file mode 100644 index 0000000..0850ce8 --- /dev/null +++ b/test/sfc-lang-postcss/src/index.js @@ -0,0 +1,7 @@ +import Vue from 'vue'; +import App from './App.vue'; + +new Vue({ + el: '#root', + render: (h) => h(App), +}); diff --git a/test/sfc-lang-ts/index.test.ts b/test/sfc-lang-ts/index.test.ts new file mode 100644 index 0000000..a11c494 --- /dev/null +++ b/test/sfc-lang-ts/index.test.ts @@ -0,0 +1,23 @@ +import { dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { expect, test } from '@playwright/test'; +import { createRsbuild, loadConfig } from '@rsbuild/core'; + +const __dirname = dirname(fileURLToPath(import.meta.url)); + +test('should build Vue sfc with lang="ts" correctly', async ({ page }) => { + const rsbuild = await createRsbuild({ + cwd: __dirname, + rsbuildConfig: (await loadConfig({ cwd: __dirname })).content, + }); + + await rsbuild.build(); + const { server, urls } = await rsbuild.preview(); + + await page.goto(urls[0]); + + const button = page.locator('#button'); + await expect(button).toHaveText('count: 0 foo: bar'); + + await server.close(); +}); diff --git a/test/sfc-lang-ts/rsbuild.config.ts b/test/sfc-lang-ts/rsbuild.config.ts new file mode 100644 index 0000000..ad4735e --- /dev/null +++ b/test/sfc-lang-ts/rsbuild.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from '@rsbuild/core'; +import { pluginVue2 } from '@rsbuild/plugin-vue2'; +import { getRandomPort } from '../helper'; + +export default defineConfig({ + plugins: [pluginVue2()], + server: { + port: getRandomPort(), + }, +}); diff --git a/test/sfc-lang-ts/src/App.vue b/test/sfc-lang-ts/src/App.vue new file mode 100644 index 0000000..735f30a --- /dev/null +++ b/test/sfc-lang-ts/src/App.vue @@ -0,0 +1,22 @@ + + + diff --git a/test/sfc-lang-ts/src/index.js b/test/sfc-lang-ts/src/index.js new file mode 100644 index 0000000..e4572d7 --- /dev/null +++ b/test/sfc-lang-ts/src/index.js @@ -0,0 +1,7 @@ +import Vue from 'vue'; +import App from './App.vue'; + +new Vue({ + el: '#root', + render: (h) => h(App, { props: { foo: 'bar' } }), +}); diff --git a/test/sfc-style/index.test.ts b/test/sfc-style/index.test.ts new file mode 100644 index 0000000..da9bf9d --- /dev/null +++ b/test/sfc-style/index.test.ts @@ -0,0 +1,28 @@ +import { dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { expect, test } from '@playwright/test'; +import { createRsbuild, loadConfig } from '@rsbuild/core'; + +const __dirname = dirname(fileURLToPath(import.meta.url)); + +test('should build Vue sfc style correctly', async ({ page }) => { + const rsbuild = await createRsbuild({ + cwd: __dirname, + rsbuildConfig: (await loadConfig({ cwd: __dirname })).content, + }); + + await rsbuild.build(); + const { server, urls } = await rsbuild.preview(); + + await page.goto(urls[0]); + + const button = page.locator('#button'); + await expect(button).toHaveCSS('color', 'rgb(255, 0, 0)'); + + const body = page.locator('body'); + await expect(body).toHaveCSS('background-color', 'rgb(0, 0, 255)'); + + await expect(body).toHaveCSS('padding', '16px'); + + await server.close(); +}); diff --git a/test/sfc-style/rsbuild.config.ts b/test/sfc-style/rsbuild.config.ts new file mode 100644 index 0000000..fddb68c --- /dev/null +++ b/test/sfc-style/rsbuild.config.ts @@ -0,0 +1,11 @@ +import { defineConfig } from '@rsbuild/core'; +import { pluginLess } from '@rsbuild/plugin-less'; +import { pluginVue2 } from '@rsbuild/plugin-vue2'; +import { getRandomPort } from '../helper'; + +export default defineConfig({ + plugins: [pluginVue2(), pluginLess()], + server: { + port: getRandomPort(), + }, +}); diff --git a/test/sfc-style/src/App.vue b/test/sfc-style/src/App.vue new file mode 100644 index 0000000..28ef818 --- /dev/null +++ b/test/sfc-style/src/App.vue @@ -0,0 +1,22 @@ + + + + + + + diff --git a/test/sfc-style/src/a.less b/test/sfc-style/src/a.less new file mode 100644 index 0000000..8371917 --- /dev/null +++ b/test/sfc-style/src/a.less @@ -0,0 +1,3 @@ +body { + background-color: blue; +} diff --git a/test/sfc-style/src/index.js b/test/sfc-style/src/index.js new file mode 100644 index 0000000..721f5f6 --- /dev/null +++ b/test/sfc-style/src/index.js @@ -0,0 +1,8 @@ +import Vue from 'vue'; +import App from './App.vue'; +import './a.less'; + +new Vue({ + el: '#root', + render: (h) => h(App), +}); diff --git a/test/split-chunk/index.test.ts b/test/split-chunk/index.test.ts new file mode 100644 index 0000000..9e19e10 --- /dev/null +++ b/test/split-chunk/index.test.ts @@ -0,0 +1,49 @@ +import { existsSync } from 'node:fs'; +import path, { dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { expect, test } from '@playwright/test'; +import { createRsbuild } from '@rsbuild/core'; +import { pluginVue2 } from '../../dist'; + +const __dirname = dirname(fileURLToPath(import.meta.url)); + +test('should split vue chunks correctly', async () => { + const rsbuild = await createRsbuild({ + cwd: __dirname, + rsbuildConfig: { + plugins: [pluginVue2()], + output: { + filenameHash: false, + }, + }, + }); + + await rsbuild.build(); + + const libVuePath = path.join(__dirname, 'dist', 'static/js/lib-vue.js'); + expect(existsSync(libVuePath)).toBeTruthy(); + + await rsbuild.build(); +}); + +test('should not split vue chunks when strategy is `all-in-one`', async () => { + const rsbuild = await createRsbuild({ + cwd: __dirname, + rsbuildConfig: { + plugins: [pluginVue2()], + performance: { + chunkSplit: { + strategy: 'all-in-one', + }, + }, + output: { + filenameHash: false, + }, + }, + }); + + await rsbuild.build(); + + const libVuePath = path.join(__dirname, 'dist', 'static/js/lib-vue.js'); + expect(existsSync(libVuePath)).toBeFalsy(); +}); diff --git a/test/split-chunk/rsbuild.config.ts b/test/split-chunk/rsbuild.config.ts new file mode 100644 index 0000000..ceb058e --- /dev/null +++ b/test/split-chunk/rsbuild.config.ts @@ -0,0 +1,8 @@ +import { pluginVue2 } from '../../dist'; + +export default { + plugins: [pluginVue2()], + output: { + filenameHash: false, + }, +}; diff --git a/test/split-chunk/src/index.js b/test/split-chunk/src/index.js new file mode 100644 index 0000000..bfd3d10 --- /dev/null +++ b/test/split-chunk/src/index.js @@ -0,0 +1,3 @@ +import Vue from 'vue'; + +console.log(Vue);