From 8510aeea79930e0348d13a769f0a3c5a452d8986 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Tue, 19 Sep 2023 17:03:59 +0800 Subject: [PATCH 01/58] chore: update farm --- package.json | 2 + pnpm-lock.yaml | 700 +++++++++++++++++++++- scripts/buildFixtures.ts | 4 + src/define.ts | 5 + src/farm/index.ts | 61 ++ src/types.ts | 3 + test/fixtures/load/__test__/build.test.ts | 6 + test/fixtures/load/farm.config.js | 34 ++ 8 files changed, 814 insertions(+), 1 deletion(-) create mode 100644 src/farm/index.ts create mode 100644 test/fixtures/load/farm.config.js diff --git a/package.json b/package.json index 4314c9c7..30cd403d 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,8 @@ "@ampproject/remapping": "^2.2.1", "@antfu/eslint-config": "^0.42.0", "@antfu/ni": "^0.21.8", + "@farmfe/cli": "^0.5.5", + "@farmfe/core": "^0.12.3", "@rspack/cli": "^0.3.4", "@rspack/core": "^0.3.4", "@types/fs-extra": "^11.0.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 210c5a9b..1b849ef9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: '6.0' +lockfileVersion: '6.1' settings: autoInstallPeers: true @@ -28,6 +28,12 @@ devDependencies: '@antfu/ni': specifier: ^0.21.8 version: 0.21.8 + '@farmfe/cli': + specifier: ^0.5.5 + version: 0.5.5 + '@farmfe/core': + specifier: ^0.12.3 + version: 0.12.3 '@rspack/cli': specifier: ^0.3.4 version: 0.3.4(esbuild@0.19.3)(react-refresh@0.14.0)(webpack-cli@4.10.0) @@ -683,6 +689,107 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true + /@farmfe/cli@0.5.5: + resolution: {integrity: sha512-Q+CvD+WpZT0CWqBmru1eqw8hZm27X8C0l+lPVcKOHqu88iM20eK2bgNSq2Z5IoDHGhq8TW6ds1kHYGiIrB3/nQ==} + engines: {node: '>= 16'} + hasBin: true + dependencies: + cac: 6.7.14 + chalk: 5.3.0 + cross-spawn: 7.0.3 + enquirer: 2.4.1 + inquirer: 9.2.11 + walkdir: 0.4.1 + dev: true + + /@farmfe/core-darwin-arm64@0.12.3: + resolution: {integrity: sha512-jMKjVp7/+jam833rxArdbwERq7BWnSO9p8fMkeMXY6l4QC0qpwIqHpC7EzGQ+FdLhxd7XDWcWRYJvbKN7bzvBQ==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /@farmfe/core-darwin-x64@0.12.3: + resolution: {integrity: sha512-y9qgxDEfLlByDqZyVNwOJkaT0ZQPzGs2W/LsEKS0aKUEqMX2ohrTajIuuxIjMn8dpoUX7/QShaW2pkQ6gBPnJg==} + engines: {node: '>= 10'} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /@farmfe/core-linux-x64-gnu@0.12.3: + resolution: {integrity: sha512-ojg/Zm6rnv3lhaf6I8jLRmHvIJxjO2uV15tc52a5svg8gHm/kKCLRHKuSrr1LyovqqxwEnowNuRQsYIobzqz2A==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + libc: [glibc] + requiresBuild: true + dev: true + optional: true + + /@farmfe/core-win32-x64-msvc@0.12.3: + resolution: {integrity: sha512-mra84fFmCRMkq6Q6FUfPJrS2N7scHrOH6zk5wrVqpIApLyIuIqETNLrJOCiVOxQF3D/VuEQbHUlK7CrQg9YAlQ==} + engines: {node: '>= 10'} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@farmfe/core@0.12.3: + resolution: {integrity: sha512-o5F3HeGoHIrodh8GFl5kH3Twoomxe2qpHJgG2nKPH38vvVY3hnRSfkFTGilMBF39jeVukexXwsXuQQffsMKMtg==} + engines: {node: '>= 16'} + dependencies: + '@farmfe/runtime': 0.7.0 + '@farmfe/runtime-plugin-hmr': 3.2.3 + '@koa/cors': 4.0.0 + '@swc/helpers': 0.5.1 + boxen: 7.1.1 + chalk: 5.3.0 + dotenv: 16.3.1 + dotenv-expand: 10.0.0 + execa: 7.2.0 + figlet: 1.6.0 + fs-extra: 11.1.1 + koa: 2.14.2 + koa-compress: 5.1.1 + koa-proxies: 0.12.3(koa@2.14.2) + koa-static: 5.0.0 + lodash.debounce: 4.0.8 + lodash.merge: 4.6.2 + loglevel: 1.8.1 + open: 9.1.0 + sirv: 2.0.3 + ws: 8.13.0 + zod: 3.21.4 + zod-validation-error: 1.5.0(zod@3.21.4) + optionalDependencies: + '@farmfe/core-darwin-arm64': 0.12.3 + '@farmfe/core-darwin-x64': 0.12.3 + '@farmfe/core-linux-x64-gnu': 0.12.3 + '@farmfe/core-win32-x64-msvc': 0.12.3 + transitivePeerDependencies: + - bufferutil + - debug + - supports-color + - utf-8-validate + dev: true + + /@farmfe/runtime-plugin-hmr@3.2.3: + resolution: {integrity: sha512-shjbIjTXMW2l7rdZ1E8s4slGgM1iFEo/ovapflQMioJRSGDI6yLETuryptGGr9MEgHhXltnfaHSbGLJBc/RfkQ==} + dependencies: + core-js: 3.32.2 + dev: true + + /@farmfe/runtime@0.7.0: + resolution: {integrity: sha512-oci/0V/60ntaG6kC5//AqRabbK8U1nFarBngymC+qWNs3a2eJFfxolX5oeq4FvqlWwFF9kVBvAtqs8hXGxrqZA==} + dependencies: + core-js: 3.32.2 + dev: true + /@humanwhocodes/config-array@0.11.11: resolution: {integrity: sha512-N2brEuAadi0CcdeMXUkhbZB84eskAc8MEX1By6qEchoVywSgXPIjou4rYsl0V3Hj0ZnuGycGCjdNgockbzeWNA==} engines: {node: '>=10.10.0'} @@ -766,10 +873,22 @@ packages: type-detect: 4.0.8 dev: true + /@koa/cors@4.0.0: + resolution: {integrity: sha512-Y4RrbvGTlAaa04DBoPBWJqDR5gPj32OOz827ULXfgB1F7piD1MB/zwn8JR2LAnvdILhxUbXbkXGWuNVsFuVFCQ==} + engines: {node: '>= 14.0.0'} + dependencies: + vary: 1.1.2 + dev: true + /@leichtgewicht/ip-codec@2.0.4: resolution: {integrity: sha512-Hcv+nVC0kZnQ3tD9GVu5xSMR4VVYOteQIr/hwFPVEvPdlXqgGEuRjiheChHgdM+JyqdgNcmzZOX/tnl0JOiI7A==} dev: true + /@ljharb/through@2.3.9: + resolution: {integrity: sha512-yN599ZBuMPPK4tdoToLlvgJB4CLK8fGl7ntfy0Wn7U6ttNvHYurd81bfUiK/6sMkiIwm65R6ck4L6+Y3DfVbNQ==} + engines: {node: '>= 0.4'} + dev: true + /@nodelib/fs.scandir@2.1.5: resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -855,6 +974,7 @@ packages: resolution: {integrity: sha512-zsVroEhA5T6HhFxiQCrEZiqEAeHP379iT+Scupp3JD7ITfDvNqCTcXObJUUhZctQWPlxn4MqtuL3goRPgvpWWQ==} cpu: [arm64] os: [linux] + libc: [glibc] requiresBuild: true dev: true optional: true @@ -863,6 +983,7 @@ packages: resolution: {integrity: sha512-5x8i92eP9ubMDEO3OLT31GdjF9nEyQCPNequAspwv98spaazbiUawPcWZN5XPhsAR41f/w2CvrNUNL7EOHJMkQ==} cpu: [arm64] os: [linux] + libc: [musl] requiresBuild: true dev: true optional: true @@ -871,6 +992,7 @@ packages: resolution: {integrity: sha512-oOtLICpLwdgKexHBQi9DERo2Ciweadf2b942Gh9vnMrVJz/oXf9eubewmN4mni5/S+RpSGJoChVvtV1E8ugN/Q==} cpu: [x64] os: [linux] + libc: [glibc] requiresBuild: true dev: true optional: true @@ -879,6 +1001,7 @@ packages: resolution: {integrity: sha512-yCEb90A3uWOvW4XKxTSaAma70P9UuPffgvt16W+uNb/rGSmTDcZr9/jytvmB5nbOwOq7dx2cu2NEJwWdSvMvxQ==} cpu: [x64] os: [linux] + libc: [musl] requiresBuild: true dev: true optional: true @@ -1798,6 +1921,17 @@ packages: uri-js: 4.4.1 dev: true + /ansi-align@3.0.1: + resolution: {integrity: sha512-IOfwwBF5iczOjp/WeY4YxyjqAFMQoZufdQWDd19SEExbVLNXqvpzSJ/M7Za4/sCPmQ0+GRquoA7bGcINcxew6w==} + dependencies: + string-width: 4.2.3 + dev: true + + /ansi-colors@4.1.3: + resolution: {integrity: sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==} + engines: {node: '>=6'} + dev: true + /ansi-escapes@4.3.2: resolution: {integrity: sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==} engines: {node: '>=8'} @@ -1907,10 +2041,19 @@ packages: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} dev: true + /base64-js@1.5.1: + resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} + dev: true + /batch@0.6.1: resolution: {integrity: sha512-x+VAiMRL6UPkx+kudNvxTl6hB2XNNCG2r+7wixVfIYwu/2HKRXimwQyaumLjMveWvT2Hkd/cAJw+QBMfJ/EKVw==} dev: true + /big-integer@1.6.51: + resolution: {integrity: sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==} + engines: {node: '>=0.6'} + dev: true + /big.js@5.2.2: resolution: {integrity: sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==} dev: true @@ -1919,6 +2062,14 @@ packages: resolution: {integrity: sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==} engines: {node: '>=8'} + /bl@4.1.0: + resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==} + dependencies: + buffer: 5.7.1 + inherits: 2.0.4 + readable-stream: 3.6.2 + dev: true + /body-parser@1.20.0: resolution: {integrity: sha512-DfJ+q6EPcGKZD1QWUjSpqp+Q7bDQTsQIF4zfUAtZ6qk+H/3/QRhg9CEp39ss+/T2vw0+HaidC0ecJj/DRLIaKg==} engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16} @@ -1952,6 +2103,27 @@ packages: resolution: {integrity: sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==} dev: true + /boxen@7.1.1: + resolution: {integrity: sha512-2hCgjEmP8YLWQ130n2FerGv7rYpfBmnmp9Uy2Le1vge6X3gZIfSmEzP5QTDElFxcvVcXlEn8Aq6MU/PZygIOog==} + engines: {node: '>=14.16'} + dependencies: + ansi-align: 3.0.1 + camelcase: 7.0.1 + chalk: 5.3.0 + cli-boxes: 3.0.0 + string-width: 5.1.2 + type-fest: 2.19.0 + widest-line: 4.0.1 + wrap-ansi: 8.1.0 + dev: true + + /bplist-parser@0.2.0: + resolution: {integrity: sha512-z0M+byMThzQmD9NILRniCUXYsYpjwnlO8N5uCFaCqIOpqRsJCrQL9NK3JsD67CN5a08nF5oIL2bD6loTdHOuKw==} + engines: {node: '>= 5.10.0'} + dependencies: + big-integer: 1.6.51 + dev: true + /brace-expansion@1.1.11: resolution: {integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==} dependencies: @@ -1980,6 +2152,13 @@ packages: resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} dev: true + /buffer@5.7.1: + resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==} + dependencies: + base64-js: 1.5.1 + ieee754: 1.2.1 + dev: true + /builtin-modules@3.3.0: resolution: {integrity: sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==} engines: {node: '>=6'} @@ -2006,6 +2185,13 @@ packages: - supports-color dev: true + /bundle-name@3.0.0: + resolution: {integrity: sha512-PKA4BeSvBpQKQ8iPOGCSiell+N8P+Tf1DlwqmYhpe2gAhKPHn8EYOxVT+ShuGmhg8lN8XiSlS80yiExKXrURlw==} + engines: {node: '>=12'} + dependencies: + run-applescript: 5.0.0 + dev: true + /bundle-require@4.0.1(esbuild@0.18.11): resolution: {integrity: sha512-9NQkRHlNdNpDBGmLpngF3EFDcwodhMUuLz9PaWYciVcQF9SE4LFjM2DB/xV1Li5JiuDMv7ZUWuC3rGbqR0MAXQ==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -2049,6 +2235,14 @@ packages: engines: {node: '>=8'} dev: true + /cache-content-type@1.0.1: + resolution: {integrity: sha512-IKufZ1o4Ut42YUrZSo8+qnMTrFuKkvyoLXUywKz9GJ5BrhOFGhLdkx9sG4KAnVvbY6kEcSFjLQul+DVmBm2bgA==} + engines: {node: '>= 6.0.0'} + dependencies: + mime-types: 2.1.35 + ylru: 1.3.2 + dev: true + /call-bind@1.0.2: resolution: {integrity: sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==} dependencies: @@ -2079,6 +2273,11 @@ packages: engines: {node: '>=6'} dev: true + /camelcase@7.0.1: + resolution: {integrity: sha512-xlx1yCK2Oc1APsPXDL2LdlNP6+uu8OCDdhOBSVT279M/S+y75O30C2VuD8T2ogdePBBl7PfPF4504tnLgX3zfw==} + engines: {node: '>=14.16'} + dev: true + /caniuse-lite@1.0.30001464: resolution: {integrity: sha512-oww27MtUmusatpRpCGSOneQk2/l5czXANDSFvsc7VuOQ86s3ANhZetpwXNf1zY/zdfP63Xvjz325DAdAoES13g==} dev: true @@ -2130,6 +2329,10 @@ packages: resolution: {integrity: sha512-mKKUkUbhPpQlCOfIuZkvSEgktjPFIsZKRRbC6KWVEMvlzblj3i3asQv5ODsrwt0N3pHAEvjP8KTQPHkp0+6jOg==} dev: true + /chardet@0.7.0: + resolution: {integrity: sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==} + dev: true + /check-error@1.0.2: resolution: {integrity: sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==} dev: true @@ -2170,6 +2373,18 @@ packages: escape-string-regexp: 1.0.5 dev: true + /cli-boxes@3.0.0: + resolution: {integrity: sha512-/lzGpEWL/8PfI0BmBOPRwp0c/wFNX1RdUML3jK/RcSBA9T8mZDdQpqYBKtCFTOfQbwPqWEOpjqW+Fnayc0969g==} + engines: {node: '>=10'} + dev: true + + /cli-cursor@3.1.0: + resolution: {integrity: sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==} + engines: {node: '>=8'} + dependencies: + restore-cursor: 3.1.0 + dev: true + /cli-cursor@4.0.0: resolution: {integrity: sha512-VGtlMu3x/4DOtIUwEkRezxUZ2lBacNJCHash0N0WeZDBS+7Ux1dm3XWAgWYxLJFMMdOeXMHXorshEFhbMSGelg==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -2177,6 +2392,11 @@ packages: restore-cursor: 4.0.0 dev: true + /cli-spinners@2.9.1: + resolution: {integrity: sha512-jHgecW0pxkonBJdrKsqxgRX9AcG+u/5k0Q7WPDfi8AogLAdwxEkyYYNWwZ5GvVFoFx2uiY1eNcSK00fh+1+FyQ==} + engines: {node: '>=6'} + dev: true + /cli-truncate@3.1.0: resolution: {integrity: sha512-wfOBkjXteqSnI59oPcJkcPl/ZmwvMMOj340qUIY1SKZCv0B9Cf4D4fAucRkIKQmsIuYK3x1rrgU7MeGRruiuiA==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -2185,6 +2405,11 @@ packages: string-width: 5.1.2 dev: true + /cli-width@4.1.0: + resolution: {integrity: sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==} + engines: {node: '>= 12'} + dev: true + /cliui@7.0.4: resolution: {integrity: sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==} dependencies: @@ -2211,6 +2436,16 @@ packages: shallow-clone: 3.0.1 dev: true + /clone@1.0.4: + resolution: {integrity: sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==} + engines: {node: '>=0.8'} + dev: true + + /co@4.6.0: + resolution: {integrity: sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==} + engines: {iojs: '>= 1.0.0', node: '>= 0.12.0'} + dev: true + /color-convert@1.9.3: resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==} dependencies: @@ -2465,11 +2700,24 @@ packages: engines: {node: '>= 0.6'} dev: true + /cookies@0.8.0: + resolution: {integrity: sha512-8aPsApQfebXnuI+537McwYsDtjVxGm8gTIzQI3FDW6t5t/DAhERxtnbEPN/8RX+uZthoz4eCOgloXaE5cYyNow==} + engines: {node: '>= 0.8'} + dependencies: + depd: 2.0.0 + keygrip: 1.1.0 + dev: true + /core-js-pure@3.30.2: resolution: {integrity: sha512-p/npFUJXXBkCCTIlEGBdghofn00jWG6ZOtdoIXSJmAu2QBvN0IqpZXWweOytcwE6cfx8ZvVUy1vw8zxhe4Y2vg==} requiresBuild: true dev: true + /core-js@3.32.2: + resolution: {integrity: sha512-pxXSw1mYZPDGvTQqEc5vgIb83jGQKFGYWY76z4a7weZXUolw3G+OvpZqSRcfYOoOVUQJYEPsWeQK8pKEnUtWxQ==} + requiresBuild: true + dev: true + /core-util-is@1.0.3: resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==} dev: true @@ -2552,10 +2800,32 @@ packages: type-detect: 4.0.8 dev: true + /deep-equal@1.0.1: + resolution: {integrity: sha512-bHtC0iYvWhyaTzvV3CZgPeZQqCOBGyGsVV7v4eevpdkLHfiSrXUdBG+qAuSz4RI70sszvjQ1QSZ98An1yNwpSw==} + dev: true + /deep-is@0.1.4: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} dev: true + /default-browser-id@3.0.0: + resolution: {integrity: sha512-OZ1y3y0SqSICtE8DE4S8YOE9UZOJ8wO16fKWVP5J1Qz42kV9jcnMVFrEE/noXb/ss3Q4pZIH79kxofzyNNtUNA==} + engines: {node: '>=12'} + dependencies: + bplist-parser: 0.2.0 + untildify: 4.0.0 + dev: true + + /default-browser@4.0.0: + resolution: {integrity: sha512-wX5pXO1+BrhMkSbROFsyxUm0i/cJEScyNhA4PPxc41ICuv05ZZB/MX28s8aZx6xjmatvebIapF6hLEKEcpneUA==} + engines: {node: '>=14.16'} + dependencies: + bundle-name: 3.0.0 + default-browser-id: 3.0.0 + execa: 7.2.0 + titleize: 3.0.0 + dev: true + /default-gateway@6.0.3: resolution: {integrity: sha512-fwSOJsbbNzZ/CUFpqFBqYfYNLj1NbMPm8MMCIzHjC83iSJRBEGmDUxU+WP661BaBQImeC2yHwXtz+P/O9o+XEg==} engines: {node: '>= 10'} @@ -2563,15 +2833,30 @@ packages: execa: 5.1.1 dev: true + /defaults@1.0.4: + resolution: {integrity: sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A==} + dependencies: + clone: 1.0.4 + dev: true + /define-lazy-prop@2.0.0: resolution: {integrity: sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==} engines: {node: '>=8'} dev: true + /define-lazy-prop@3.0.0: + resolution: {integrity: sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg==} + engines: {node: '>=12'} + dev: true + /defu@6.1.2: resolution: {integrity: sha512-+uO4+qr7msjNNWKYPHqN/3+Dx3NFkmIzayk2L1MyZQlvgZb/J1A0fo410dpKrN2SnqFjt8n4JL8fDJE0wIgjFQ==} dev: true + /delegates@1.0.0: + resolution: {integrity: sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==} + dev: true + /depd@1.1.2: resolution: {integrity: sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==} engines: {node: '>= 0.6'} @@ -2666,6 +2951,11 @@ packages: is-obj: 2.0.0 dev: true + /dotenv-expand@10.0.0: + resolution: {integrity: sha512-GopVGCpVS1UKH75VKHGuQFqS1Gusej0z4FyQkPdwjil2gNIv+LNsqBlboOzpJFZKVT95GkCyWJbBSdFEFUWI2A==} + engines: {node: '>=12'} + dev: true + /dotenv@16.3.1: resolution: {integrity: sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==} engines: {node: '>=12'} @@ -2721,6 +3011,14 @@ packages: tapable: 2.2.1 dev: true + /enquirer@2.4.1: + resolution: {integrity: sha512-rRqJg/6gd538VHvR3PSrdRBb/1Vy2YfzHqzvbhGIQpDRKIa4FgV/54b5Q1xYSxOOwKvjXweS26E0Q+nAMwp2pQ==} + engines: {node: '>=8.6'} + dependencies: + ansi-colors: 4.1.3 + strip-ansi: 6.0.1 + dev: true + /entities@4.4.0: resolution: {integrity: sha512-oYp7156SP8LkeGD0GF85ad1X9Ai79WtRsZ2gxJqtBuzH+98YUV6jkHEKlZkMbcrjJjIVJNIDP/3WL9wQkoPbWA==} engines: {node: '>=0.12'} @@ -2831,6 +3129,11 @@ packages: engines: {node: '>=10'} dev: true + /escape-string-regexp@5.0.0: + resolution: {integrity: sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==} + engines: {node: '>=12'} + dev: true + /eslint-import-resolver-node@0.3.7: resolution: {integrity: sha512-gozW2blMLJCeFpBwugLTGyvVjNoeo1knonXAcatC6bjPBZitotxdWf7Gimr25N4c0AAOo4eOUfaG82IJPDpqCA==} dependencies: @@ -3302,6 +3605,15 @@ packages: - supports-color dev: true + /external-editor@3.1.0: + resolution: {integrity: sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==} + engines: {node: '>=4'} + dependencies: + chardet: 0.7.0 + iconv-lite: 0.4.24 + tmp: 0.0.33 + dev: true + /fast-deep-equal@3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} dev: true @@ -3342,6 +3654,20 @@ packages: websocket-driver: 0.7.4 dev: true + /figlet@1.6.0: + resolution: {integrity: sha512-31EQGhCEITv6+hi2ORRPyn3bulaV9Fl4xOdR169cBzH/n1UqcxsiSB/noo6SJdD7Kfb1Ljit+IgR1USvF/XbdA==} + engines: {node: '>= 0.4.0'} + hasBin: true + dev: true + + /figures@5.0.0: + resolution: {integrity: sha512-ej8ksPF4x6e5wvK9yevct0UCXh8TTFlWGVLlgjZuoBH1HwjIfKE/IdL5mq89sFA7zELi1VhKpmtDnrs7zWyeyg==} + engines: {node: '>=14'} + dependencies: + escape-string-regexp: 5.0.0 + is-unicode-supported: 1.3.0 + dev: true + /file-entry-cache@6.0.1: resolution: {integrity: sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==} engines: {node: ^10.12.0 || >=12.0.0} @@ -3721,10 +4047,26 @@ packages: entities: 4.4.0 dev: true + /http-assert@1.5.0: + resolution: {integrity: sha512-uPpH7OKX4H25hBmU6G1jWNaqJGpTXxey+YOUizJUAgu0AjLUeC8D73hTrhvDS5D+GJN1DN1+hhc/eF/wpxtp0w==} + engines: {node: '>= 0.8'} + dependencies: + deep-equal: 1.0.1 + http-errors: 1.8.1 + dev: true + /http-deceiver@1.2.7: resolution: {integrity: sha512-LmpOGxTfbpgtGVxJrj5k7asXHCgNZp5nLfp+hWc8QQRqtb7fUy6kRY3BO1h9ddF6yIPYUARgxGOwB42DnxIaNw==} dev: true + /http-errors@1.4.0: + resolution: {integrity: sha512-oLjPqve1tuOl5aRhv8GK5eHpqP1C9fb+Ol+XTLjKfLltE44zdDbEdjPSbU7Ch5rSNsVFqZn97SrMmZLdu1/YMw==} + engines: {node: '>= 0.6'} + dependencies: + inherits: 2.0.1 + statuses: 1.5.0 + dev: true + /http-errors@1.6.3: resolution: {integrity: sha512-lks+lVC8dgGyh97jxvxeYTWQFvh4uw4yC12gVl63Cg30sjPX4wuGcdkICVXDAESr6OJGjqGA8Iz5mkeN6zlD7A==} engines: {node: '>= 0.6'} @@ -3735,6 +4077,17 @@ packages: statuses: 1.5.0 dev: true + /http-errors@1.8.1: + resolution: {integrity: sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==} + engines: {node: '>= 0.6'} + dependencies: + depd: 1.1.2 + inherits: 2.0.4 + setprototypeof: 1.2.0 + statuses: 1.5.0 + toidentifier: 1.0.1 + dev: true + /http-errors@2.0.0: resolution: {integrity: sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==} engines: {node: '>= 0.8'} @@ -3807,6 +4160,10 @@ packages: safer-buffer: 2.1.2 dev: true + /ieee754@1.2.1: + resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} + dev: true + /ignore@5.2.4: resolution: {integrity: sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==} engines: {node: '>= 4'} @@ -3846,6 +4203,10 @@ packages: wrappy: 1.0.2 dev: true + /inherits@2.0.1: + resolution: {integrity: sha512-8nWq2nLTAwd02jTqJExUYFSD/fKq6VH9Y/oG2accc/kdI0V98Bag8d5a4gi3XHz73rDWa2PvTtvcWYquKqSENA==} + dev: true + /inherits@2.0.3: resolution: {integrity: sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==} dev: true @@ -3858,6 +4219,27 @@ packages: resolution: {integrity: sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==} dev: true + /inquirer@9.2.11: + resolution: {integrity: sha512-B2LafrnnhbRzCWfAdOXisUzL89Kg8cVJlYmhqoi3flSiV/TveO+nsXwgKr9h9PIo+J1hz7nBSk6gegRIMBBf7g==} + engines: {node: '>=14.18.0'} + dependencies: + '@ljharb/through': 2.3.9 + ansi-escapes: 4.3.2 + chalk: 5.3.0 + cli-cursor: 3.1.0 + cli-width: 4.1.0 + external-editor: 3.1.0 + figures: 5.0.0 + lodash: 4.17.21 + mute-stream: 1.0.0 + ora: 5.4.1 + run-async: 3.0.0 + rxjs: 7.8.1 + string-width: 4.2.3 + strip-ansi: 6.0.1 + wrap-ansi: 6.2.0 + dev: true + /interpret@2.2.0: resolution: {integrity: sha512-Ju0Bz/cEia55xDwUWEa8+olFpCiQoypjnQySseKtmjNrnps3P+xfpUmGr90T7yjlVJmOtybRvPXhKMbHr+fWnw==} engines: {node: '>= 0.10'} @@ -3935,6 +4317,12 @@ packages: hasBin: true dev: true + /is-docker@3.0.0: + resolution: {integrity: sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + hasBin: true + dev: true + /is-extglob@2.1.1: resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} engines: {node: '>=0.10.0'} @@ -3966,6 +4354,19 @@ packages: resolution: {integrity: sha512-gyPJuv83bHMpocVYoqof5VDiZveEoGoFL8m3BXNb2VW8Xs+rz9kqO8LOQ5DH6EsuvilT1ApazU0pyl+ytbPtlw==} dev: true + /is-inside-container@1.0.0: + resolution: {integrity: sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==} + engines: {node: '>=14.16'} + hasBin: true + dependencies: + is-docker: 3.0.0 + dev: true + + /is-interactive@1.0.0: + resolution: {integrity: sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==} + engines: {node: '>=8'} + dev: true + /is-number@7.0.0: resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} engines: {node: '>=0.12.0'} @@ -4025,6 +4426,16 @@ packages: has-tostringtag: 1.0.0 dev: true + /is-unicode-supported@0.1.0: + resolution: {integrity: sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==} + engines: {node: '>=10'} + dev: true + + /is-unicode-supported@1.3.0: + resolution: {integrity: sha512-43r2mRvz+8JRIKnWJ+3j8JtjRKZ6GmjzfaE/qiBJnikNnYv/6bagRJ1kUhNk8R5EX/GkobD+r+sfxCPJsiKBLQ==} + engines: {node: '>=12'} + dev: true + /is-wsl@2.2.0: resolution: {integrity: sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==} engines: {node: '>=8'} @@ -4032,6 +4443,10 @@ packages: is-docker: 2.2.1 dev: true + /isarray@0.0.1: + resolution: {integrity: sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==} + dev: true + /isarray@1.0.0: resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==} dev: true @@ -4148,6 +4563,13 @@ packages: engines: {'0': node >= 0.2.0} dev: true + /keygrip@1.1.0: + resolution: {integrity: sha512-iYSchDJ+liQ8iwbSI2QqsQOvqv58eJCEanyJPJi+Khyu8smkcKSFUCbPwzFcL7YVtZ6eONjqRX/38caJ7QjRAQ==} + engines: {node: '>= 0.6'} + dependencies: + tsscmp: 1.0.6 + dev: true + /kind-of@6.0.3: resolution: {integrity: sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==} engines: {node: '>=0.10.0'} @@ -4158,6 +4580,97 @@ packages: engines: {node: '>=6'} dev: true + /koa-compose@4.1.0: + resolution: {integrity: sha512-8ODW8TrDuMYvXRwra/Kh7/rJo9BtOfPc6qO8eAfC80CnCvSjSl0bkRM24X6/XBBEyj0v1nRUQ1LyOy3dbqOWXw==} + dev: true + + /koa-compress@5.1.1: + resolution: {integrity: sha512-UgMIN7ZoEP2DuoSQmD6CYvFSLt0NReGlc2qSY4bO4Oq0L56OiD9pDG41Kj/zFmVY/A3Wvmn4BqKcfq5H30LGIg==} + engines: {node: '>= 12'} + dependencies: + bytes: 3.1.2 + compressible: 2.0.18 + http-errors: 1.8.1 + koa-is-json: 1.0.0 + dev: true + + /koa-convert@2.0.0: + resolution: {integrity: sha512-asOvN6bFlSnxewce2e/DK3p4tltyfC4VM7ZwuTuepI7dEQVcvpyFuBcEARu1+Hxg8DIwytce2n7jrZtRlPrARA==} + engines: {node: '>= 10'} + dependencies: + co: 4.6.0 + koa-compose: 4.1.0 + dev: true + + /koa-is-json@1.0.0: + resolution: {integrity: sha512-+97CtHAlWDx0ndt0J8y3P12EWLwTLMXIfMnYDev3wOTwH/RpBGMlfn4bDXlMEg1u73K6XRE9BbUp+5ZAYoRYWw==} + dev: true + + /koa-proxies@0.12.3(koa@2.14.2): + resolution: {integrity: sha512-griAAVJbuzaGCt9H8RtLIsqcQhb5Q8uDPopQ6aK5DtRMvv6xb5SP/LEQ7Z8/bI1gAqd8n9WjMeT0c04I09ZAUg==} + peerDependencies: + koa: '>=2' + dependencies: + http-proxy: 1.18.1 + koa: 2.14.2 + path-match: 1.2.4 + uuid: 8.3.2 + transitivePeerDependencies: + - debug + dev: true + + /koa-send@5.0.1: + resolution: {integrity: sha512-tmcyQ/wXXuxpDxyNXv5yNNkdAMdFRqwtegBXUaowiQzUKqJehttS0x2j0eOZDQAyloAth5w6wwBImnFzkUz3pQ==} + engines: {node: '>= 8'} + dependencies: + debug: 4.3.4 + http-errors: 1.8.1 + resolve-path: 1.4.0 + transitivePeerDependencies: + - supports-color + dev: true + + /koa-static@5.0.0: + resolution: {integrity: sha512-UqyYyH5YEXaJrf9S8E23GoJFQZXkBVJ9zYYMPGz919MSX1KuvAcycIuS0ci150HCoPf4XQVhQ84Qf8xRPWxFaQ==} + engines: {node: '>= 7.6.0'} + dependencies: + debug: 3.2.7 + koa-send: 5.0.1 + transitivePeerDependencies: + - supports-color + dev: true + + /koa@2.14.2: + resolution: {integrity: sha512-VFI2bpJaodz6P7x2uyLiX6RLYpZmOJqNmoCst/Yyd7hQlszyPwG/I9CQJ63nOtKSxpt5M7NH67V6nJL2BwCl7g==} + engines: {node: ^4.8.4 || ^6.10.1 || ^7.10.1 || >= 8.1.4} + dependencies: + accepts: 1.3.8 + cache-content-type: 1.0.1 + content-disposition: 0.5.4 + content-type: 1.0.5 + cookies: 0.8.0 + debug: 4.3.4 + delegates: 1.0.0 + depd: 2.0.0 + destroy: 1.2.0 + encodeurl: 1.0.2 + escape-html: 1.0.3 + fresh: 0.5.2 + http-assert: 1.5.0 + http-errors: 1.6.3 + is-generator-function: 1.0.10 + koa-compose: 4.1.0 + koa-convert: 2.0.0 + on-finished: 2.4.1 + only: 0.0.2 + parseurl: 1.3.3 + statuses: 1.5.0 + type-is: 1.6.18 + vary: 1.1.2 + transitivePeerDependencies: + - supports-color + dev: true + /launch-editor@2.6.0: resolution: {integrity: sha512-JpDCcQnyAAzZZaZ7vEiSqL690w7dAEyLao+KC96zBplnYbJS7TYNjvM3M7y3dGz+v7aIsJk3hllWuc0kWAjyRQ==} dependencies: @@ -4275,6 +4788,10 @@ packages: p-locate: 5.0.0 dev: true + /lodash.debounce@4.0.8: + resolution: {integrity: sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==} + dev: true + /lodash.ismatch@4.4.0: resolution: {integrity: sha512-fPMfXjGQEV9Xsq/8MTSgUf255gawYRbjwMyDbcvDhXgV7enSZA0hynz6vMPnpAb5iONEzBHBPsT+0zes5Z301g==} dev: true @@ -4291,6 +4808,14 @@ packages: resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} dev: true + /log-symbols@4.1.0: + resolution: {integrity: sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==} + engines: {node: '>=10'} + dependencies: + chalk: 4.1.2 + is-unicode-supported: 0.1.0 + dev: true + /log-update@5.0.1: resolution: {integrity: sha512-5UtUDQ/6edw4ofyljDNcOVJQ4c7OjDro4h3y8e1GQL5iYElYclVHJ3zeWchylvMaKnDbDilC8irOVyexnA/Slw==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -4302,6 +4827,11 @@ packages: wrap-ansi: 8.1.0 dev: true + /loglevel@1.8.1: + resolution: {integrity: sha512-tCRIJM51SHjAayKwC+QAg8hT8vg6z7GSgLJKGvzuPb1Wc+hLzqtuVLxp6/HzSPOozuK+8ErAhy7U/sVzw8Dgfg==} + engines: {node: '>= 0.6.0'} + dev: true + /loupe@2.3.6: resolution: {integrity: sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==} dependencies: @@ -4538,6 +5068,11 @@ packages: thunky: 1.1.0 dev: true + /mute-stream@1.0.0: + resolution: {integrity: sha512-avsJQhyd+680gKXyG/sQc0nXaC6rBkPOfyHYcFb9+hdkqQkR9bdnkJ0AMZhke0oesPqIO+mFFJ+IdBc7mst4IA==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + dev: true + /mz@2.7.0: resolution: {integrity: sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==} dependencies: @@ -4670,6 +5205,10 @@ packages: mimic-fn: 4.0.0 dev: true + /only@0.0.2: + resolution: {integrity: sha512-Fvw+Jemq5fjjyWz6CpKx6w9s7xxqo3+JCyM0WXWeCSOboZ8ABkyvP8ID4CZuChA/wxSx+XSJmdOm8rGVyJ1hdQ==} + dev: true + /open@8.4.2: resolution: {integrity: sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==} engines: {node: '>=12'} @@ -4679,6 +5218,16 @@ packages: is-wsl: 2.2.0 dev: true + /open@9.1.0: + resolution: {integrity: sha512-OS+QTnw1/4vrf+9hh1jc1jnYjzSG4ttTBB8UxOwAnInG3Uo4ssetzC1ihqaIHjLJnA5GGlRl6QlZXOTQhRBUvg==} + engines: {node: '>=14.16'} + dependencies: + default-browser: 4.0.0 + define-lazy-prop: 3.0.0 + is-inside-container: 1.0.0 + is-wsl: 2.2.0 + dev: true + /opener@1.5.2: resolution: {integrity: sha512-ur5UIdyw5Y7yEj9wLzhqXiy6GZ3Mwx0yGI+5sMn2r0N0v3cKJvUmFH5yPP+WXh9e0xfyzyJX95D8l088DNFj7A==} hasBin: true @@ -4696,6 +5245,26 @@ packages: type-check: 0.4.0 dev: true + /ora@5.4.1: + resolution: {integrity: sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ==} + engines: {node: '>=10'} + dependencies: + bl: 4.1.0 + chalk: 4.1.2 + cli-cursor: 3.1.0 + cli-spinners: 2.9.1 + is-interactive: 1.0.0 + is-unicode-supported: 0.1.0 + log-symbols: 4.1.0 + strip-ansi: 6.0.1 + wcwidth: 1.0.1 + dev: true + + /os-tmpdir@1.0.2: + resolution: {integrity: sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==} + engines: {node: '>=0.10.0'} + dev: true + /p-limit@1.3.0: resolution: {integrity: sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==} engines: {node: '>=4'} @@ -4829,6 +5398,13 @@ packages: engines: {node: '>=12'} dev: true + /path-match@1.2.4: + resolution: {integrity: sha512-UWlehEdqu36jmh4h5CWJ7tARp1OEVKGHKm6+dg9qMq5RKUTV5WJrGgaZ3dN2m7WFAXDbjlHzvJvL/IUpy84Ktw==} + dependencies: + http-errors: 1.4.0 + path-to-regexp: 1.8.0 + dev: true + /path-parse@1.0.7: resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} dev: true @@ -4837,6 +5413,12 @@ packages: resolution: {integrity: sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==} dev: true + /path-to-regexp@1.8.0: + resolution: {integrity: sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==} + dependencies: + isarray: 0.0.1 + dev: true + /path-type@3.0.0: resolution: {integrity: sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==} engines: {node: '>=4'} @@ -5164,6 +5746,14 @@ packages: engines: {node: '>=8'} dev: true + /resolve-path@1.4.0: + resolution: {integrity: sha512-i1xevIst/Qa+nA9olDxLWnLk8YZbi8R/7JPbCMcgyWaFR6bKWaexgJgEB5oc2PKMjYdrHynyz0NY+if+H98t1w==} + engines: {node: '>= 0.8'} + dependencies: + http-errors: 1.6.3 + path-is-absolute: 1.0.1 + dev: true + /resolve-pkg-maps@1.0.0: resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==} dev: true @@ -5177,6 +5767,14 @@ packages: supports-preserve-symlinks-flag: 1.0.0 dev: true + /restore-cursor@3.1.0: + resolution: {integrity: sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==} + engines: {node: '>=8'} + dependencies: + onetime: 5.1.2 + signal-exit: 3.0.7 + dev: true + /restore-cursor@4.0.0: resolution: {integrity: sha512-I9fPXU9geO9bHOt9pHHOhOkYerIMsmVaWB0rA2AI9ERh/+x/i7MV5HKBNrg+ljO5eoPVgCcnFuRjJ9uH6I/3eg==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -5214,12 +5812,30 @@ packages: fsevents: 2.3.2 dev: true + /run-applescript@5.0.0: + resolution: {integrity: sha512-XcT5rBksx1QdIhlFOCtgZkB99ZEouFZ1E2Kc2LHqNW13U3/74YGdkQRmThTwxy4QIyookibDKYZOPqX//6BlAg==} + engines: {node: '>=12'} + dependencies: + execa: 5.1.1 + dev: true + + /run-async@3.0.0: + resolution: {integrity: sha512-540WwVDOMxA6dN6We19EcT9sc3hkXPw5mzRNGM3FkdN/vtE9NFvj5lFAPNwUDmJjXidm3v7TC1cTE7t17Ulm1Q==} + engines: {node: '>=0.12.0'} + dev: true + /run-parallel@1.2.0: resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} dependencies: queue-microtask: 1.2.3 dev: true + /rxjs@7.8.1: + resolution: {integrity: sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==} + dependencies: + tslib: 2.5.0 + dev: true + /safe-buffer@5.1.2: resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==} dev: true @@ -5396,6 +6012,15 @@ packages: totalist: 1.1.0 dev: true + /sirv@2.0.3: + resolution: {integrity: sha512-O9jm9BsID1P+0HOi81VpXPoDxYP374pkOLzACAoyUQ/3OUVndNpsz6wMnY2z+yOxzbllCKZrM+9QrWsv4THnyA==} + engines: {node: '>= 10'} + dependencies: + '@polka/url': 1.0.0-next.21 + mrmime: 1.0.1 + totalist: 3.0.1 + dev: true + /sisteransi@1.0.5: resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} dev: true @@ -5811,6 +6436,18 @@ packages: engines: {node: '>=14.0.0'} dev: true + /titleize@3.0.0: + resolution: {integrity: sha512-KxVu8EYHDPBdUYdKZdKtU2aj2XfEx9AfjXxE/Aj0vT06w2icA09Vus1rh6eSu1y01akYg6BjIK/hxyLJINoMLQ==} + engines: {node: '>=12'} + dev: true + + /tmp@0.0.33: + resolution: {integrity: sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==} + engines: {node: '>=0.6.0'} + dependencies: + os-tmpdir: 1.0.2 + dev: true + /to-regex-range@5.0.1: resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} engines: {node: '>=8.0'} @@ -5827,6 +6464,11 @@ packages: engines: {node: '>=6'} dev: true + /totalist@3.0.1: + resolution: {integrity: sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==} + engines: {node: '>=6'} + dev: true + /tr46@1.0.1: resolution: {integrity: sha512-dTpowEjclQ7Kgx5SdBkqRzVhERQXov8/l9Ft9dVM9fmg0W0KQSVaXX9T4i6twCPNtYiZM53lpSSUAwJbFPOHxA==} dependencies: @@ -5864,6 +6506,11 @@ packages: resolution: {integrity: sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==} dev: true + /tsscmp@1.0.6: + resolution: {integrity: sha512-LxhtAkPDTkVCMQjt2h6eBVY28KCjikZqZfMcC15YBeNjkgUpdCfBu5HoiOTDu86v6smE8yOjyEktJ8hlbANHQA==} + engines: {node: '>=0.6.x'} + dev: true + /tsup@7.2.0(typescript@5.2.2): resolution: {integrity: sha512-vDHlczXbgUvY3rWvqFEbSqmC1L7woozbzngMqTtL2PGBODTtWlRwGDDawhvWzr5c1QjKe4OAKqJGfE1xeXUvtQ==} engines: {node: '>=16.14'} @@ -5952,6 +6599,11 @@ packages: engines: {node: '>=10'} dev: true + /type-fest@2.19.0: + resolution: {integrity: sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==} + engines: {node: '>=12.20'} + dev: true + /type-is@1.6.18: resolution: {integrity: sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==} engines: {node: '>= 0.6'} @@ -5994,6 +6646,11 @@ packages: engines: {node: '>= 0.8'} dev: true + /untildify@4.0.0: + resolution: {integrity: sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==} + engines: {node: '>=8'} + dev: true + /update-browserslist-db@1.0.10(browserslist@4.21.5): resolution: {integrity: sha512-OztqDenkfFkbSG+tRxBeAnCVPckDBcvibKd35yDONx6OU8N7sqgwc7rCbkJ/WcYtVRZ4ba68d6byhC21GFh7sQ==} hasBin: true @@ -6194,6 +6851,11 @@ packages: - supports-color dev: true + /walkdir@0.4.1: + resolution: {integrity: sha512-3eBwRyEln6E1MSzcxcVpQIhRG8Q1jLvEqRmCZqS3dsfXEDR/AhOF4d+jHg1qvDCpYaVRZjENPQyrVxAkQqxPgQ==} + engines: {node: '>=6.0.0'} + dev: true + /watchpack@2.4.0: resolution: {integrity: sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg==} engines: {node: '>=10.13.0'} @@ -6208,6 +6870,12 @@ packages: minimalistic-assert: 1.0.1 dev: true + /wcwidth@1.0.1: + resolution: {integrity: sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==} + dependencies: + defaults: 1.0.4 + dev: true + /webidl-conversions@4.0.2: resolution: {integrity: sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==} dev: true @@ -6498,6 +7166,13 @@ packages: stackback: 0.0.2 dev: true + /widest-line@4.0.1: + resolution: {integrity: sha512-o0cyEG0e8GPzT4iGHphIOh0cJOV8fivsXxddQasHPHfoZf1ZexrfeA21w2NaEN1RHE+fXlfISmOE8R9N3u3Qig==} + engines: {node: '>=12'} + dependencies: + string-width: 5.1.2 + dev: true + /wildcard@2.0.0: resolution: {integrity: sha512-JcKqAHLPxcdb9KM49dufGXn2x3ssnfjbcaQdLlfZsL9rH9wgDQjUtDxbo8NE0F6SFvydeu1VhZe7hZuHsB2/pw==} dev: true @@ -6506,6 +7181,15 @@ packages: resolution: {integrity: sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==} dev: true + /wrap-ansi@6.2.0: + resolution: {integrity: sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==} + engines: {node: '>=8'} + dependencies: + ansi-styles: 4.3.0 + string-width: 4.2.3 + strip-ansi: 6.0.1 + dev: true + /wrap-ansi@7.0.0: resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} engines: {node: '>=10'} @@ -6636,6 +7320,11 @@ packages: yargs-parser: 21.1.1 dev: true + /ylru@1.3.2: + resolution: {integrity: sha512-RXRJzMiK6U2ye0BlGGZnmpwJDPgakn6aNQ0A7gHRbD4I0uvK4TW6UqkK1V0pp9jskjJBAXd3dRrbzWkqJ+6cxA==} + engines: {node: '>= 4.0.0'} + dev: true + /yocto-queue@0.1.0: resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} engines: {node: '>=10'} @@ -6655,6 +7344,15 @@ packages: zod: 3.21.4 dev: true + /zod-validation-error@1.5.0(zod@3.21.4): + resolution: {integrity: sha512-/7eFkAI4qV0tcxMBB/3+d2c1P6jzzZYdYSlBuAklzMuCrJu5bzJfHS0yVAS87dRHVlhftd6RFJDIvv03JgkSbw==} + engines: {node: '>=16.0.0'} + peerDependencies: + zod: ^3.18.0 + dependencies: + zod: 3.21.4 + dev: true + /zod@3.21.4: resolution: {integrity: sha512-m46AKbrzKVzOzs/DZgVnG5H55N1sv1M8qZU3A8RIKbs3mrACDNeIOeilDymVb2HdmP8uwshOCF4uJ8uM9rCqJw==} dev: true diff --git a/scripts/buildFixtures.ts b/scripts/buildFixtures.ts index a9c9b15b..7684422f 100644 --- a/scripts/buildFixtures.ts +++ b/scripts/buildFixtures.ts @@ -39,6 +39,10 @@ async function run() { execSync('npx @rspack/cli --version', { cwd: path, stdio: 'inherit' }) execSync('npx @rspack/cli', { cwd: path, stdio: 'inherit' }) } + + console.log(c.magenta(c.inverse(c.bold('\n Farm '))), name, '\n') + execSync('npx farm --version', { cwd: path, stdio: 'inherit' }) + execSync('npx farm build', { cwd: path, stdio: 'inherit' }) } } diff --git a/src/define.ts b/src/define.ts index 4b7e73cf..61039036 100644 --- a/src/define.ts +++ b/src/define.ts @@ -1,4 +1,5 @@ import { getEsbuildPlugin } from './esbuild' +import { getFarmPlugin } from './farm' import { getRollupPlugin } from './rollup' import { getRspackPlugin } from './rspack' import type { UnpluginFactory, UnpluginInstance } from './types' @@ -25,6 +26,10 @@ export function createUnplugin( get rspack() { return getRspackPlugin(factory) }, + /** @experimental do not use it in production */ + get farm() { + return getFarmPlugin(factory) + }, get raw() { return factory }, diff --git a/src/farm/index.ts b/src/farm/index.ts new file mode 100644 index 00000000..b92caa4c --- /dev/null +++ b/src/farm/index.ts @@ -0,0 +1,61 @@ +import type { + RollupPlugin, + UnpluginContextMeta, + UnpluginFactory, + UnpluginInstance, + UnpluginOptions, +} from '../types' +import { toArray } from '../utils' + +export function getFarmPlugin< + UserOptions = Record, + Nested extends boolean = boolean, +>(factory: UnpluginFactory) { + return ((userOptions?: UserOptions) => { + const meta: UnpluginContextMeta = { + framework: 'farm', + } + const rawPlugins = toArray(factory(userOptions!, meta)) + + const plugins = rawPlugins.map(plugin => toFarmPlugin(plugin)) + return plugins.length === 1 ? plugins[0] : plugins + }) as UnpluginInstance['rollup'] +} + +export function toFarmPlugin( + plugin: UnpluginOptions, + containRollupOptions = true, +): RollupPlugin { + if (plugin.transform && plugin.transformInclude) { + const _transform = plugin.transform + plugin.transform = function (code, id) { + if (plugin.transformInclude && !plugin.transformInclude(id)) + return null + + return _transform.call(this, code, id) + } + } + + if (plugin.load && plugin.loadInclude) { + const _load = plugin.load + plugin.load = function (id) { + if (plugin.loadInclude && !plugin.loadInclude(id)) + return null + + return _load.call(this, id) + } + } + + if (plugin.rollup && containRollupOptions) + Object.assign(plugin, plugin.rollup) + + return plugin +} + +/** + * v1.0.0 beta + * 1. 增量构建 + * 2. 重构 resolver + * 3. 接入一些 js 生态 (unplugin) + * 4. 重构 node 流程 规范化 + */ diff --git a/src/types.ts b/src/types.ts index b3a3bea6..b11479fd 100644 --- a/src/types.ts +++ b/src/types.ts @@ -99,6 +99,7 @@ export interface UnpluginInstance vite: UnpluginFactoryOutput : VitePlugin> webpack: UnpluginFactoryOutput rspack: UnpluginFactoryOutput + farm: UnpluginFactoryOutput : RollupPlugin> esbuild: UnpluginFactoryOutput raw: UnpluginFactory } @@ -120,6 +121,8 @@ export type UnpluginContextMeta = Partial & ({ rspack: { compiler: RspackCompiler } +} | { + framework: 'farm' }) export interface UnpluginContext { diff --git a/test/fixtures/load/__test__/build.test.ts b/test/fixtures/load/__test__/build.test.ts index 1388a59c..daedc0bf 100644 --- a/test/fixtures/load/__test__/build.test.ts +++ b/test/fixtures/load/__test__/build.test.ts @@ -32,4 +32,10 @@ describe('load-called-before-transform', () => { expect(content).toContain('it is a msg -> through the load hook -> transform-[Injected Rspack]') }) + + it('farm', async () => { + const content = await fs.readFile(r('farm/main.js'), 'utf-8') + + expect(content).toContain('it is a msg -> through the load hook -> transform-[Injected Esbuild]') + }) }) diff --git a/test/fixtures/load/farm.config.js b/test/fixtures/load/farm.config.js new file mode 100644 index 00000000..cb0f5785 --- /dev/null +++ b/test/fixtures/load/farm.config.js @@ -0,0 +1,34 @@ +const { builtinModules } = require('module') +const { farm } = require('./unplugin') + +/** + * @type {import('@farmfe/core').UserConfig} + */ +module.exports = { + compilation: { + input: { + index: './src/main.js', + }, + output: { + path: './dist/farm', + targetEnv: 'node', + format: 'cjs', + }, + external: [ + ...builtinModules.map(m => `^${m}$`), + ...builtinModules.map(m => `^node:${m}$`), + ], + partialBundling: { + moduleBuckets: [ + { + name: 'node.bundle.js', + test: ['.+'], + }, + ], + }, + presetEnv: false, + }, + plugins: [ + farm({ msg: 'Farm' }), + ], +} From debf59f7f2f7f350c150a32cfa84c555d081a490 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Tue, 19 Sep 2023 17:48:37 +0800 Subject: [PATCH 02/58] chore: update code --- src/farm/index.ts | 48 ++++++++++++++++++++++--------- test/fixtures/load/farm.config.js | 3 ++ 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/src/farm/index.ts b/src/farm/index.ts index b92caa4c..8db66e75 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -22,32 +22,51 @@ export function getFarmPlugin< }) as UnpluginInstance['rollup'] } -export function toFarmPlugin( - plugin: UnpluginOptions, - containRollupOptions = true, -): RollupPlugin { +export function toFarmPlugin(plugin: UnpluginOptions): RollupPlugin { + // 根据loadInclude 出来的结果,决定在 load 中执行的 id if (plugin.transform && plugin.transformInclude) { + // const _transform = plugin.transform + // plugin.transform = function (code, id) { + // if (plugin.transformInclude && !plugin.transformInclude(id)) + // return null + + // return _transform.call(this, code, id) + // } const _transform = plugin.transform - plugin.transform = function (code, id) { - if (plugin.transformInclude && !plugin.transformInclude(id)) - return null + plugin.transform = { + filters: { resolvedPaths: [] }, + executor(params) { + if (plugin.transformInclude && !plugin.transformInclude(id)) + return null - return _transform.call(this, code, id) + return _transform.call(this, params.content, params.resolvedPath) + }, } } if (plugin.load && plugin.loadInclude) { const _load = plugin.load - plugin.load = function (id) { - if (plugin.loadInclude && !plugin.loadInclude(id)) - return null + // plugin.load = function (id) { + // console.log(id); + // if (plugin.loadInclude && !plugin.loadInclude(id)) + // return null - return _load.call(this, id) + // return _load.call(this, id) + // } + plugin.load = { + filters: { + resolvedPaths: [], + }, + executor(id) { + return _load.call(this, id) + }, } } + delete plugin.transformInclude + delete plugin.loadInclude - if (plugin.rollup && containRollupOptions) - Object.assign(plugin, plugin.rollup) + // if (plugin.rollup && containRollupOptions) + // Object.assign(plugin, plugin.rollup) return plugin } @@ -58,4 +77,5 @@ export function toFarmPlugin( * 2. 重构 resolver * 3. 接入一些 js 生态 (unplugin) * 4. 重构 node 流程 规范化 + * 5. 感觉还可以接一下 fervid 的 vue compiler */ diff --git a/test/fixtures/load/farm.config.js b/test/fixtures/load/farm.config.js index cb0f5785..ebd5f87b 100644 --- a/test/fixtures/load/farm.config.js +++ b/test/fixtures/load/farm.config.js @@ -31,4 +31,7 @@ module.exports = { plugins: [ farm({ msg: 'Farm' }), ], + server: { + hmr: false, + }, } From 11714f399c90588ebf7971bcae2027e7dd7be1ba Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Tue, 19 Sep 2023 18:23:02 +0800 Subject: [PATCH 03/58] chore: update sourcemap --- src/farm/index.ts | 19 +++++++++++++++---- test/fixtures/load/unplugin.js | 2 -- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/farm/index.ts b/src/farm/index.ts index 8db66e75..0635503d 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -32,14 +32,21 @@ export function toFarmPlugin(plugin: UnpluginOptions): RollupPlugin { // return _transform.call(this, code, id) // } + // TODO: resolvePath const _transform = plugin.transform plugin.transform = { - filters: { resolvedPaths: [] }, + filters: { resolvedPaths: ['msg.js$'] }, executor(params) { if (plugin.transformInclude && !plugin.transformInclude(id)) return null - return _transform.call(this, params.content, params.resolvedPath) + const res = _transform(params.content, params.resolvedPath) + + return { + content: res.code, + moduleType: 'js', + sourceMap: res.map.mappings, + } }, } } @@ -55,10 +62,14 @@ export function toFarmPlugin(plugin: UnpluginOptions): RollupPlugin { // } plugin.load = { filters: { - resolvedPaths: [], + resolvedPaths: ['msg.js$'], }, executor(id) { - return _load.call(this, id) + const res = _load(id.resolvedPath) + return { + content: res, + moduleType: 'js', + } }, } } diff --git a/test/fixtures/load/unplugin.js b/test/fixtures/load/unplugin.js index f8055002..3e447ebe 100644 --- a/test/fixtures/load/unplugin.js +++ b/test/fixtures/load/unplugin.js @@ -14,7 +14,6 @@ module.exports = createUnplugin((options) => { const str = new MagicString(code) const _index = code.indexOf('msg') const loadInjectedCode = 'msg -> through the load hook -> __unplugin__' - str.overwrite(_index, _index + 'msg'.length, loadInjectedCode) return str.toString() }, @@ -26,7 +25,6 @@ module.exports = createUnplugin((options) => { const index = code.indexOf('__unplugin__') if (index === -1) return null - const injectedCode = `transform-[Injected ${options.msg}]` if (code.includes(injectedCode)) From 72838c6022cede836a4f38fd906f1015a925ee2a Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Tue, 19 Sep 2023 20:41:16 +0800 Subject: [PATCH 04/58] chore: update code --- src/farm/index.ts | 5 ++-- src/types.ts | 1 + test/fixtures/transform/farm.config.js | 37 ++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 test/fixtures/transform/farm.config.js diff --git a/src/farm/index.ts b/src/farm/index.ts index 0635503d..c9d94b5c 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -8,8 +8,7 @@ import type { import { toArray } from '../utils' export function getFarmPlugin< - UserOptions = Record, - Nested extends boolean = boolean, + UserOptions = Record, Nested extends boolean = boolean, >(factory: UnpluginFactory) { return ((userOptions?: UserOptions) => { const meta: UnpluginContextMeta = { @@ -45,7 +44,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): RollupPlugin { return { content: res.code, moduleType: 'js', - sourceMap: res.map.mappings, + sourceMap: JSON.stringify(res.map), } }, } diff --git a/src/types.ts b/src/types.ts index b11479fd..9868787f 100644 --- a/src/types.ts +++ b/src/types.ts @@ -77,6 +77,7 @@ export interface UnpluginOptions { setup?: EsbuildPlugin['setup'] loader?: Loader | ((code: string, id: string) => Loader) } + farm?: any } export interface ResolvedUnpluginOptions extends UnpluginOptions { diff --git a/test/fixtures/transform/farm.config.js b/test/fixtures/transform/farm.config.js new file mode 100644 index 00000000..ebd5f87b --- /dev/null +++ b/test/fixtures/transform/farm.config.js @@ -0,0 +1,37 @@ +const { builtinModules } = require('module') +const { farm } = require('./unplugin') + +/** + * @type {import('@farmfe/core').UserConfig} + */ +module.exports = { + compilation: { + input: { + index: './src/main.js', + }, + output: { + path: './dist/farm', + targetEnv: 'node', + format: 'cjs', + }, + external: [ + ...builtinModules.map(m => `^${m}$`), + ...builtinModules.map(m => `^node:${m}$`), + ], + partialBundling: { + moduleBuckets: [ + { + name: 'node.bundle.js', + test: ['.+'], + }, + ], + }, + presetEnv: false, + }, + plugins: [ + farm({ msg: 'Farm' }), + ], + server: { + hmr: false, + }, +} From f87e54a7ad74970ac6b838f9c85ad589b27dad45 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Tue, 19 Sep 2023 20:47:05 +0800 Subject: [PATCH 05/58] chore: update code --- test/fixtures/load/__test__/build.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/fixtures/load/__test__/build.test.ts b/test/fixtures/load/__test__/build.test.ts index daedc0bf..70371218 100644 --- a/test/fixtures/load/__test__/build.test.ts +++ b/test/fixtures/load/__test__/build.test.ts @@ -34,8 +34,8 @@ describe('load-called-before-transform', () => { }) it('farm', async () => { - const content = await fs.readFile(r('farm/main.js'), 'utf-8') + const content = await fs.readFile(r('farm/index.js'), 'utf-8') - expect(content).toContain('it is a msg -> through the load hook -> transform-[Injected Esbuild]') + expect(content).toContain('it is a msg -> through the load hook -> transform-[Injected Farm]') }) }) From 7c5ee4e54b31d1a032cf98ceaa209101939ff8f5 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Wed, 20 Sep 2023 09:26:32 +0800 Subject: [PATCH 06/58] chore: use all filters --- src/farm/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/farm/index.ts b/src/farm/index.ts index 0635503d..26bfa2f9 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -35,7 +35,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): RollupPlugin { // TODO: resolvePath const _transform = plugin.transform plugin.transform = { - filters: { resolvedPaths: ['msg.js$'] }, + filters: { resolvedPaths: ['.*$'] }, executor(params) { if (plugin.transformInclude && !plugin.transformInclude(id)) return null @@ -62,7 +62,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): RollupPlugin { // } plugin.load = { filters: { - resolvedPaths: ['msg.js$'], + resolvedPaths: ['.*$'], }, executor(id) { const res = _load(id.resolvedPath) From a8f8234dfbbc7d9c7ab58515a1bba8476b302d8d Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Wed, 20 Sep 2023 10:14:36 +0800 Subject: [PATCH 07/58] chore: update code --- src/farm/index.ts | 45 +++++++++++++++++++++++++++------------------ src/farm/utils.ts | 23 +++++++++++++++++++++++ 2 files changed, 50 insertions(+), 18 deletions(-) create mode 100644 src/farm/utils.ts diff --git a/src/farm/index.ts b/src/farm/index.ts index f08beba5..a28c60a8 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -6,9 +6,11 @@ import type { UnpluginOptions, } from '../types' import { toArray } from '../utils' +import { guessIdLoader } from './utils' export function getFarmPlugin< - UserOptions = Record, Nested extends boolean = boolean, + UserOptions = Record, + Nested extends boolean = boolean, >(factory: UnpluginFactory) { return ((userOptions?: UserOptions) => { const meta: UnpluginContextMeta = { @@ -22,7 +24,6 @@ export function getFarmPlugin< } export function toFarmPlugin(plugin: UnpluginOptions): RollupPlugin { - // 根据loadInclude 出来的结果,决定在 load 中执行的 id if (plugin.transform && plugin.transformInclude) { // const _transform = plugin.transform // plugin.transform = function (code, id) { @@ -34,17 +35,22 @@ export function toFarmPlugin(plugin: UnpluginOptions): RollupPlugin { // TODO: resolvePath const _transform = plugin.transform plugin.transform = { - filters: { resolvedPaths: ['.*$'] }, + filters: { resolvedPaths: ['.*'] }, executor(params) { - if (plugin.transformInclude && !plugin.transformInclude(id)) + const loader = guessIdLoader(params.resolvedPath) + if ( + plugin.transformInclude + && !plugin.transformInclude(params.resolvedPath) + ) return null + if (plugin.transformInclude(params.resolvedPath)) { + const resource = _transform(params.content, params.resolvedPath) - const res = _transform(params.content, params.resolvedPath) - - return { - content: res.code, - moduleType: 'js', - sourceMap: JSON.stringify(res.map), + return { + content: resource.code, + moduleType: loader, + sourceMap: JSON.stringify(resource.map), + } } }, } @@ -53,7 +59,6 @@ export function toFarmPlugin(plugin: UnpluginOptions): RollupPlugin { if (plugin.load && plugin.loadInclude) { const _load = plugin.load // plugin.load = function (id) { - // console.log(id); // if (plugin.loadInclude && !plugin.loadInclude(id)) // return null @@ -61,19 +66,23 @@ export function toFarmPlugin(plugin: UnpluginOptions): RollupPlugin { // } plugin.load = { filters: { - resolvedPaths: ['.*$'], + resolvedPaths: ['.*'], }, executor(id) { - const res = _load(id.resolvedPath) - return { - content: res, - moduleType: 'js', + const loader = guessIdLoader(id.resolvedPath) + if (plugin.loadInclude(id.resolvedPath)) { + const content = _load(id.resolvedPath) + + return { + content, + moduleType: loader, + } } }, } } - delete plugin.transformInclude - delete plugin.loadInclude + // delete plugin.transformInclude + // delete plugin.loadInclude // if (plugin.rollup && containRollupOptions) // Object.assign(plugin, plugin.rollup) diff --git a/src/farm/utils.ts b/src/farm/utils.ts new file mode 100644 index 00000000..1d7d3222 --- /dev/null +++ b/src/farm/utils.ts @@ -0,0 +1,23 @@ +import path from 'node:path' + +export * from '../utils' + +const ExtToLoader: Record = { + '.js': 'js', + '.mjs': 'js', + '.cjs': 'js', + '.jsx': 'jsx', + '.ts': 'ts', + '.cts': 'ts', + '.mts': 'ts', + '.tsx': 'tsx', + '.json': 'json', + '.toml': 'toml', + '.wasm': 'wasm', + '.napi': 'napi', + '.node': 'napi', +} + +export function guessIdLoader(id: string): string { + return ExtToLoader[path.extname(id).toLowerCase()] || 'js' +} From 77514fe95c6cc101f66502ba683446d2d766b7f3 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Wed, 20 Sep 2023 10:21:29 +0800 Subject: [PATCH 08/58] chore: update code --- src/farm/index.ts | 1 - test/fixtures/transform/unplugin.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/farm/index.ts b/src/farm/index.ts index a28c60a8..118226b9 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -17,7 +17,6 @@ export function getFarmPlugin< framework: 'farm', } const rawPlugins = toArray(factory(userOptions!, meta)) - const plugins = rawPlugins.map(plugin => toFarmPlugin(plugin)) return plugins.length === 1 ? plugins[0] : plugins }) as UnpluginInstance['rollup'] diff --git a/test/fixtures/transform/unplugin.js b/test/fixtures/transform/unplugin.js index a014daca..986115b8 100644 --- a/test/fixtures/transform/unplugin.js +++ b/test/fixtures/transform/unplugin.js @@ -29,7 +29,7 @@ module.exports = createUnplugin((options, meta) => { throw new Error('File was already transformed') s.overwrite(index, index + '__UNPLUGIN__'.length, injectedCode) - + console.log(s.toString()) return { code: s.toString(), map: s.generateMap({ From 7f42bfcb260fcd88397dee7c06f009bcb31abbf2 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Wed, 20 Sep 2023 14:21:12 +0800 Subject: [PATCH 09/58] chore: update code --- scripts/buildFixtures.ts | 13 +++++++++---- src/farm/index.ts | 10 ++++++++++ test/fixtures/transform/__test__/build.test.ts | 8 ++++++++ test/fixtures/transform/farm.config.js | 1 + test/fixtures/transform/unplugin.js | 2 -- 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/scripts/buildFixtures.ts b/scripts/buildFixtures.ts index 7684422f..4cd21600 100644 --- a/scripts/buildFixtures.ts +++ b/scripts/buildFixtures.ts @@ -24,7 +24,10 @@ async function run() { console.log(c.red(c.inverse(c.bold('\n Rollup '))), name, '\n') execSync('npx rollup --version', { cwd: path, stdio: 'inherit' }) - execSync('npx rollup --bundleConfigAsCjs -c', { cwd: path, stdio: 'inherit' }) + execSync('npx rollup --bundleConfigAsCjs -c', { + cwd: path, + stdio: 'inherit', + }) console.log(c.blue(c.inverse(c.bold('\n Webpack '))), name, '\n') execSync('npx webpack --version', { cwd: path, stdio: 'inherit' }) @@ -40,9 +43,11 @@ async function run() { execSync('npx @rspack/cli', { cwd: path, stdio: 'inherit' }) } - console.log(c.magenta(c.inverse(c.bold('\n Farm '))), name, '\n') - execSync('npx farm --version', { cwd: path, stdio: 'inherit' }) - execSync('npx farm build', { cwd: path, stdio: 'inherit' }) + if (name !== 'virtual-module') { + console.log(c.magenta(c.inverse(c.bold('\n Farm '))), name, '\n') + execSync('npx farm --version', { cwd: path, stdio: 'inherit' }) + execSync('npx farm build', { cwd: path, stdio: 'inherit' }) + } } } diff --git a/src/farm/index.ts b/src/farm/index.ts index 118226b9..0cca80d9 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -1,3 +1,4 @@ +import * as querystring from 'node:querystring' import type { RollupPlugin, UnpluginContextMeta, @@ -36,6 +37,14 @@ export function toFarmPlugin(plugin: UnpluginOptions): RollupPlugin { plugin.transform = { filters: { resolvedPaths: ['.*'] }, executor(params) { + if (params.query.length) { + const queryParamsObject = {} + params.query.forEach(([param, value]) => { + queryParamsObject[param] = value + }) + const transformQuery = querystring.stringify(queryParamsObject) + params.resolvedPath = `${params.resolvedPath}?${transformQuery}` + } const loader = guessIdLoader(params.resolvedPath) if ( plugin.transformInclude @@ -96,4 +105,5 @@ export function toFarmPlugin(plugin: UnpluginOptions): RollupPlugin { * 3. 接入一些 js 生态 (unplugin) * 4. 重构 node 流程 规范化 * 5. 感觉还可以接一下 fervid 的 vue compiler + * 6. 用户DX 热更新报错白屏 */ diff --git a/test/fixtures/transform/__test__/build.test.ts b/test/fixtures/transform/__test__/build.test.ts index c05ee7a2..478001fa 100644 --- a/test/fixtures/transform/__test__/build.test.ts +++ b/test/fixtures/transform/__test__/build.test.ts @@ -45,4 +45,12 @@ describe('transform build', () => { expect(content).toContain('TARGET: [Injected Post Rspack]') expect(content).toContain('QUERY: [Injected Post Rspack]') }) + + it('farm', async () => { + const content = await fs.readFile(r('farm/main.js'), 'utf-8') + + expect(content).toContain('NON-TARGET: __UNPLUGIN__') + expect(content).toContain('TARGET: [Injected Post Farm]') + expect(content).toContain('QUERY: [Injected Post Farm]') + }) }) diff --git a/test/fixtures/transform/farm.config.js b/test/fixtures/transform/farm.config.js index ebd5f87b..3248438b 100644 --- a/test/fixtures/transform/farm.config.js +++ b/test/fixtures/transform/farm.config.js @@ -11,6 +11,7 @@ module.exports = { }, output: { path: './dist/farm', + entryFilename: 'main.[ext]', targetEnv: 'node', format: 'cjs', }, diff --git a/test/fixtures/transform/unplugin.js b/test/fixtures/transform/unplugin.js index 986115b8..ad352fb6 100644 --- a/test/fixtures/transform/unplugin.js +++ b/test/fixtures/transform/unplugin.js @@ -24,12 +24,10 @@ module.exports = createUnplugin((options, meta) => { return null const injectedCode = `[Injected ${options.msg}]` - if (id.includes(injectedCode)) throw new Error('File was already transformed') s.overwrite(index, index + '__UNPLUGIN__'.length, injectedCode) - console.log(s.toString()) return { code: s.toString(), map: s.generateMap({ From 857c7d8f6bcb7fa80c94d1c4fd3296bea7160224 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Wed, 20 Sep 2023 14:58:28 +0800 Subject: [PATCH 10/58] chore: update code --- src/farm/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/farm/index.ts b/src/farm/index.ts index 0cca80d9..de1f9fc3 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -103,7 +103,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): RollupPlugin { * 1. 增量构建 * 2. 重构 resolver * 3. 接入一些 js 生态 (unplugin) - * 4. 重构 node 流程 规范化 - * 5. 感觉还可以接一下 fervid 的 vue compiler - * 6. 用户DX 热更新报错白屏 + * 4. 重构 node 规范化基础配置流程 不重要! + * 5. 接 fervid 的 vue compiler 不重要! + * 6. 用户DX 修复一些体验 bug e.g: 热更新报错白屏 */ From f2a99a05ba96b9c850624b25cfc07d35ff46a79a Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Wed, 20 Sep 2023 17:06:30 +0800 Subject: [PATCH 11/58] chore: update code --- src/farm/index.ts | 100 +++++++++++++++++++++------------------------- src/farm/utils.ts | 10 +++++ 2 files changed, 56 insertions(+), 54 deletions(-) diff --git a/src/farm/index.ts b/src/farm/index.ts index de1f9fc3..23c51ba1 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -1,4 +1,3 @@ -import * as querystring from 'node:querystring' import type { RollupPlugin, UnpluginContextMeta, @@ -7,7 +6,7 @@ import type { UnpluginOptions, } from '../types' import { toArray } from '../utils' -import { guessIdLoader } from './utils' +import { guessIdLoader, transformQuery } from './utils' export function getFarmPlugin< UserOptions = Record, @@ -24,76 +23,69 @@ export function getFarmPlugin< } export function toFarmPlugin(plugin: UnpluginOptions): RollupPlugin { - if (plugin.transform && plugin.transformInclude) { - // const _transform = plugin.transform - // plugin.transform = function (code, id) { - // if (plugin.transformInclude && !plugin.transformInclude(id)) - // return null + if (plugin.load) { + const _load: any = plugin.load + plugin.load = { + filters: { + resolvedPaths: ['.*'], + }, + executor(id: any) { + if (plugin.loadInclude && !plugin.loadInclude(id.resolvedPath)) + return null + const loader = guessIdLoader(id.resolvedPath) + const shouldLoadInclude + = plugin.loadInclude && plugin.loadInclude(id.resolvedPath) + const content = _load(id.resolvedPath) - // return _transform.call(this, code, id) - // } - // TODO: resolvePath - const _transform = plugin.transform + if (shouldLoadInclude) { + return { + content, + moduleType: loader, + } + } + + return { + content, + moduleType: loader, + } + }, + } as any + } + + if (plugin.transform) { + const _transform: any = plugin.transform plugin.transform = { filters: { resolvedPaths: ['.*'] }, - executor(params) { - if (params.query.length) { - const queryParamsObject = {} - params.query.forEach(([param, value]) => { - queryParamsObject[param] = value - }) - const transformQuery = querystring.stringify(queryParamsObject) - params.resolvedPath = `${params.resolvedPath}?${transformQuery}` - } - const loader = guessIdLoader(params.resolvedPath) + executor(params: any) { + if (params.query.length) + transformQuery(params) + if ( plugin.transformInclude && !plugin.transformInclude(params.resolvedPath) ) return null - if (plugin.transformInclude(params.resolvedPath)) { - const resource = _transform(params.content, params.resolvedPath) + const loader = guessIdLoader(params.resolvedPath) + const shouldTransformInclude + = plugin.transformInclude + && plugin.transformInclude(params.resolvedPath) + const resource: any = _transform(params.content, params.resolvedPath) + if (shouldTransformInclude) { return { content: resource.code, moduleType: loader, sourceMap: JSON.stringify(resource.map), } } - }, - } - } - - if (plugin.load && plugin.loadInclude) { - const _load = plugin.load - // plugin.load = function (id) { - // if (plugin.loadInclude && !plugin.loadInclude(id)) - // return null - - // return _load.call(this, id) - // } - plugin.load = { - filters: { - resolvedPaths: ['.*'], - }, - executor(id) { - const loader = guessIdLoader(id.resolvedPath) - if (plugin.loadInclude(id.resolvedPath)) { - const content = _load(id.resolvedPath) - - return { - content, - moduleType: loader, - } + return { + content: resource.code, + moduleType: loader, + sourceMap: JSON.stringify(resource.map), } }, - } + } as any } - // delete plugin.transformInclude - // delete plugin.loadInclude - - // if (plugin.rollup && containRollupOptions) - // Object.assign(plugin, plugin.rollup) return plugin } diff --git a/src/farm/utils.ts b/src/farm/utils.ts index 1d7d3222..0089c9e9 100644 --- a/src/farm/utils.ts +++ b/src/farm/utils.ts @@ -1,4 +1,5 @@ import path from 'node:path' +import * as querystring from 'node:querystring' export * from '../utils' @@ -21,3 +22,12 @@ const ExtToLoader: Record = { export function guessIdLoader(id: string): string { return ExtToLoader[path.extname(id).toLowerCase()] || 'js' } + +export function transformQuery(context: any) { + const queryParamsObject: Record = {} + context.query.forEach(([param, value]: string[]) => { + queryParamsObject[param] = value + }) + const transformQuery = querystring.stringify(queryParamsObject) + context.resolvedPath = `${context.resolvedPath}?${transformQuery}` +} From c1a17b1d495945a3382e9dd08a71168dfd559b73 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Wed, 20 Sep 2023 18:13:41 +0800 Subject: [PATCH 12/58] chore: update code --- src/farm/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/farm/index.ts b/src/farm/index.ts index 23c51ba1..fc70cbce 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -1,3 +1,4 @@ +import type { PluginLoadHookParam } from '@farmfe/core/binding' import type { RollupPlugin, UnpluginContextMeta, @@ -29,7 +30,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): RollupPlugin { filters: { resolvedPaths: ['.*'], }, - executor(id: any) { + executor(id: PluginLoadHookParam) { if (plugin.loadInclude && !plugin.loadInclude(id.resolvedPath)) return null const loader = guessIdLoader(id.resolvedPath) From ab1f4cddcc855e39cd2efeaa1f7f5687e68fef7a Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Wed, 20 Sep 2023 20:44:42 +0800 Subject: [PATCH 13/58] chore: update code --- src/farm/index.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/farm/index.ts b/src/farm/index.ts index fc70cbce..ddee3843 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -1,6 +1,6 @@ -import type { PluginLoadHookParam } from '@farmfe/core/binding' +import type { PluginLoadHookParam, PluginLoadHookResult } from '@farmfe/core/binding' +import type { JsPlugin } from '@farmfe/core' import type { - RollupPlugin, UnpluginContextMeta, UnpluginFactory, UnpluginInstance, @@ -10,8 +10,7 @@ import { toArray } from '../utils' import { guessIdLoader, transformQuery } from './utils' export function getFarmPlugin< - UserOptions = Record, - Nested extends boolean = boolean, + UserOptions = Record, Nested extends boolean = boolean, >(factory: UnpluginFactory) { return ((userOptions?: UserOptions) => { const meta: UnpluginContextMeta = { @@ -23,14 +22,14 @@ export function getFarmPlugin< }) as UnpluginInstance['rollup'] } -export function toFarmPlugin(plugin: UnpluginOptions): RollupPlugin { +export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { if (plugin.load) { - const _load: any = plugin.load + const _load = plugin.load plugin.load = { filters: { resolvedPaths: ['.*'], }, - executor(id: PluginLoadHookParam) { + executor(id: PluginLoadHookParam): PluginLoadHookResult | null { if (plugin.loadInclude && !plugin.loadInclude(id.resolvedPath)) return null const loader = guessIdLoader(id.resolvedPath) @@ -88,7 +87,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): RollupPlugin { } as any } - return plugin + return plugin as any } /** From fbe6b1d1b75c79f0f8ec48edafd9066ccc536be4 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Thu, 21 Sep 2023 16:08:46 +0800 Subject: [PATCH 14/58] chore: support all hooks --- README.md | 78 +++++++++++------ package.json | 2 +- pnpm-lock.yaml | 34 +++---- src/farm/index.ts | 156 +++++++++++++++++++++++++++------ src/farm/utils.ts | 21 +++++ test/fixtures/load/unplugin.js | 9 ++ 6 files changed, 227 insertions(+), 73 deletions(-) diff --git a/README.md b/README.md index 5c2f8cc4..e70d0653 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ Currently supports: - [Webpack](https://webpack.js.org/) - [esbuild](https://esbuild.github.io/) - [Rspack](https://www.rspack.dev/) (⚠️ experimental) +- [Farm](https://farm-fe.github.io/) (⚠️ experimental) ## Hooks @@ -20,18 +21,18 @@ Currently supports: ###### Supported -| Hook | Rollup | Vite | Webpack 4 | Webpack 5 | esbuild | Rspack | -| ----------------------------------------------------------------------- | :-------------: | :--: | :-------: | :-------: | :-------------: | :----: | -| [`enforce`](https://rollupjs.org/guide/en/#enforce) | ❌ 1 | ✅ | ✅ | ✅ | ❌ 1 | ✅ | -| [`buildStart`](https://rollupjs.org/guide/en/#buildstart) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`resolveId`](https://rollupjs.org/guide/en/#resolveid) | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | -| `loadInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`load`](https://rollupjs.org/guide/en/#load) | ✅ | ✅ | ✅ | ✅ | ✅ 3 | ✅ | -| `transformInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`transform`](https://rollupjs.org/guide/en/#transformers) | ✅ | ✅ | ✅ | ✅ | ✅ 3 | ✅ | -| [`watchChange`](https://rollupjs.org/guide/en/#watchchange) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | -| [`buildEnd`](https://rollupjs.org/guide/en/#buildend) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`writeBundle`](https://rollupjs.org/guide/en/#writebundle)4 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| Hook | Rollup | Vite | Webpack 4 | Webpack 5 | esbuild | Rspack | Farm | +| ----------------------------------------------------------------------- | :-------------: | :--: | :-------: | :-------: | :-------------: | :----: | ---- | +| [`enforce`](https://rollupjs.org/guide/en/#enforce) | ❌ 1 | ✅ | ✅ | ✅ | ❌ 1 | ✅ | ✅ | +| [`buildStart`](https://rollupjs.org/guide/en/#buildstart) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`resolveId`](https://rollupjs.org/guide/en/#resolveid) | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | +| `loadInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`load`](https://rollupjs.org/guide/en/#load) | ✅ | ✅ | ✅ | ✅ | ✅ 3 | ✅ | ✅ | +| `transformInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`transform`](https://rollupjs.org/guide/en/#transformers) | ✅ | ✅ | ✅ | ✅ | ✅ 3 | ✅ | ✅ | +| [`watchChange`](https://rollupjs.org/guide/en/#watchchange) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | +| [`buildEnd`](https://rollupjs.org/guide/en/#buildend) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`writeBundle`](https://rollupjs.org/guide/en/#writebundle)4 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | 1. Rollup and esbuild do not support using `enforce` to control the order of plugins. Users need to maintain the order manually. 2. Webpack's id filter is outside of loader logic; an additional hook is needed for better perf on Webpack. In Rollup and Vite, this hook has been polyfilled to match the behaviors. See for the following usage examples. @@ -129,7 +130,9 @@ import UnpluginFeature from './unplugin-feature' export default { plugins: [ - UnpluginFeature.vite({ /* options */ }), + UnpluginFeature.vite({ + /* options */ + }), ], } ``` @@ -142,7 +145,9 @@ import UnpluginFeature from './unplugin-feature' export default { plugins: [ - UnpluginFeature.rollup({ /* options */ }), + UnpluginFeature.rollup({ + /* options */ + }), ], } ``` @@ -153,7 +158,9 @@ export default { // webpack.config.js module.exports = { plugins: [ - require('./unplugin-feature').webpack({ /* options */ }), + require('./unplugin-feature').webpack({ + /* options */ + }), ], } ``` @@ -166,19 +173,22 @@ import { build } from 'esbuild' build({ plugins: [ - require('./unplugin-feature').esbuild({ /* options */ }), + require('./unplugin-feature').esbuild({ + /* options */ + }), ], }) ``` - ###### Rspack ```ts // rspack.config.js module.exports = { plugins: [ - require('./unplugin-feature').rspack({ /* options */ }), + require('./unplugin-feature').rspack({ + /* options */ + }), ], } ``` @@ -194,8 +204,12 @@ export const unplugin = createUnplugin((options: UserOptions, meta) => { return { // Common unplugin hooks name: 'unplugin-prefixed-name', - transformInclude(id) { /* ... */ }, - transform(code) { /* ... */ }, + transformInclude(id) { + /* ... */ + }, + transform(code) { + /* ... */ + }, // Framework specific hooks vite: { @@ -218,11 +232,9 @@ export const unplugin = createUnplugin((options: UserOptions, meta) => { // Change the filter of onResolve and onLoad // onResolveFilter?: RegExp, // onLoadFilter?: RegExp, - // Tell esbuild how to interpret the contents. By default unplugin tries to guess the loader // from file extension (eg: .js -> "js", .jsx -> 'jsx') // loader?: (Loader | (code: string, id: string) => Loader) - // Or you can completely replace the setup logic // setup?: EsbuildPlugin.setup, }, @@ -241,14 +253,24 @@ import { createRollupPlugin, createRspackPlugin, createVitePlugin, - createWebpackPlugin + createWebpackPlugin, } from 'unplugin' -const vitePlugin = createVitePlugin({ /* options */ }) -const rollupPlugin = createRollupPlugin({ /* options */ }) -const esbuildPlugin = createEsbuildPlugin({ /* options */ }) -const webpackPlugin = createWebpackPlugin({ /* options */ }) -const rspackPlugin = createRspackPlugin({ /* options */ }) +const vitePlugin = createVitePlugin({ + /* options */ +}) +const rollupPlugin = createRollupPlugin({ + /* options */ +}) +const esbuildPlugin = createEsbuildPlugin({ + /* options */ +}) +const webpackPlugin = createWebpackPlugin({ + /* options */ +}) +const rspackPlugin = createRspackPlugin({ + /* options */ +}) ``` ## Conventions diff --git a/package.json b/package.json index 30cd403d..58ab2ed4 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@antfu/eslint-config": "^0.42.0", "@antfu/ni": "^0.21.8", "@farmfe/cli": "^0.5.5", - "@farmfe/core": "^0.12.3", + "@farmfe/core": "^0.12.6", "@rspack/cli": "^0.3.4", "@rspack/core": "^0.3.4", "@types/fs-extra": "^11.0.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1b849ef9..749b67c3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -32,8 +32,8 @@ devDependencies: specifier: ^0.5.5 version: 0.5.5 '@farmfe/core': - specifier: ^0.12.3 - version: 0.12.3 + specifier: ^0.12.6 + version: 0.12.6 '@rspack/cli': specifier: ^0.3.4 version: 0.3.4(esbuild@0.19.3)(react-refresh@0.14.0)(webpack-cli@4.10.0) @@ -702,8 +702,8 @@ packages: walkdir: 0.4.1 dev: true - /@farmfe/core-darwin-arm64@0.12.3: - resolution: {integrity: sha512-jMKjVp7/+jam833rxArdbwERq7BWnSO9p8fMkeMXY6l4QC0qpwIqHpC7EzGQ+FdLhxd7XDWcWRYJvbKN7bzvBQ==} + /@farmfe/core-darwin-arm64@0.12.6: + resolution: {integrity: sha512-uwv1++VXuCdck2+AXWHWL7HIuqdP392CSfnKgaIOFyWeKmDmNaabvP0FBhS8A92y679NoNUneJQFn/ZpLK9DrA==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] @@ -711,8 +711,8 @@ packages: dev: true optional: true - /@farmfe/core-darwin-x64@0.12.3: - resolution: {integrity: sha512-y9qgxDEfLlByDqZyVNwOJkaT0ZQPzGs2W/LsEKS0aKUEqMX2ohrTajIuuxIjMn8dpoUX7/QShaW2pkQ6gBPnJg==} + /@farmfe/core-darwin-x64@0.12.6: + resolution: {integrity: sha512-27tkzXFZl6MIdp+CcJqvfs9hueoJN7CBtabwu6ay2auBY5GkaQvZn+K4mwLOzKU2RRRDuwawu4hUksRnRNK1Aw==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] @@ -720,8 +720,8 @@ packages: dev: true optional: true - /@farmfe/core-linux-x64-gnu@0.12.3: - resolution: {integrity: sha512-ojg/Zm6rnv3lhaf6I8jLRmHvIJxjO2uV15tc52a5svg8gHm/kKCLRHKuSrr1LyovqqxwEnowNuRQsYIobzqz2A==} + /@farmfe/core-linux-x64-gnu@0.12.6: + resolution: {integrity: sha512-TTpr3wBE7x9htW6KiQSQDSqkexo69qdohiI4ENKq+L2A6doSYnWSKbFJL+Ly//MKjG7Olk0kidb3A6M1Nx9rgg==} engines: {node: '>= 10'} cpu: [x64] os: [linux] @@ -730,8 +730,8 @@ packages: dev: true optional: true - /@farmfe/core-win32-x64-msvc@0.12.3: - resolution: {integrity: sha512-mra84fFmCRMkq6Q6FUfPJrS2N7scHrOH6zk5wrVqpIApLyIuIqETNLrJOCiVOxQF3D/VuEQbHUlK7CrQg9YAlQ==} + /@farmfe/core-win32-x64-msvc@0.12.6: + resolution: {integrity: sha512-0iWqVkJ+WwPko6hPVpAumnJliDifIKWpedJ/njdtuBYZ4hc6DjiM21NrKZ/97JzjekbWkBv1R6ZWoxXlxjsUrA==} engines: {node: '>= 10'} cpu: [x64] os: [win32] @@ -739,8 +739,8 @@ packages: dev: true optional: true - /@farmfe/core@0.12.3: - resolution: {integrity: sha512-o5F3HeGoHIrodh8GFl5kH3Twoomxe2qpHJgG2nKPH38vvVY3hnRSfkFTGilMBF39jeVukexXwsXuQQffsMKMtg==} + /@farmfe/core@0.12.6: + resolution: {integrity: sha512-DxSbJwDWL+esieVe4o1O+pq1xLXORWgsB9ZZwxQGrAklPik5tcPTWS8L6rzSVxQRZc3B1bMtrfHIDj17IBYiSQ==} engines: {node: '>= 16'} dependencies: '@farmfe/runtime': 0.7.0 @@ -767,10 +767,10 @@ packages: zod: 3.21.4 zod-validation-error: 1.5.0(zod@3.21.4) optionalDependencies: - '@farmfe/core-darwin-arm64': 0.12.3 - '@farmfe/core-darwin-x64': 0.12.3 - '@farmfe/core-linux-x64-gnu': 0.12.3 - '@farmfe/core-win32-x64-msvc': 0.12.3 + '@farmfe/core-darwin-arm64': 0.12.6 + '@farmfe/core-darwin-x64': 0.12.6 + '@farmfe/core-linux-x64-gnu': 0.12.6 + '@farmfe/core-win32-x64-msvc': 0.12.6 transitivePeerDependencies: - bufferutil - debug @@ -4657,7 +4657,7 @@ packages: escape-html: 1.0.3 fresh: 0.5.2 http-assert: 1.5.0 - http-errors: 1.6.3 + http-errors: 1.8.1 is-generator-function: 1.0.10 koa-compose: 4.1.0 koa-convert: 2.0.0 diff --git a/src/farm/index.ts b/src/farm/index.ts index ddee3843..1c23b123 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -1,16 +1,30 @@ -import type { PluginLoadHookParam, PluginLoadHookResult } from '@farmfe/core/binding' +import fs from 'fs' +import path from 'path' +import type { + PluginLoadHookParam, + PluginLoadHookResult, + PluginTransformHookParam, + PluginTransformHookResult, +} from '@farmfe/core/binding' import type { JsPlugin } from '@farmfe/core' import type { + TransformResult, UnpluginContextMeta, UnpluginFactory, UnpluginInstance, UnpluginOptions, } from '../types' import { toArray } from '../utils' -import { guessIdLoader, transformQuery } from './utils' +import { + convertEnforceToPriority, + convertWatchEventChange, + guessIdLoader, + transformQuery, +} from './utils' export function getFarmPlugin< - UserOptions = Record, Nested extends boolean = boolean, + UserOptions = Record, + Nested extends boolean = boolean, >(factory: UnpluginFactory) { return ((userOptions?: UserOptions) => { const meta: UnpluginContextMeta = { @@ -23,40 +37,87 @@ export function getFarmPlugin< } export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { + const farmPlugin: JsPlugin = { + name: plugin.name, + priority: convertEnforceToPriority(plugin.enforce), + } + + if (plugin.buildStart) { + const _buildStart = plugin.buildStart + farmPlugin.buildStart = { + async executor() { + await _buildStart() + }, + } + } + + if (plugin.resolveId) { + const _resolveId = plugin.resolveId + farmPlugin.resolve = { + filters: { sources: ['.*'], importers: ['.*'] }, + async executor(params) { + const resolvedIdPath = path.resolve( + process.cwd(), + params.importer?.relativePath ?? '', + ) + const isEntry = params.kind.entry === 'index' + // const paths = path.resolve(process.cwd(), params.importer?.relativePath) + const resolvedPath = await _resolveId( + params.source, + resolvedIdPath ?? null, + { isEntry }, + ) + if (resolvedPath) { + return { + resolvedPath, + query: [], + sideEffects: false, + external: false, + meta: {}, + } + } + }, + } + } + if (plugin.load) { const _load = plugin.load - plugin.load = { + farmPlugin.load = { filters: { resolvedPaths: ['.*'], }, - executor(id: PluginLoadHookParam): PluginLoadHookResult | null { + async executor( + id: PluginLoadHookParam, + ): Promise { if (plugin.loadInclude && !plugin.loadInclude(id.resolvedPath)) return null const loader = guessIdLoader(id.resolvedPath) const shouldLoadInclude = plugin.loadInclude && plugin.loadInclude(id.resolvedPath) - const content = _load(id.resolvedPath) + const content + = _load.call(this, id.resolvedPath) + ?? (await fs.promises.readFile(id.resolvedPath, 'utf8')) if (shouldLoadInclude) { return { content, moduleType: loader, - } + } as PluginLoadHookResult } return { content, moduleType: loader, - } + } as PluginLoadHookResult }, } as any } if (plugin.transform) { - const _transform: any = plugin.transform - plugin.transform = { + const _transform = plugin.transform + farmPlugin.transform = { filters: { resolvedPaths: ['.*'] }, - executor(params: any) { + async executor(params: PluginTransformHookParam) { if (params.query.length) transformQuery(params) @@ -70,32 +131,73 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { const shouldTransformInclude = plugin.transformInclude && plugin.transformInclude(params.resolvedPath) - const resource: any = _transform(params.content, params.resolvedPath) - if (shouldTransformInclude) { + const resource: TransformResult = await _transform.call( + this, + params.content, + params.resolvedPath, + ) + if (resource && typeof resource !== 'string') { + if (shouldTransformInclude) { + return { + content: resource.code, + moduleType: loader, + sourceMap: JSON.stringify(resource.map), + } as PluginTransformHookResult + } return { content: resource.code, moduleType: loader, sourceMap: JSON.stringify(resource.map), - } - } - return { - content: resource.code, - moduleType: loader, - sourceMap: JSON.stringify(resource.map), + } as PluginTransformHookResult } }, } as any } - return plugin as any + if (plugin.watchChange) { + const _watchChange = plugin.watchChange + farmPlugin.updateModules = { + async executor(param) { + // To be compatible with unplugin, we ensure that only one file is changed at a time. + const updatePathContent = param.paths[0] + const ModifiedPath = updatePathContent[0] + const eventChange = convertWatchEventChange(updatePathContent[1]) + _watchChange(ModifiedPath, eventChange) + }, + } + } + + if (plugin.buildEnd) { + const _buildEnd = plugin.buildEnd + farmPlugin.buildEnd = { + executor() { + _buildEnd() + }, + } + } + + if (plugin.writeBundle) { + const _writeBundle = plugin.writeBundle + farmPlugin.finish = { + executor() { + _writeBundle() + }, + } + } + + return farmPlugin } /** - * v1.0.0 beta - * 1. 增量构建 - * 2. 重构 resolver - * 3. 接入一些 js 生态 (unplugin) - * 4. 重构 node 规范化基础配置流程 不重要! - * 5. 接 fervid 的 vue compiler 不重要! - * 6. 用户DX 修复一些体验 bug e.g: 热更新报错白屏 + * Degree of completion + * enforce ✅ + * buildStart ✅ + * resolveId ✅ + * loadInclude ✅ + * load ✅ + * transformInclude ✅ + * transform ✅ + * watchChange ✅ + * buildEnd ✅ + * writeBundle ✅ */ diff --git a/src/farm/utils.ts b/src/farm/utils.ts index 0089c9e9..ccaefdbc 100644 --- a/src/farm/utils.ts +++ b/src/farm/utils.ts @@ -14,6 +14,7 @@ const ExtToLoader: Record = { '.tsx': 'tsx', '.json': 'json', '.toml': 'toml', + '.text': 'text', '.wasm': 'wasm', '.napi': 'napi', '.node': 'napi', @@ -31,3 +32,23 @@ export function transformQuery(context: any) { const transformQuery = querystring.stringify(queryParamsObject) context.resolvedPath = `${context.resolvedPath}?${transformQuery}` } + +export function convertEnforceToPriority(value: 'pre' | 'post' | undefined) { + const defaultPriority = 100 + const enforceToPriority = { + pre: 101, + post: 99, + } + + return enforceToPriority[value!] !== undefined ? enforceToPriority[value!] : defaultPriority +} + +export function convertWatchEventChange(value: 'Added' | 'Updated' | 'Removed') { + const watchEventChange = { + Added: 'create', + Updated: 'update', + Removed: 'delete', + } + + return watchEventChange[value] +} diff --git a/test/fixtures/load/unplugin.js b/test/fixtures/load/unplugin.js index 3e447ebe..23855081 100644 --- a/test/fixtures/load/unplugin.js +++ b/test/fixtures/load/unplugin.js @@ -9,6 +9,9 @@ module.exports = createUnplugin((options) => { loadInclude(id) { return targetFileReg.test(id) }, + buildStart() {}, + resolveId() { + }, load(id) { const code = fs.readFileSync(id, { encoding: 'utf-8' }) const str = new MagicString(code) @@ -39,5 +42,11 @@ module.exports = createUnplugin((options) => { }), } }, + watchChange() { + }, + buildEnd() { + }, + writeBundle() { + }, } }) From a169cfb18e942a6fdc9e5d0012e34f4ebd836e94 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Thu, 21 Sep 2023 18:08:30 +0800 Subject: [PATCH 15/58] chore: update code --- src/farm/index.ts | 14 +++++++++----- src/farm/utils.ts | 12 +++++++++--- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/farm/index.ts b/src/farm/index.ts index 1c23b123..6179a83b 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -3,6 +3,7 @@ import path from 'path' import type { PluginLoadHookParam, PluginLoadHookResult, + PluginResolveHookParam, PluginTransformHookParam, PluginTransformHookResult, } from '@farmfe/core/binding' @@ -15,6 +16,7 @@ import type { UnpluginOptions, } from '../types' import { toArray } from '../utils' +import type { WatchChangeEvents } from './utils' import { convertEnforceToPriority, convertWatchEventChange, @@ -46,7 +48,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { const _buildStart = plugin.buildStart farmPlugin.buildStart = { async executor() { - await _buildStart() + await _buildStart.call(this) }, } } @@ -55,7 +57,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { const _resolveId = plugin.resolveId farmPlugin.resolve = { filters: { sources: ['.*'], importers: ['.*'] }, - async executor(params) { + async executor(params: PluginResolveHookParam) { const resolvedIdPath = path.resolve( process.cwd(), params.importer?.relativePath ?? '', @@ -161,8 +163,10 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { // To be compatible with unplugin, we ensure that only one file is changed at a time. const updatePathContent = param.paths[0] const ModifiedPath = updatePathContent[0] - const eventChange = convertWatchEventChange(updatePathContent[1]) - _watchChange(ModifiedPath, eventChange) + const eventChange = convertWatchEventChange( + updatePathContent[1] as WatchChangeEvents, + ) + _watchChange.call(this, ModifiedPath, { event: eventChange }) }, } } @@ -171,7 +175,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { const _buildEnd = plugin.buildEnd farmPlugin.buildEnd = { executor() { - _buildEnd() + _buildEnd.call(this) }, } } diff --git a/src/farm/utils.ts b/src/farm/utils.ts index ccaefdbc..5b9450e5 100644 --- a/src/farm/utils.ts +++ b/src/farm/utils.ts @@ -3,6 +3,8 @@ import * as querystring from 'node:querystring' export * from '../utils' +export type WatchChangeEvents = 'create' | 'update' | 'delete' + const ExtToLoader: Record = { '.js': 'js', '.mjs': 'js', @@ -40,15 +42,19 @@ export function convertEnforceToPriority(value: 'pre' | 'post' | undefined) { post: 99, } - return enforceToPriority[value!] !== undefined ? enforceToPriority[value!] : defaultPriority + return enforceToPriority[value!] !== undefined + ? enforceToPriority[value!] + : defaultPriority } -export function convertWatchEventChange(value: 'Added' | 'Updated' | 'Removed') { +export function convertWatchEventChange( + value: WatchChangeEvents, +) { const watchEventChange = { Added: 'create', Updated: 'update', Removed: 'delete', - } + } as unknown as { [key in WatchChangeEvents]: string } return watchEventChange[value] } From 9eb776f2ac5aba11f45dfd357e0f4322ae61106d Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Thu, 21 Sep 2023 21:23:41 +0800 Subject: [PATCH 16/58] chore: update code --- src/farm/index.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/farm/index.ts b/src/farm/index.ts index 6179a83b..6cd43739 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -25,8 +25,7 @@ import { } from './utils' export function getFarmPlugin< - UserOptions = Record, - Nested extends boolean = boolean, + UserOptions = Record, Nested extends boolean = boolean, >(factory: UnpluginFactory) { return ((userOptions?: UserOptions) => { const meta: UnpluginContextMeta = { @@ -62,14 +61,16 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { process.cwd(), params.importer?.relativePath ?? '', ) - const isEntry = params.kind.entry === 'index' - // const paths = path.resolve(process.cwd(), params.importer?.relativePath) + let isEntry = false + if (typeof params.kind === 'object' && params.kind !== null) + isEntry = params.kind.entry === 'index' + const resolvedPath = await _resolveId( params.source, resolvedIdPath ?? null, { isEntry }, ) - if (resolvedPath) { + if (resolvedPath && typeof resolvedPath === 'string') { return { resolvedPath, query: [], @@ -78,6 +79,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { meta: {}, } } + return null }, } } From 83fed5a3f9bee374d19df875315f60e18ff278cf Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Fri, 22 Sep 2023 11:03:06 +0800 Subject: [PATCH 17/58] chore: update farm hooks --- src/farm/index.ts | 32 +++++++++++++++++--------------- src/types.ts | 3 ++- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/farm/index.ts b/src/farm/index.ts index 6cd43739..76827a1c 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -41,15 +41,16 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { const farmPlugin: JsPlugin = { name: plugin.name, priority: convertEnforceToPriority(plugin.enforce), + config: plugin.farm!.config, + configDevServer: plugin.farm!.configDevServer, } - if (plugin.buildStart) { const _buildStart = plugin.buildStart farmPlugin.buildStart = { - async executor() { - await _buildStart.call(this) + async executor(_, hook) { + await _buildStart.call(hook) }, - } + } as JsPlugin['buildStart'] } if (plugin.resolveId) { @@ -62,9 +63,10 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { params.importer?.relativePath ?? '', ) let isEntry = false - if (typeof params.kind === 'object' && params.kind !== null) - isEntry = params.kind.entry === 'index' - + if (typeof params.kind === 'object' && 'entry' in params.kind) { + const kindWithEntry = params.kind as { entry: string } + isEntry = kindWithEntry.entry === 'index' + } const resolvedPath = await _resolveId( params.source, resolvedIdPath ?? null, @@ -81,7 +83,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { } return null }, - } + } as JsPlugin['resolve'] } if (plugin.load) { @@ -114,7 +116,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { moduleType: loader, } as PluginLoadHookResult }, - } as any + } as JsPlugin['load'] } if (plugin.transform) { @@ -155,7 +157,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { } as PluginTransformHookResult } }, - } as any + } as JsPlugin['transform'] } if (plugin.watchChange) { @@ -170,16 +172,16 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { ) _watchChange.call(this, ModifiedPath, { event: eventChange }) }, - } + } as JsPlugin['updateModules'] } if (plugin.buildEnd) { const _buildEnd = plugin.buildEnd farmPlugin.buildEnd = { - executor() { - _buildEnd.call(this) + executor(_, context) { + _buildEnd.call(context) }, - } + } as JsPlugin['buildEnd'] } if (plugin.writeBundle) { @@ -188,7 +190,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { executor() { _writeBundle() }, - } + } as JsPlugin['finish'] } return farmPlugin diff --git a/src/types.ts b/src/types.ts index 9868787f..081c1d2b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -4,6 +4,7 @@ import type { Plugin as VitePlugin } from 'vite' import type { Plugin as EsbuildPlugin, Loader, PluginBuild } from 'esbuild' import type { Compiler as RspackCompiler, RspackPluginInstance } from '@rspack/core' import type VirtualModulesPlugin from 'webpack-virtual-modules' +import type { JsPlugin as FarmPlugin } from '@farmfe/core' export { EsbuildPlugin, @@ -77,7 +78,7 @@ export interface UnpluginOptions { setup?: EsbuildPlugin['setup'] loader?: Loader | ((code: string, id: string) => Loader) } - farm?: any + farm?: Partial } export interface ResolvedUnpluginOptions extends UnpluginOptions { From a57890fd525487b7a958d2bfbc199d8fca2ca09a Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Fri, 22 Sep 2023 11:04:42 +0800 Subject: [PATCH 18/58] chore: update code --- src/farm/index.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/farm/index.ts b/src/farm/index.ts index 76827a1c..cf47c84a 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -41,9 +41,14 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { const farmPlugin: JsPlugin = { name: plugin.name, priority: convertEnforceToPriority(plugin.enforce), - config: plugin.farm!.config, - configDevServer: plugin.farm!.configDevServer, } + + if (plugin.farm?.config) + farmPlugin.config = plugin.farm.config + + if (plugin.farm?.configDevServer) + farmPlugin.configDevServer = plugin.farm.configDevServer + if (plugin.buildStart) { const _buildStart = plugin.buildStart farmPlugin.buildStart = { From 6e8f0be27eda2d04b5843df3e625189d5ff254b7 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Fri, 22 Sep 2023 11:06:45 +0800 Subject: [PATCH 19/58] chore: update code --- src/farm/index.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/farm/index.ts b/src/farm/index.ts index cf47c84a..26312737 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -106,7 +106,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { const shouldLoadInclude = plugin.loadInclude && plugin.loadInclude(id.resolvedPath) const content - = _load.call(this, id.resolvedPath) + = await _load.call(this, id.resolvedPath) ?? (await fs.promises.readFile(id.resolvedPath, 'utf8')) if (shouldLoadInclude) { @@ -175,7 +175,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { const eventChange = convertWatchEventChange( updatePathContent[1] as WatchChangeEvents, ) - _watchChange.call(this, ModifiedPath, { event: eventChange }) + await _watchChange.call(this, ModifiedPath, { event: eventChange }) }, } as JsPlugin['updateModules'] } @@ -183,8 +183,8 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { if (plugin.buildEnd) { const _buildEnd = plugin.buildEnd farmPlugin.buildEnd = { - executor(_, context) { - _buildEnd.call(context) + async executor(_, context) { + await _buildEnd.call(context) }, } as JsPlugin['buildEnd'] } @@ -192,8 +192,8 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { if (plugin.writeBundle) { const _writeBundle = plugin.writeBundle farmPlugin.finish = { - executor() { - _writeBundle() + async executor() { + await _writeBundle() }, } as JsPlugin['finish'] } From 5fa6994ad70bded11e07412b32b543dd42f35760 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Fri, 22 Sep 2023 11:10:04 +0800 Subject: [PATCH 20/58] chore: update code --- src/farm/index.ts | 8 ++++++-- test/fixtures/load/unplugin.js | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/farm/index.ts b/src/farm/index.ts index 26312737..12449e8a 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -25,7 +25,8 @@ import { } from './utils' export function getFarmPlugin< - UserOptions = Record, Nested extends boolean = boolean, + UserOptions = Record, + Nested extends boolean = boolean, >(factory: UnpluginFactory) { return ((userOptions?: UserOptions) => { const meta: UnpluginContextMeta = { @@ -49,6 +50,9 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { if (plugin.farm?.configDevServer) farmPlugin.configDevServer = plugin.farm.configDevServer + if (plugin.farm?.updateModules) + farmPlugin.updateModules = plugin.farm.updateModules + if (plugin.buildStart) { const _buildStart = plugin.buildStart farmPlugin.buildStart = { @@ -106,7 +110,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { const shouldLoadInclude = plugin.loadInclude && plugin.loadInclude(id.resolvedPath) const content - = await _load.call(this, id.resolvedPath) + = (await _load.call(this, id.resolvedPath)) ?? (await fs.promises.readFile(id.resolvedPath, 'utf8')) if (shouldLoadInclude) { diff --git a/test/fixtures/load/unplugin.js b/test/fixtures/load/unplugin.js index 23855081..666c39f7 100644 --- a/test/fixtures/load/unplugin.js +++ b/test/fixtures/load/unplugin.js @@ -9,7 +9,8 @@ module.exports = createUnplugin((options) => { loadInclude(id) { return targetFileReg.test(id) }, - buildStart() {}, + buildStart() { + }, resolveId() { }, load(id) { From defed4ce96533fddfeb7a2ca90ad72a652608b48 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Sat, 23 Sep 2023 09:45:45 +0800 Subject: [PATCH 21/58] chore: update code --- package.json | 8 ++++---- pnpm-lock.yaml | 49 +++++++++++++++++++++++------------------------ src/farm/index.ts | 28 +++++++++++++++------------ 3 files changed, 44 insertions(+), 41 deletions(-) diff --git a/package.json b/package.json index 58ab2ed4..5b8f311a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "unplugin", - "version": "1.5.0", + "name": "unplugin-test", + "version": "1.5.4", "packageManager": "pnpm@8.7.5", "description": "Unified plugin system for build tools", "license": "MIT", @@ -44,8 +44,8 @@ "@ampproject/remapping": "^2.2.1", "@antfu/eslint-config": "^0.42.0", "@antfu/ni": "^0.21.8", - "@farmfe/cli": "^0.5.5", - "@farmfe/core": "^0.12.6", + "@farmfe/cli": "^0.5.7", + "@farmfe/core": "^0.12.8", "@rspack/cli": "^0.3.4", "@rspack/core": "^0.3.4", "@types/fs-extra": "^11.0.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 749b67c3..c719492b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: '6.1' +lockfileVersion: '6.0' settings: autoInstallPeers: true @@ -29,11 +29,11 @@ devDependencies: specifier: ^0.21.8 version: 0.21.8 '@farmfe/cli': - specifier: ^0.5.5 - version: 0.5.5 + specifier: ^0.5.7 + version: 0.5.7 '@farmfe/core': - specifier: ^0.12.6 - version: 0.12.6 + specifier: ^0.12.8 + version: 0.12.8 '@rspack/cli': specifier: ^0.3.4 version: 0.3.4(esbuild@0.19.3)(react-refresh@0.14.0)(webpack-cli@4.10.0) @@ -689,8 +689,8 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /@farmfe/cli@0.5.5: - resolution: {integrity: sha512-Q+CvD+WpZT0CWqBmru1eqw8hZm27X8C0l+lPVcKOHqu88iM20eK2bgNSq2Z5IoDHGhq8TW6ds1kHYGiIrB3/nQ==} + /@farmfe/cli@0.5.7: + resolution: {integrity: sha512-kO1oQFXuQpwRhOZY1fvZPRCIxWORLI66HnrbJM6ATVirZUiuonlTe14PpI4bnaUDOsnKpBhYOHmGYtWsQlwCJA==} engines: {node: '>= 16'} hasBin: true dependencies: @@ -702,8 +702,8 @@ packages: walkdir: 0.4.1 dev: true - /@farmfe/core-darwin-arm64@0.12.6: - resolution: {integrity: sha512-uwv1++VXuCdck2+AXWHWL7HIuqdP392CSfnKgaIOFyWeKmDmNaabvP0FBhS8A92y679NoNUneJQFn/ZpLK9DrA==} + /@farmfe/core-darwin-arm64@0.12.8: + resolution: {integrity: sha512-RexuS0c0hMMpdXxbSufHrh4TvQpDt/v+DKnAvibZLgX4l4NpUWt1RACeOGr4NpP6gVsS0UR66LuPY/883vq5Vw==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] @@ -711,8 +711,8 @@ packages: dev: true optional: true - /@farmfe/core-darwin-x64@0.12.6: - resolution: {integrity: sha512-27tkzXFZl6MIdp+CcJqvfs9hueoJN7CBtabwu6ay2auBY5GkaQvZn+K4mwLOzKU2RRRDuwawu4hUksRnRNK1Aw==} + /@farmfe/core-darwin-x64@0.12.8: + resolution: {integrity: sha512-g4G41zs96tFHbCbRBQxBgFQCnxdVlsPILw7IzpoqGgWsb+aQQECA9dZaQ/vJ1vGoaI1L3/SvEyEh30lw1ZcgLA==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] @@ -720,18 +720,17 @@ packages: dev: true optional: true - /@farmfe/core-linux-x64-gnu@0.12.6: - resolution: {integrity: sha512-TTpr3wBE7x9htW6KiQSQDSqkexo69qdohiI4ENKq+L2A6doSYnWSKbFJL+Ly//MKjG7Olk0kidb3A6M1Nx9rgg==} + /@farmfe/core-linux-x64-gnu@0.12.8: + resolution: {integrity: sha512-/odx9eKYlYXQFskCvHk0VM97ED2o1zD+v6J9Bit2HL5zu3ozjjZCnJH3po2mes8moPtn4AQurO91VjuvuKSLMA==} engines: {node: '>= 10'} cpu: [x64] os: [linux] - libc: [glibc] requiresBuild: true dev: true optional: true - /@farmfe/core-win32-x64-msvc@0.12.6: - resolution: {integrity: sha512-0iWqVkJ+WwPko6hPVpAumnJliDifIKWpedJ/njdtuBYZ4hc6DjiM21NrKZ/97JzjekbWkBv1R6ZWoxXlxjsUrA==} + /@farmfe/core-win32-x64-msvc@0.12.8: + resolution: {integrity: sha512-4HFsIWrYW2WXFxZfJg4Usk4OZD6Ot/4GCKJBfghP7yrGmuCmfMUGdIBqbzFXLRyZI14mJhmBQd57/zUNu+tPCQ==} engines: {node: '>= 10'} cpu: [x64] os: [win32] @@ -739,8 +738,8 @@ packages: dev: true optional: true - /@farmfe/core@0.12.6: - resolution: {integrity: sha512-DxSbJwDWL+esieVe4o1O+pq1xLXORWgsB9ZZwxQGrAklPik5tcPTWS8L6rzSVxQRZc3B1bMtrfHIDj17IBYiSQ==} + /@farmfe/core@0.12.8: + resolution: {integrity: sha512-bUmN09SOBzoMorphJZKmqeKn2fnEEB9xMO/falGYQGgUhdE1IIKUu5/OKSYdFF41jjm25e/iMJyJJVh8qbdGeQ==} engines: {node: '>= 16'} dependencies: '@farmfe/runtime': 0.7.0 @@ -767,10 +766,10 @@ packages: zod: 3.21.4 zod-validation-error: 1.5.0(zod@3.21.4) optionalDependencies: - '@farmfe/core-darwin-arm64': 0.12.6 - '@farmfe/core-darwin-x64': 0.12.6 - '@farmfe/core-linux-x64-gnu': 0.12.6 - '@farmfe/core-win32-x64-msvc': 0.12.6 + '@farmfe/core-darwin-arm64': 0.12.8 + '@farmfe/core-darwin-x64': 0.12.8 + '@farmfe/core-linux-x64-gnu': 0.12.8 + '@farmfe/core-win32-x64-msvc': 0.12.8 transitivePeerDependencies: - bufferutil - debug @@ -2537,7 +2536,7 @@ packages: dev: true /concat-map@0.0.1: - resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} + resolution: {integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=} dev: true /connect-history-api-fallback@2.0.0: @@ -2970,7 +2969,7 @@ packages: dev: true /ee-first@1.1.1: - resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==} + resolution: {integrity: sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=} dev: true /electron-to-chromium@1.4.327: @@ -4879,7 +4878,7 @@ packages: dev: true /media-typer@0.3.0: - resolution: {integrity: sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==} + resolution: {integrity: sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=} engines: {node: '>= 0.6'} dev: true diff --git a/src/farm/index.ts b/src/farm/index.ts index 12449e8a..793198cd 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -25,15 +25,21 @@ import { } from './utils' export function getFarmPlugin< - UserOptions = Record, - Nested extends boolean = boolean, + UserOptions = Record, Nested extends boolean = boolean, >(factory: UnpluginFactory) { return ((userOptions?: UserOptions) => { const meta: UnpluginContextMeta = { framework: 'farm', } const rawPlugins = toArray(factory(userOptions!, meta)) - const plugins = rawPlugins.map(plugin => toFarmPlugin(plugin)) + const plugins = rawPlugins.map((rawPlugin) => { + const plugin = toFarmPlugin(rawPlugin) as JsPlugin + if (rawPlugin.farm) + Object.assign(plugin, rawPlugin.farm) + + return plugin + }) + return plugins.length === 1 ? plugins[0] : plugins }) as UnpluginInstance['rollup'] } @@ -151,19 +157,17 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { params.content, params.resolvedPath, ) + if (resource && typeof resource !== 'string') { - if (shouldTransformInclude) { - return { - content: resource.code, - moduleType: loader, - sourceMap: JSON.stringify(resource.map), - } as PluginTransformHookResult - } - return { + const transformFarmResult: PluginTransformHookResult = { content: resource.code, moduleType: loader, sourceMap: JSON.stringify(resource.map), - } as PluginTransformHookResult + } + if (shouldTransformInclude) + return transformFarmResult + + return transformFarmResult } }, } as JsPlugin['transform'] From ee2fa397b2f9ee5d44cdc328f90a0a2b779d10d4 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Sat, 23 Sep 2023 13:04:01 +0800 Subject: [PATCH 22/58] fix: resolve type error --- package.json | 2 +- src/farm/index.ts | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 5b8f311a..d163fe53 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "unplugin-test", - "version": "1.5.4", + "version": "1.5.5", "packageManager": "pnpm@8.7.5", "description": "Unified plugin system for build tools", "license": "MIT", diff --git a/src/farm/index.ts b/src/farm/index.ts index 793198cd..0cdb5a8a 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -115,9 +115,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { const loader = guessIdLoader(id.resolvedPath) const shouldLoadInclude = plugin.loadInclude && plugin.loadInclude(id.resolvedPath) - const content - = (await _load.call(this, id.resolvedPath)) - ?? (await fs.promises.readFile(id.resolvedPath, 'utf8')) + const content = await _load.call(this, id.resolvedPath) if (shouldLoadInclude) { return { @@ -148,7 +146,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { ) return null - const loader = guessIdLoader(params.resolvedPath) + const loader = params.moduleType ?? guessIdLoader(params.resolvedPath) const shouldTransformInclude = plugin.transformInclude && plugin.transformInclude(params.resolvedPath) From 659b4b368e8b75b30bf00c0584e597ea55fe8f98 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Sat, 23 Sep 2023 20:34:13 +0800 Subject: [PATCH 23/58] chore: update code --- package.json | 2 +- src/farm/index.ts | 25 ++++++++++++------------- src/farm/utils.ts | 9 +++++++++ 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index d163fe53..7ebfbcc6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "unplugin-test", - "version": "1.5.5", + "version": "1.5.6", "packageManager": "pnpm@8.7.5", "description": "Unified plugin system for build tools", "license": "MIT", diff --git a/src/farm/index.ts b/src/farm/index.ts index 0cdb5a8a..803294e4 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -20,7 +20,9 @@ import type { WatchChangeEvents } from './utils' import { convertEnforceToPriority, convertWatchEventChange, + getContentValue, guessIdLoader, + resolveQuery, transformQuery, } from './utils' @@ -90,7 +92,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { if (resolvedPath && typeof resolvedPath === 'string') { return { resolvedPath, - query: [], + query: [], // TODO queryString sideEffects: false, external: false, meta: {}, @@ -115,19 +117,16 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { const loader = guessIdLoader(id.resolvedPath) const shouldLoadInclude = plugin.loadInclude && plugin.loadInclude(id.resolvedPath) - const content = await _load.call(this, id.resolvedPath) - - if (shouldLoadInclude) { - return { - content, - moduleType: loader, - } as PluginLoadHookResult + const content: TransformResult = await _load.call(this, id.resolvedPath) + const loadFarmResult: PluginLoadHookResult = { + // TODO maybe sourcemap resolve + content: typeof content === 'string' ? content : content!.code, + moduleType: loader, } + if (shouldLoadInclude) + return loadFarmResult - return { - content, - moduleType: loader, - } as PluginLoadHookResult + return loadFarmResult }, } as JsPlugin['load'] } @@ -158,7 +157,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { if (resource && typeof resource !== 'string') { const transformFarmResult: PluginTransformHookResult = { - content: resource.code, + content: typeof resource === 'string' ? resource : resource!.code, moduleType: loader, sourceMap: JSON.stringify(resource.map), } diff --git a/src/farm/utils.ts b/src/farm/utils.ts index 5b9450e5..f0cfa0d9 100644 --- a/src/farm/utils.ts +++ b/src/farm/utils.ts @@ -1,5 +1,6 @@ import path from 'node:path' import * as querystring from 'node:querystring' +import type { TransformResult } from 'src/types' export * from '../utils' @@ -58,3 +59,11 @@ export function convertWatchEventChange( return watchEventChange[value] } + +export function resolveQuery(url: string) { + return querystring.parse(new URL(url).search.slice(1)) +} + +export function getContentValue(content: TransformResult): string { + return typeof content === 'string' ? content : content!.code +} From 47edb06ced77318d04097a283162ac96623ce149 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Sun, 24 Sep 2023 11:47:53 +0800 Subject: [PATCH 24/58] chore: update code --- package.json | 6 +-- pnpm-lock.yaml | 40 ++++++++-------- src/farm/context.ts | 41 ++++++++++++++++ src/farm/index.ts | 87 +++++++++++++++++++++------------- src/farm/utils.ts | 4 +- src/types.ts | 2 +- test/fixtures/load/unplugin.js | 12 +---- 7 files changed, 123 insertions(+), 69 deletions(-) create mode 100644 src/farm/context.ts diff --git a/package.json b/package.json index 7ebfbcc6..c3393b9f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "unplugin-test", - "version": "1.5.6", + "version": "1.5.7", "packageManager": "pnpm@8.7.5", "description": "Unified plugin system for build tools", "license": "MIT", @@ -44,8 +44,8 @@ "@ampproject/remapping": "^2.2.1", "@antfu/eslint-config": "^0.42.0", "@antfu/ni": "^0.21.8", - "@farmfe/cli": "^0.5.7", - "@farmfe/core": "^0.12.8", + "@farmfe/cli": "^0.5.8", + "@farmfe/core": "^0.12.10", "@rspack/cli": "^0.3.4", "@rspack/core": "^0.3.4", "@types/fs-extra": "^11.0.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c719492b..ee345a55 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -29,11 +29,11 @@ devDependencies: specifier: ^0.21.8 version: 0.21.8 '@farmfe/cli': - specifier: ^0.5.7 - version: 0.5.7 + specifier: ^0.5.8 + version: 0.5.8 '@farmfe/core': - specifier: ^0.12.8 - version: 0.12.8 + specifier: ^0.12.10 + version: 0.12.10 '@rspack/cli': specifier: ^0.3.4 version: 0.3.4(esbuild@0.19.3)(react-refresh@0.14.0)(webpack-cli@4.10.0) @@ -689,8 +689,8 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /@farmfe/cli@0.5.7: - resolution: {integrity: sha512-kO1oQFXuQpwRhOZY1fvZPRCIxWORLI66HnrbJM6ATVirZUiuonlTe14PpI4bnaUDOsnKpBhYOHmGYtWsQlwCJA==} + /@farmfe/cli@0.5.8: + resolution: {integrity: sha512-cX4cuGNgCkh0+aekCFWNFuiRM2kdWYNfWbln0yA4Te5fB4cjOZrXvLKO8UonLQ84Gl+lnReGQwu0kVm9Xju9Vg==} engines: {node: '>= 16'} hasBin: true dependencies: @@ -702,8 +702,8 @@ packages: walkdir: 0.4.1 dev: true - /@farmfe/core-darwin-arm64@0.12.8: - resolution: {integrity: sha512-RexuS0c0hMMpdXxbSufHrh4TvQpDt/v+DKnAvibZLgX4l4NpUWt1RACeOGr4NpP6gVsS0UR66LuPY/883vq5Vw==} + /@farmfe/core-darwin-arm64@0.12.10: + resolution: {integrity: sha512-xPxCaCZrdapRMStUU05a6ubrjhb6MC7pE8lZU83tJdp2CBGXKsctH5Q8u31fMsHxdC+cl8AhTVatlg7yhmPjyA==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] @@ -711,8 +711,8 @@ packages: dev: true optional: true - /@farmfe/core-darwin-x64@0.12.8: - resolution: {integrity: sha512-g4G41zs96tFHbCbRBQxBgFQCnxdVlsPILw7IzpoqGgWsb+aQQECA9dZaQ/vJ1vGoaI1L3/SvEyEh30lw1ZcgLA==} + /@farmfe/core-darwin-x64@0.12.10: + resolution: {integrity: sha512-FnTUK8djUhFKL+5pKWJ6DiVYk6NoIJ5HmkUip0zxK6kr1BufybMGf/DuO0rmSJoNMeglXk5Tb91zMg4sa51IBA==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] @@ -720,8 +720,8 @@ packages: dev: true optional: true - /@farmfe/core-linux-x64-gnu@0.12.8: - resolution: {integrity: sha512-/odx9eKYlYXQFskCvHk0VM97ED2o1zD+v6J9Bit2HL5zu3ozjjZCnJH3po2mes8moPtn4AQurO91VjuvuKSLMA==} + /@farmfe/core-linux-x64-gnu@0.12.10: + resolution: {integrity: sha512-eJAxyUOXJqDPVaDv+dZHEV9AfJF4DdXcqC5MC4sF/6e/+brNcissM+2LHkHOg6hRkFOAtv3qeHvAVWkv9xVQHQ==} engines: {node: '>= 10'} cpu: [x64] os: [linux] @@ -729,8 +729,8 @@ packages: dev: true optional: true - /@farmfe/core-win32-x64-msvc@0.12.8: - resolution: {integrity: sha512-4HFsIWrYW2WXFxZfJg4Usk4OZD6Ot/4GCKJBfghP7yrGmuCmfMUGdIBqbzFXLRyZI14mJhmBQd57/zUNu+tPCQ==} + /@farmfe/core-win32-x64-msvc@0.12.10: + resolution: {integrity: sha512-owiHGg57rVII+DghsLnbGI6VNRpOwEcPqypKZjKEQB+RK9VgBZz4aaG5o3g/1nf3ERYxQbwo7FQSogfcKbDcgQ==} engines: {node: '>= 10'} cpu: [x64] os: [win32] @@ -738,8 +738,8 @@ packages: dev: true optional: true - /@farmfe/core@0.12.8: - resolution: {integrity: sha512-bUmN09SOBzoMorphJZKmqeKn2fnEEB9xMO/falGYQGgUhdE1IIKUu5/OKSYdFF41jjm25e/iMJyJJVh8qbdGeQ==} + /@farmfe/core@0.12.10: + resolution: {integrity: sha512-4zYAgYa+dEJ7IN5Zd0SX+fxWjKiSCQSKocHyWHd4a1njzgraWsBQnvdCDQ5wefS53Pp7OC/+tBzohuiE/DbESA==} engines: {node: '>= 16'} dependencies: '@farmfe/runtime': 0.7.0 @@ -766,10 +766,10 @@ packages: zod: 3.21.4 zod-validation-error: 1.5.0(zod@3.21.4) optionalDependencies: - '@farmfe/core-darwin-arm64': 0.12.8 - '@farmfe/core-darwin-x64': 0.12.8 - '@farmfe/core-linux-x64-gnu': 0.12.8 - '@farmfe/core-win32-x64-msvc': 0.12.8 + '@farmfe/core-darwin-arm64': 0.12.10 + '@farmfe/core-darwin-x64': 0.12.10 + '@farmfe/core-linux-x64-gnu': 0.12.10 + '@farmfe/core-win32-x64-msvc': 0.12.10 transitivePeerDependencies: - bufferutil - debug diff --git a/src/farm/context.ts b/src/farm/context.ts new file mode 100644 index 00000000..236935de --- /dev/null +++ b/src/farm/context.ts @@ -0,0 +1,41 @@ +import { Buffer } from 'buffer' +import { extname } from 'path' +import { Parser } from 'acorn' +import type { CompilationContext } from '@farmfe/core' +import type { UnpluginBuildContext } from '..' + +export function createFarmContext( + context: CompilationContext, + currentResolveId?: string, +): UnpluginBuildContext & { + addWatchFile: (id: string, currentResolveId: string) => void + } { + return { + parse(code: string, opts: any = {}) { + return Parser.parse(code, { + sourceType: 'module', + ecmaVersion: 'latest', + locations: true, + ...opts, + }) + }, + + addWatchFile(id: string) { + context.addWatchFile(currentResolveId || id, id) + }, + emitFile(emittedFile) { + const outFileName = emittedFile.fileName || emittedFile.name + if (emittedFile.source && outFileName) { + context.emitFile({ + resolvedPath: outFileName, + name: outFileName, + content: [...Buffer.from(emittedFile.source)], + resourceType: extname(outFileName), + }) + } + }, + getWatchFiles() { + return context.getWatchFiles() + }, + } +} diff --git a/src/farm/index.ts b/src/farm/index.ts index 803294e4..84bfcf1c 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -1,4 +1,3 @@ -import fs from 'fs' import path from 'path' import type { PluginLoadHookParam, @@ -7,9 +6,10 @@ import type { PluginTransformHookParam, PluginTransformHookResult, } from '@farmfe/core/binding' -import type { JsPlugin } from '@farmfe/core' +import type { CompilationContext, JsPlugin } from '@farmfe/core' import type { TransformResult, + UnpluginContext, UnpluginContextMeta, UnpluginFactory, UnpluginInstance, @@ -25,6 +25,7 @@ import { resolveQuery, transformQuery, } from './utils' +import { createFarmContext } from './context' export function getFarmPlugin< UserOptions = Record, Nested extends boolean = boolean, @@ -43,7 +44,7 @@ export function getFarmPlugin< }) return plugins.length === 1 ? plugins[0] : plugins - }) as UnpluginInstance['rollup'] + }) as UnpluginInstance['farm'] } export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { @@ -64,8 +65,8 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { if (plugin.buildStart) { const _buildStart = plugin.buildStart farmPlugin.buildStart = { - async executor(_, hook) { - await _buildStart.call(hook) + async executor(_, context) { + await _buildStart.call(createFarmContext(context!)) }, } as JsPlugin['buildStart'] } @@ -84,23 +85,32 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { const kindWithEntry = params.kind as { entry: string } isEntry = kindWithEntry.entry === 'index' } - const resolvedPath = await _resolveId( + const resolveIdResult = await _resolveId( params.source, resolvedIdPath ?? null, { isEntry }, ) - if (resolvedPath && typeof resolvedPath === 'string') { + if (typeof resolveIdResult === 'string') { return { - resolvedPath, - query: [], // TODO queryString + resolvedPath: resolveIdResult, + query: resolveQuery(resolveIdResult), sideEffects: false, external: false, meta: {}, } } + else if (typeof resolveIdResult === 'object') { + return { + resolvedPath: resolveIdResult?.id, + query: resolveQuery(resolveIdResult!.id), + sideEffects: false, + external: resolveIdResult?.external, + meta: {}, + } + } return null }, - } as JsPlugin['resolve'] + } as unknown as JsPlugin['resolve'] } if (plugin.load) { @@ -111,16 +121,30 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { }, async executor( id: PluginLoadHookParam, + context, ): Promise { if (plugin.loadInclude && !plugin.loadInclude(id.resolvedPath)) return null const loader = guessIdLoader(id.resolvedPath) const shouldLoadInclude = plugin.loadInclude && plugin.loadInclude(id.resolvedPath) - const content: TransformResult = await _load.call(this, id.resolvedPath) + const farmContext = createFarmContext(context!, id.resolvedPath) + const unpluginContext: UnpluginContext = { + error: error => + context!.error( + typeof error === 'string' ? new Error(error) : error, + ), + warn: error => + context!.warn(typeof error === 'string' ? new Error(error) : error), + } + + const content: TransformResult = await _load.call( + Object.assign(unpluginContext, farmContext), + id.resolvedPath, + ) const loadFarmResult: PluginLoadHookResult = { // TODO maybe sourcemap resolve - content: typeof content === 'string' ? content : content!.code, + content: getContentValue(content), moduleType: loader, } if (shouldLoadInclude) @@ -135,7 +159,10 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { const _transform = plugin.transform farmPlugin.transform = { filters: { resolvedPaths: ['.*'] }, - async executor(params: PluginTransformHookParam) { + async executor( + params: PluginTransformHookParam, + context: CompilationContext, + ) { if (params.query.length) transformQuery(params) @@ -149,15 +176,23 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { const shouldTransformInclude = plugin.transformInclude && plugin.transformInclude(params.resolvedPath) + const farmContext = createFarmContext(context, params.resolvedPath) + const unpluginContext: UnpluginContext = { + error: error => + context.error(typeof error === 'string' ? new Error(error) : error), + warn: error => + context.warn(typeof error === 'string' ? new Error(error) : error), + } + const resource: TransformResult = await _transform.call( - this, + Object.assign(unpluginContext, farmContext), params.content, params.resolvedPath, ) if (resource && typeof resource !== 'string') { const transformFarmResult: PluginTransformHookResult = { - content: typeof resource === 'string' ? resource : resource!.code, + content: getContentValue(resource), moduleType: loader, sourceMap: JSON.stringify(resource.map), } @@ -173,14 +208,16 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { if (plugin.watchChange) { const _watchChange = plugin.watchChange farmPlugin.updateModules = { - async executor(param) { + async executor(param, context) { // To be compatible with unplugin, we ensure that only one file is changed at a time. const updatePathContent = param.paths[0] const ModifiedPath = updatePathContent[0] const eventChange = convertWatchEventChange( updatePathContent[1] as WatchChangeEvents, ) - await _watchChange.call(this, ModifiedPath, { event: eventChange }) + await _watchChange.call(createFarmContext(context!), ModifiedPath, { + event: eventChange, + }) }, } as JsPlugin['updateModules'] } @@ -189,7 +226,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { const _buildEnd = plugin.buildEnd farmPlugin.buildEnd = { async executor(_, context) { - await _buildEnd.call(context) + await _buildEnd.call(createFarmContext(context!)) }, } as JsPlugin['buildEnd'] } @@ -205,17 +242,3 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { return farmPlugin } - -/** - * Degree of completion - * enforce ✅ - * buildStart ✅ - * resolveId ✅ - * loadInclude ✅ - * load ✅ - * transformInclude ✅ - * transform ✅ - * watchChange ✅ - * buildEnd ✅ - * writeBundle ✅ - */ diff --git a/src/farm/utils.ts b/src/farm/utils.ts index f0cfa0d9..7519bf9f 100644 --- a/src/farm/utils.ts +++ b/src/farm/utils.ts @@ -50,12 +50,12 @@ export function convertEnforceToPriority(value: 'pre' | 'post' | undefined) { export function convertWatchEventChange( value: WatchChangeEvents, -) { +): WatchChangeEvents { const watchEventChange = { Added: 'create', Updated: 'update', Removed: 'delete', - } as unknown as { [key in WatchChangeEvents]: string } + } as unknown as { [key in WatchChangeEvents]: WatchChangeEvents } return watchEventChange[value] } diff --git a/src/types.ts b/src/types.ts index 081c1d2b..aec955be 100644 --- a/src/types.ts +++ b/src/types.ts @@ -101,8 +101,8 @@ export interface UnpluginInstance vite: UnpluginFactoryOutput : VitePlugin> webpack: UnpluginFactoryOutput rspack: UnpluginFactoryOutput - farm: UnpluginFactoryOutput : RollupPlugin> esbuild: UnpluginFactoryOutput + farm: UnpluginFactoryOutput raw: UnpluginFactory } diff --git a/test/fixtures/load/unplugin.js b/test/fixtures/load/unplugin.js index 666c39f7..02a96bac 100644 --- a/test/fixtures/load/unplugin.js +++ b/test/fixtures/load/unplugin.js @@ -9,11 +9,7 @@ module.exports = createUnplugin((options) => { loadInclude(id) { return targetFileReg.test(id) }, - buildStart() { - }, - resolveId() { - }, - load(id) { + async load(id) { const code = fs.readFileSync(id, { encoding: 'utf-8' }) const str = new MagicString(code) const _index = code.indexOf('msg') @@ -43,11 +39,5 @@ module.exports = createUnplugin((options) => { }), } }, - watchChange() { - }, - buildEnd() { - }, - writeBundle() { - }, } }) From 2a10dec01f6e971fe3c7ba9c1b6a3fc365602e67 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Sun, 24 Sep 2023 12:02:43 +0800 Subject: [PATCH 25/58] chore: update code --- package.json | 4 ++-- pnpm-lock.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index c3393b9f..6fbec1c7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "unplugin-test", - "version": "1.5.7", + "name": "unplugin", + "version": "1.5.0", "packageManager": "pnpm@8.7.5", "description": "Unified plugin system for build tools", "license": "MIT", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ee345a55..cadd831e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: '6.0' +lockfileVersion: '6.1' settings: autoInstallPeers: true From 0273a7f118772bb1c68d1384ef6baae418fac4ae Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Sun, 24 Sep 2023 12:18:42 +0800 Subject: [PATCH 26/58] chore: update readme --- README.md | 78 ++++++++++++++++++++++++++++++++++----------------- src/define.ts | 6 ++++ 2 files changed, 59 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index e70d0653..dce9e028 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Currently supports: - [Webpack](https://webpack.js.org/) - [esbuild](https://esbuild.github.io/) - [Rspack](https://www.rspack.dev/) (⚠️ experimental) -- [Farm](https://farm-fe.github.io/) (⚠️ experimental) +- [Farm](https://farm-fe.github.io/) ## Hooks @@ -21,18 +21,18 @@ Currently supports: ###### Supported -| Hook | Rollup | Vite | Webpack 4 | Webpack 5 | esbuild | Rspack | Farm | -| ----------------------------------------------------------------------- | :-------------: | :--: | :-------: | :-------: | :-------------: | :----: | ---- | -| [`enforce`](https://rollupjs.org/guide/en/#enforce) | ❌ 1 | ✅ | ✅ | ✅ | ❌ 1 | ✅ | ✅ | -| [`buildStart`](https://rollupjs.org/guide/en/#buildstart) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`resolveId`](https://rollupjs.org/guide/en/#resolveid) | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | -| `loadInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`load`](https://rollupjs.org/guide/en/#load) | ✅ | ✅ | ✅ | ✅ | ✅ 3 | ✅ | ✅ | -| `transformInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`transform`](https://rollupjs.org/guide/en/#transformers) | ✅ | ✅ | ✅ | ✅ | ✅ 3 | ✅ | ✅ | -| [`watchChange`](https://rollupjs.org/guide/en/#watchchange) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | -| [`buildEnd`](https://rollupjs.org/guide/en/#buildend) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`writeBundle`](https://rollupjs.org/guide/en/#writebundle)4 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| Hook | Rollup | Vite | Webpack 4 | Webpack 5 | esbuild | Rspack | Farm | +| ----------------------------------------------------------------------- | :------------: | :---: | :-------: | :-------: | :------------: | :----: | ---- | +| [`enforce`](https://rollupjs.org/guide/en/#enforce) | ❌ 1 | ✅ | ✅ | ✅ | ❌ 1 | ✅ | ✅ | +| [`buildStart`](https://rollupjs.org/guide/en/#buildstart) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`resolveId`](https://rollupjs.org/guide/en/#resolveid) | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | +| `loadInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`load`](https://rollupjs.org/guide/en/#load) | ✅ | ✅ | ✅ | ✅ | ✅ 3 | ✅ | ✅ | +| `transformInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`transform`](https://rollupjs.org/guide/en/#transformers) | ✅ | ✅ | ✅ | ✅ | ✅ 3 | ✅ | ✅ | +| [`watchChange`](https://rollupjs.org/guide/en/#watchchange) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | +| [`buildEnd`](https://rollupjs.org/guide/en/#buildend) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`writeBundle`](https://rollupjs.org/guide/en/#writebundle)4 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | 1. Rollup and esbuild do not support using `enforce` to control the order of plugins. Users need to maintain the order manually. 2. Webpack's id filter is outside of loader logic; an additional hook is needed for better perf on Webpack. In Rollup and Vite, this hook has been polyfilled to match the behaviors. See for the following usage examples. @@ -45,14 +45,14 @@ Currently supports: ###### Supported -| Hook | Rollup | Vite | Webpack 4 | Webpack 5 | esbuild | Rspack | -| -------------------------------------------------------------------------- | :----: | :--: | :-------: | :-------: | :-----: | :----: | -| [`this.parse`](https://rollupjs.org/guide/en/#thisparse) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`this.addWatchFile`](https://rollupjs.org/guide/en/#thisaddwatchfile) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | -| [`this.emitFile`](https://rollupjs.org/guide/en/#thisemitfile)5 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`this.getWatchFiles`](https://rollupjs.org/guide/en/#thisgetwatchfiles) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | -| [`this.warn`](https://rollupjs.org/guide/en/#thiswarn) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`this.error`](https://rollupjs.org/guide/en/#thiserror) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| Hook | Rollup | Vite | Webpack 4 | Webpack 5 | esbuild | Rspack | Farm | +| -------------------------------------------------------------------------- | :----: | :---: | :-------: | :-------: | :-----: | :----: | :---: | +| [`this.parse`](https://rollupjs.org/guide/en/#thisparse) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`this.addWatchFile`](https://rollupjs.org/guide/en/#thisaddwatchfile) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | +| [`this.emitFile`](https://rollupjs.org/guide/en/#thisemitfile)5 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`this.getWatchFiles`](https://rollupjs.org/guide/en/#thisgetwatchfiles) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | +| [`this.warn`](https://rollupjs.org/guide/en/#thiswarn) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`this.error`](https://rollupjs.org/guide/en/#thiserror) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | 5. Currently, [`this.emitFile`](https://rollupjs.org/guide/en/#thisemitfile) only supports the `EmittedAsset` variant. @@ -82,6 +82,7 @@ export const rollupPlugin = unplugin.rollup export const webpackPlugin = unplugin.webpack export const rspackPlugin = unplugin.rspack export const esbuildPlugin = unplugin.esbuild +export const farmPlugin = unplugin.farm ``` ## Nested Plugins @@ -90,9 +91,9 @@ Since `v0.10.0`, unplugin supports constructing multiple nested plugins to behav ###### Supported -| Rollup | Vite | Webpack 4 | Webpack 5 | Rspack | esbuild | -| :--------------------: | :--: | :-------: | :-------: | :----: | :------------: | -| ✅ `>=3.1`6 | ✅ | ✅ | ✅ | ✅ | ⚠️7 | +| Rollup | Vite | Webpack 4 | Webpack 5 | Rspack | esbuild | Farm | +| :-------------------: | :---: | :-------: | :-------: | :----: | :-----------: | :---: | +| ✅ `>=3.1`6 | ✅ | ✅ | ✅ | ✅ | ⚠️7 | ✅ | 6. Rollup supports nested plugins since [v3.1.0](https://github.com/rollup/rollup/releases/tag/v3.1.0). Plugin author should ask users to have a Rollup version of `>=3.1.0` when using nested plugins. For single plugin format, unplugin works for any version of Rollup. 7. Since esbuild does not have a built-in transform phase, the `transform` hook of the nested plugin will not work on esbuild yet. Other hooks like `load` or `resolveId` work fine. We will try to find a way to support it in the future. @@ -193,13 +194,28 @@ module.exports = { } ``` +###### Farm + +```ts +// farm.config.ts +import UnpluginFeature from './unplugin-feature' + +export default { + plugins: [ + UnpluginFeature.farm({ + /* options */ + }), + ], +} +``` + ### Framework-specific Logic While `unplugin` provides compatible layers for some hooks, the functionality of it is limited to the common subset of the build's plugins capability. For more advanced framework-specific usages, `unplugin` provides an escape hatch for that. ```ts export const unplugin = createUnplugin((options: UserOptions, meta) => { - console.log(meta.framework) // 'vite' | 'rollup' | 'webpack' | 'rspack' | 'esbuild' + console.log(meta.framework) // 'vite' | 'rollup' | 'webpack' | 'rspack' | 'esbuild' | 'farm' return { // Common unplugin hooks @@ -238,6 +254,14 @@ export const unplugin = createUnplugin((options: UserOptions, meta) => { // Or you can completely replace the setup logic // setup?: EsbuildPlugin.setup, }, + farm: { + config(config) { + // Configure Farm config + }, + configDevServer(server) { + // Configure Farm dev server + }, + } } }) ``` @@ -250,6 +274,7 @@ Each of the function takes the same generic factory argument as `createUnplugin` ```ts import { createEsbuildPlugin, + createFarmPlugin, createRollupPlugin, createRspackPlugin, createVitePlugin, @@ -271,6 +296,9 @@ const webpackPlugin = createWebpackPlugin({ const rspackPlugin = createRspackPlugin({ /* options */ }) +const farmPlugin = createFarmPlugin({ + /* options */ +}) ``` ## Conventions diff --git a/src/define.ts b/src/define.ts index 61039036..3f65bdfc 100644 --- a/src/define.ts +++ b/src/define.ts @@ -65,3 +65,9 @@ export function createRspackPlugin( + factory: UnpluginFactory, +) { + return getFarmPlugin(factory) +} From 5403b81d89246125b0cc984101dcdec2666f20c5 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Sun, 24 Sep 2023 12:23:03 +0800 Subject: [PATCH 27/58] chore: update code --- src/farm/index.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/farm/index.ts b/src/farm/index.ts index 84bfcf1c..79f17179 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -52,15 +52,15 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { name: plugin.name, priority: convertEnforceToPriority(plugin.enforce), } - - if (plugin.farm?.config) - farmPlugin.config = plugin.farm.config - - if (plugin.farm?.configDevServer) - farmPlugin.configDevServer = plugin.farm.configDevServer - - if (plugin.farm?.updateModules) - farmPlugin.updateModules = plugin.farm.updateModules + if (plugin.farm) { + const { config, configDevServer, updateModules } = plugin.farm + if (config) + farmPlugin.config = config + if (configDevServer) + farmPlugin.configDevServer = configDevServer + if (updateModules) + farmPlugin.updateModules = updateModules + } if (plugin.buildStart) { const _buildStart = plugin.buildStart From e3cc911300df5d35392591127e22ac611f4394c6 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Sun, 24 Sep 2023 12:30:50 +0800 Subject: [PATCH 28/58] chore: update code --- scripts/buildFixtures.ts | 5 +---- test/fixtures/load/unplugin.js | 4 +++- test/fixtures/transform/unplugin.js | 2 ++ 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/buildFixtures.ts b/scripts/buildFixtures.ts index 4cd21600..702470f3 100644 --- a/scripts/buildFixtures.ts +++ b/scripts/buildFixtures.ts @@ -24,10 +24,7 @@ async function run() { console.log(c.red(c.inverse(c.bold('\n Rollup '))), name, '\n') execSync('npx rollup --version', { cwd: path, stdio: 'inherit' }) - execSync('npx rollup --bundleConfigAsCjs -c', { - cwd: path, - stdio: 'inherit', - }) + execSync('npx rollup --bundleConfigAsCjs -c', { cwd: path, stdio: 'inherit' }) console.log(c.blue(c.inverse(c.bold('\n Webpack '))), name, '\n') execSync('npx webpack --version', { cwd: path, stdio: 'inherit' }) diff --git a/test/fixtures/load/unplugin.js b/test/fixtures/load/unplugin.js index 02a96bac..f8055002 100644 --- a/test/fixtures/load/unplugin.js +++ b/test/fixtures/load/unplugin.js @@ -9,11 +9,12 @@ module.exports = createUnplugin((options) => { loadInclude(id) { return targetFileReg.test(id) }, - async load(id) { + load(id) { const code = fs.readFileSync(id, { encoding: 'utf-8' }) const str = new MagicString(code) const _index = code.indexOf('msg') const loadInjectedCode = 'msg -> through the load hook -> __unplugin__' + str.overwrite(_index, _index + 'msg'.length, loadInjectedCode) return str.toString() }, @@ -25,6 +26,7 @@ module.exports = createUnplugin((options) => { const index = code.indexOf('__unplugin__') if (index === -1) return null + const injectedCode = `transform-[Injected ${options.msg}]` if (code.includes(injectedCode)) diff --git a/test/fixtures/transform/unplugin.js b/test/fixtures/transform/unplugin.js index ad352fb6..a014daca 100644 --- a/test/fixtures/transform/unplugin.js +++ b/test/fixtures/transform/unplugin.js @@ -24,10 +24,12 @@ module.exports = createUnplugin((options, meta) => { return null const injectedCode = `[Injected ${options.msg}]` + if (id.includes(injectedCode)) throw new Error('File was already transformed') s.overwrite(index, index + '__UNPLUGIN__'.length, injectedCode) + return { code: s.toString(), map: s.generateMap({ From 95a415f37ec5ca9aa211020048498eddf850ab8e Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Sun, 24 Sep 2023 12:32:57 +0800 Subject: [PATCH 29/58] chore: update readme --- README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index dce9e028..a213665b 100644 --- a/README.md +++ b/README.md @@ -21,18 +21,18 @@ Currently supports: ###### Supported -| Hook | Rollup | Vite | Webpack 4 | Webpack 5 | esbuild | Rspack | Farm | -| ----------------------------------------------------------------------- | :------------: | :---: | :-------: | :-------: | :------------: | :----: | ---- | -| [`enforce`](https://rollupjs.org/guide/en/#enforce) | ❌ 1 | ✅ | ✅ | ✅ | ❌ 1 | ✅ | ✅ | -| [`buildStart`](https://rollupjs.org/guide/en/#buildstart) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`resolveId`](https://rollupjs.org/guide/en/#resolveid) | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | -| `loadInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`load`](https://rollupjs.org/guide/en/#load) | ✅ | ✅ | ✅ | ✅ | ✅ 3 | ✅ | ✅ | -| `transformInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`transform`](https://rollupjs.org/guide/en/#transformers) | ✅ | ✅ | ✅ | ✅ | ✅ 3 | ✅ | ✅ | -| [`watchChange`](https://rollupjs.org/guide/en/#watchchange) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | -| [`buildEnd`](https://rollupjs.org/guide/en/#buildend) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`writeBundle`](https://rollupjs.org/guide/en/#writebundle)4 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| Hook | Rollup | Vite | Webpack 4 | Webpack 5 | esbuild | Rspack | Farm | +| ----------------------------------------------------------------------- | :--------------: | :---: | :-------: | :------------: | :------------: | :----: | :---: | +| [`enforce`](https://rollupjs.org/guide/en/#enforce) | ❌ 1 ✅ | ✅ | ✅ | ❌ 1 | ✅ | ✅ | +| [`buildStart`](https://rollupjs.org/guide/en/#buildstart) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`resolveId`](https://rollupjs.org/guide/en/#resolveid) | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | +| `loadInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`load`](https://rollupjs.org/guide/en/#load) | ✅ | ✅ | ✅ | ✅ | ✅ 3 | ✅ | ✅ | +| `transformInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`transform`](https://rollupjs.org/guide/en/#transformers) | ✅ | ✅ | ✅ | ✅ | ✅ 3 | ✅ | ✅ | +| [`watchChange`](https://rollupjs.org/guide/en/#watchchange) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | +| [`buildEnd`](https://rollupjs.org/guide/en/#buildend) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`writeBundle`](https://rollupjs.org/guide/en/#writebundle)4 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | 1. Rollup and esbuild do not support using `enforce` to control the order of plugins. Users need to maintain the order manually. 2. Webpack's id filter is outside of loader logic; an additional hook is needed for better perf on Webpack. In Rollup and Vite, this hook has been polyfilled to match the behaviors. See for the following usage examples. From 375249695b740887dab10b68644c0412bdb1e5fb Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Sun, 24 Sep 2023 19:00:39 +0800 Subject: [PATCH 30/58] chore: update readme --- README.md | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index a213665b..90453247 100644 --- a/README.md +++ b/README.md @@ -22,17 +22,17 @@ Currently supports: ###### Supported | Hook | Rollup | Vite | Webpack 4 | Webpack 5 | esbuild | Rspack | Farm | -| ----------------------------------------------------------------------- | :--------------: | :---: | :-------: | :------------: | :------------: | :----: | :---: | -| [`enforce`](https://rollupjs.org/guide/en/#enforce) | ❌ 1 ✅ | ✅ | ✅ | ❌ 1 | ✅ | ✅ | -| [`buildStart`](https://rollupjs.org/guide/en/#buildstart) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`resolveId`](https://rollupjs.org/guide/en/#resolveid) | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | -| `loadInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`load`](https://rollupjs.org/guide/en/#load) | ✅ | ✅ | ✅ | ✅ | ✅ 3 | ✅ | ✅ | -| `transformInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`transform`](https://rollupjs.org/guide/en/#transformers) | ✅ | ✅ | ✅ | ✅ | ✅ 3 | ✅ | ✅ | -| [`watchChange`](https://rollupjs.org/guide/en/#watchchange) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | -| [`buildEnd`](https://rollupjs.org/guide/en/#buildend) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`writeBundle`](https://rollupjs.org/guide/en/#writebundle)4 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| ----------------------------------------------------------------------- | :--------------: | :--: | :-------: | :-------: | :------------: | :----: | :--: | +| [`enforce`](https://rollupjs.org/guide/en/#enforce) | ❌ 1 | ✅ | ✅ | ❌ 1 | ✅ | ✅ | ✅ | +| [`buildStart`](https://rollupjs.org/guide/en/#buildstart) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`resolveId`](https://rollupjs.org/guide/en/#resolveid) | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | +| `loadInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`load`](https://rollupjs.org/guide/en/#load) | ✅ | ✅ | ✅ | ✅ | ✅ 3 | ✅ | ✅ | +| `transformInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`transform`](https://rollupjs.org/guide/en/#transformers) | ✅ | ✅ | ✅ | ✅ | ✅ 3 | ✅ | ✅ | +| [`watchChange`](https://rollupjs.org/guide/en/#watchchange) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | +| [`buildEnd`](https://rollupjs.org/guide/en/#buildend) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`writeBundle`](https://rollupjs.org/guide/en/#writebundle)4 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | 1. Rollup and esbuild do not support using `enforce` to control the order of plugins. Users need to maintain the order manually. 2. Webpack's id filter is outside of loader logic; an additional hook is needed for better perf on Webpack. In Rollup and Vite, this hook has been polyfilled to match the behaviors. See for the following usage examples. @@ -46,13 +46,13 @@ Currently supports: ###### Supported | Hook | Rollup | Vite | Webpack 4 | Webpack 5 | esbuild | Rspack | Farm | -| -------------------------------------------------------------------------- | :----: | :---: | :-------: | :-------: | :-----: | :----: | :---: | -| [`this.parse`](https://rollupjs.org/guide/en/#thisparse) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`this.addWatchFile`](https://rollupjs.org/guide/en/#thisaddwatchfile) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | -| [`this.emitFile`](https://rollupjs.org/guide/en/#thisemitfile)5 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`this.getWatchFiles`](https://rollupjs.org/guide/en/#thisgetwatchfiles) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | -| [`this.warn`](https://rollupjs.org/guide/en/#thiswarn) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`this.error`](https://rollupjs.org/guide/en/#thiserror) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| -------------------------------------------------------------------------- | :----: | :--: | :------: | :------: | :-----: | :----: | :--: | +| [`this.parse`](https://rollupjs.org/guide/en/#thisparse) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`this.addWatchFile`](https://rollupjs.org/guide/en/#thisaddwatchfile) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | +| [`this.emitFile`](https://rollupjs.org/guide/en/#thisemitfile)5 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`this.getWatchFiles`](https://rollupjs.org/guide/en/#thisgetwatchfiles) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | +| [`this.warn`](https://rollupjs.org/guide/en/#thiswarn) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`this.error`](https://rollupjs.org/guide/en/#thiserror) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | 5. Currently, [`this.emitFile`](https://rollupjs.org/guide/en/#thisemitfile) only supports the `EmittedAsset` variant. From e9e09ab417c2b306fcbcb0cc1192880c454adaf9 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Sun, 24 Sep 2023 19:02:40 +0800 Subject: [PATCH 31/58] chore: update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 90453247..405c7bfc 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Currently supports: | Hook | Rollup | Vite | Webpack 4 | Webpack 5 | esbuild | Rspack | Farm | | ----------------------------------------------------------------------- | :--------------: | :--: | :-------: | :-------: | :------------: | :----: | :--: | -| [`enforce`](https://rollupjs.org/guide/en/#enforce) | ❌ 1 | ✅ | ✅ | ❌ 1 | ✅ | ✅ | ✅ | +| [`enforce`](https://rollupjs.org/guide/en/#enforce) | ❌ 1 | ✅ | ✅ | ✅ | ❌ 1 | ✅ | ✅ | | [`buildStart`](https://rollupjs.org/guide/en/#buildstart) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | [`resolveId`](https://rollupjs.org/guide/en/#resolveid) | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | | `loadInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | From 8f1daa70907d6d316cb8c2dbc5ba7716c745f32b Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Sun, 24 Sep 2023 19:05:57 +0800 Subject: [PATCH 32/58] chore: update readme --- README.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 405c7bfc..3158cd0a 100644 --- a/README.md +++ b/README.md @@ -22,17 +22,17 @@ Currently supports: ###### Supported | Hook | Rollup | Vite | Webpack 4 | Webpack 5 | esbuild | Rspack | Farm | -| ----------------------------------------------------------------------- | :--------------: | :--: | :-------: | :-------: | :------------: | :----: | :--: | -| [`enforce`](https://rollupjs.org/guide/en/#enforce) | ❌ 1 | ✅ | ✅ | ✅ | ❌ 1 | ✅ | ✅ | -| [`buildStart`](https://rollupjs.org/guide/en/#buildstart) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`resolveId`](https://rollupjs.org/guide/en/#resolveid) | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | -| `loadInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`load`](https://rollupjs.org/guide/en/#load) | ✅ | ✅ | ✅ | ✅ | ✅ 3 | ✅ | ✅ | -| `transformInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`transform`](https://rollupjs.org/guide/en/#transformers) | ✅ | ✅ | ✅ | ✅ | ✅ 3 | ✅ | ✅ | -| [`watchChange`](https://rollupjs.org/guide/en/#watchchange) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | -| [`buildEnd`](https://rollupjs.org/guide/en/#buildend) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`writeBundle`](https://rollupjs.org/guide/en/#writebundle)4 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| ----------------------------------------------------------------------- | :-------------: | :--: | :-------: | :-------: | :------------: | :----: | :--: | +| [`enforce`](https://rollupjs.org/guide/en/#enforce) | ❌ 1 | ✅ | ✅ | ✅ | ❌ 1 | ✅ | ✅ | +| [`buildStart`](https://rollupjs.org/guide/en/#buildstart) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`resolveId`](https://rollupjs.org/guide/en/#resolveid) | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | +| `loadInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`load`](https://rollupjs.org/guide/en/#load) | ✅ | ✅ | ✅ | ✅ | ✅ 3 | ✅ | ✅ | +| `transformInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`transform`](https://rollupjs.org/guide/en/#transformers) | ✅ | ✅ | ✅ | ✅ | ✅ 3 | ✅ | ✅ | +| [`watchChange`](https://rollupjs.org/guide/en/#watchchange) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | +| [`buildEnd`](https://rollupjs.org/guide/en/#buildend) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`writeBundle`](https://rollupjs.org/guide/en/#writebundle)4 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | 1. Rollup and esbuild do not support using `enforce` to control the order of plugins. Users need to maintain the order manually. 2. Webpack's id filter is outside of loader logic; an additional hook is needed for better perf on Webpack. In Rollup and Vite, this hook has been polyfilled to match the behaviors. See for the following usage examples. @@ -47,12 +47,12 @@ Currently supports: | Hook | Rollup | Vite | Webpack 4 | Webpack 5 | esbuild | Rspack | Farm | | -------------------------------------------------------------------------- | :----: | :--: | :------: | :------: | :-----: | :----: | :--: | -| [`this.parse`](https://rollupjs.org/guide/en/#thisparse) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`this.addWatchFile`](https://rollupjs.org/guide/en/#thisaddwatchfile) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | -| [`this.emitFile`](https://rollupjs.org/guide/en/#thisemitfile)5 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`this.getWatchFiles`](https://rollupjs.org/guide/en/#thisgetwatchfiles) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | -| [`this.warn`](https://rollupjs.org/guide/en/#thiswarn) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`this.error`](https://rollupjs.org/guide/en/#thiserror) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`this.parse`](https://rollupjs.org/guide/en/#thisparse) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`this.addWatchFile`](https://rollupjs.org/guide/en/#thisaddwatchfile) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | +| [`this.emitFile`](https://rollupjs.org/guide/en/#thisemitfile)5 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`this.getWatchFiles`](https://rollupjs.org/guide/en/#thisgetwatchfiles) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | +| [`this.warn`](https://rollupjs.org/guide/en/#thiswarn) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`this.error`](https://rollupjs.org/guide/en/#thiserror) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | 5. Currently, [`this.emitFile`](https://rollupjs.org/guide/en/#thisemitfile) only supports the `EmittedAsset` variant. From 30fc86c58aa27f0a5ba9f95519454038857c5134 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Sun, 24 Sep 2023 19:47:36 +0800 Subject: [PATCH 33/58] chore: update code --- src/farm/index.ts | 8 +++++--- src/farm/utils.ts | 8 ++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/farm/index.ts b/src/farm/index.ts index 79f17179..a064f19f 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -22,6 +22,8 @@ import { convertWatchEventChange, getContentValue, guessIdLoader, + isObject, + isString, resolveQuery, transformQuery, } from './utils' @@ -81,7 +83,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { params.importer?.relativePath ?? '', ) let isEntry = false - if (typeof params.kind === 'object' && 'entry' in params.kind) { + if (isObject(params.kind) && 'entry' in params.kind) { const kindWithEntry = params.kind as { entry: string } isEntry = kindWithEntry.entry === 'index' } @@ -90,7 +92,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { resolvedIdPath ?? null, { isEntry }, ) - if (typeof resolveIdResult === 'string') { + if (isString(resolveIdResult)) { return { resolvedPath: resolveIdResult, query: resolveQuery(resolveIdResult), @@ -99,7 +101,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { meta: {}, } } - else if (typeof resolveIdResult === 'object') { + else if (isObject(resolveIdResult)) { return { resolvedPath: resolveIdResult?.id, query: resolveQuery(resolveIdResult!.id), diff --git a/src/farm/utils.ts b/src/farm/utils.ts index 7519bf9f..d3ceb9fd 100644 --- a/src/farm/utils.ts +++ b/src/farm/utils.ts @@ -67,3 +67,11 @@ export function resolveQuery(url: string) { export function getContentValue(content: TransformResult): string { return typeof content === 'string' ? content : content!.code } + +export function isString(variable: unknown): variable is string { + return typeof variable === 'string' +} + +export function isObject(variable: unknown): variable is object { + return typeof variable === 'object' && variable !== null +} From f28d6e7466a56bb872fae424abd65f3b79a9377b Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Sun, 24 Sep 2023 20:00:20 +0800 Subject: [PATCH 34/58] chore: update resolveId error --- src/farm/index.ts | 6 +++--- src/farm/utils.ts | 19 +++++++++++++++---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/farm/index.ts b/src/farm/index.ts index a064f19f..64e2d98b 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -20,11 +20,11 @@ import type { WatchChangeEvents } from './utils' import { convertEnforceToPriority, convertWatchEventChange, + customParseQueryString, getContentValue, guessIdLoader, isObject, isString, - resolveQuery, transformQuery, } from './utils' import { createFarmContext } from './context' @@ -95,7 +95,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { if (isString(resolveIdResult)) { return { resolvedPath: resolveIdResult, - query: resolveQuery(resolveIdResult), + query: customParseQueryString(resolveIdResult), sideEffects: false, external: false, meta: {}, @@ -104,7 +104,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { else if (isObject(resolveIdResult)) { return { resolvedPath: resolveIdResult?.id, - query: resolveQuery(resolveIdResult!.id), + query: customParseQueryString(resolveIdResult!.id), sideEffects: false, external: resolveIdResult?.external, meta: {}, diff --git a/src/farm/utils.ts b/src/farm/utils.ts index d3ceb9fd..58d0063d 100644 --- a/src/farm/utils.ts +++ b/src/farm/utils.ts @@ -60,10 +60,6 @@ export function convertWatchEventChange( return watchEventChange[value] } -export function resolveQuery(url: string) { - return querystring.parse(new URL(url).search.slice(1)) -} - export function getContentValue(content: TransformResult): string { return typeof content === 'string' ? content : content!.code } @@ -75,3 +71,18 @@ export function isString(variable: unknown): variable is string { export function isObject(variable: unknown): variable is object { return typeof variable === 'object' && variable !== null } + +export function customParseQueryString(url: string | null) { + if (!url) + return [] + + const queryString = url.split('?')[1] + + const parsedParams = querystring.parse(queryString) + const paramsArray = [] + + for (const key in parsedParams) + paramsArray.push([key, parsedParams[key]]) + + return paramsArray +} From 315ddb0a6a46e53adcb84984914013bb035aba9c Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Mon, 25 Sep 2023 15:49:16 +0800 Subject: [PATCH 35/58] chore: update readme --- README.md | 65 +++++++++++++++++-------------------------------------- 1 file changed, 20 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 3158cd0a..8520111b 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Currently supports: - [Webpack](https://webpack.js.org/) - [esbuild](https://esbuild.github.io/) - [Rspack](https://www.rspack.dev/) (⚠️ experimental) -- [Farm](https://farm-fe.github.io/) +- [Farm](https://farm-fe.github.io/) (⚠️ experimental) ## Hooks @@ -23,7 +23,7 @@ Currently supports: | Hook | Rollup | Vite | Webpack 4 | Webpack 5 | esbuild | Rspack | Farm | | ----------------------------------------------------------------------- | :-------------: | :--: | :-------: | :-------: | :------------: | :----: | :--: | -| [`enforce`](https://rollupjs.org/guide/en/#enforce) | ❌ 1 | ✅ | ✅ | ✅ | ❌ 1 | ✅ | ✅ | +| [`enforce`](https://rollupjs.org/guide/en/#enforce) | ❌ 1 | ✅ | ✅ | ✅ | ❌ 1 | ✅ | ✅ | | [`buildStart`](https://rollupjs.org/guide/en/#buildstart) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | [`resolveId`](https://rollupjs.org/guide/en/#resolveid) | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | | `loadInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | @@ -39,7 +39,7 @@ Currently supports: 3. Although esbuild can handle both JavaScript and CSS and many other file formats, you can only return JavaScript in `load` and `transform` results. 4. Currently, `writeBundle` is only serves as a hook for the timing. It doesn't pass any arguments. -> **Warning**: The [Rspack](https://www.rspack.dev/) support is experimental. Future changes to Rspack integrations might not follow semver, please pin `unplugin` in your dependency when using. It's not recommended to use in production. +> **Warning**: The support for [Rspack](https://www.rspack.dev/) and [Farm](https://farm-fe.github.io/) is currently in an experimental stage. Please note that future changes to the integration of Rspack and farm may not strictly adhere to semantic versioning (semver), please pin `unplugin` in your dependency when using. It's not recommended to use in production. ### Hook Context @@ -131,9 +131,7 @@ import UnpluginFeature from './unplugin-feature' export default { plugins: [ - UnpluginFeature.vite({ - /* options */ - }), + UnpluginFeature.vite({ /* options */ }), ], } ``` @@ -146,9 +144,7 @@ import UnpluginFeature from './unplugin-feature' export default { plugins: [ - UnpluginFeature.rollup({ - /* options */ - }), + UnpluginFeature.rollup({ /* options */ }), ], } ``` @@ -159,9 +155,7 @@ export default { // webpack.config.js module.exports = { plugins: [ - require('./unplugin-feature').webpack({ - /* options */ - }), + require('./unplugin-feature').webpack({ /* options */ }), ], } ``` @@ -174,22 +168,19 @@ import { build } from 'esbuild' build({ plugins: [ - require('./unplugin-feature').esbuild({ - /* options */ - }), + require('./unplugin-feature').esbuild({ /* options */ }), ], }) ``` + ###### Rspack ```ts // rspack.config.js module.exports = { plugins: [ - require('./unplugin-feature').rspack({ - /* options */ - }), + require('./unplugin-feature').rspack({ /* options */ }), ], } ``` @@ -202,9 +193,7 @@ import UnpluginFeature from './unplugin-feature' export default { plugins: [ - UnpluginFeature.farm({ - /* options */ - }), + UnpluginFeature.farm({ /* options */ }), ], } ``` @@ -220,12 +209,8 @@ export const unplugin = createUnplugin((options: UserOptions, meta) => { return { // Common unplugin hooks name: 'unplugin-prefixed-name', - transformInclude(id) { - /* ... */ - }, - transform(code) { - /* ... */ - }, + transformInclude(id) { /* ... */ }, + transform(code) { /* ... */ }, // Framework specific hooks vite: { @@ -248,9 +233,11 @@ export const unplugin = createUnplugin((options: UserOptions, meta) => { // Change the filter of onResolve and onLoad // onResolveFilter?: RegExp, // onLoadFilter?: RegExp, + // Tell esbuild how to interpret the contents. By default unplugin tries to guess the loader // from file extension (eg: .js -> "js", .jsx -> 'jsx') // loader?: (Loader | (code: string, id: string) => Loader) + // Or you can completely replace the setup logic // setup?: EsbuildPlugin.setup, }, @@ -281,24 +268,12 @@ import { createWebpackPlugin, } from 'unplugin' -const vitePlugin = createVitePlugin({ - /* options */ -}) -const rollupPlugin = createRollupPlugin({ - /* options */ -}) -const esbuildPlugin = createEsbuildPlugin({ - /* options */ -}) -const webpackPlugin = createWebpackPlugin({ - /* options */ -}) -const rspackPlugin = createRspackPlugin({ - /* options */ -}) -const farmPlugin = createFarmPlugin({ - /* options */ -}) +const vitePlugin = createVitePlugin({ /* options */ }) +const rollupPlugin = createRollupPlugin({ /* options */ }) +const esbuildPlugin = createEsbuildPlugin({ /* options */ }) +const webpackPlugin = createWebpackPlugin({ /* options */ }) +const rspackPlugin = createRspackPlugin({ /* options */ }) +const farmPlugin = createFarmPlugin({ /* options */ }) ``` ## Conventions From 269acd529e61a33c12a14289761b42036c3fb7d6 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Mon, 25 Sep 2023 15:49:35 +0800 Subject: [PATCH 36/58] chore: update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8520111b..92ce784d 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ Currently supports: 3. Although esbuild can handle both JavaScript and CSS and many other file formats, you can only return JavaScript in `load` and `transform` results. 4. Currently, `writeBundle` is only serves as a hook for the timing. It doesn't pass any arguments. -> **Warning**: The support for [Rspack](https://www.rspack.dev/) and [Farm](https://farm-fe.github.io/) is currently in an experimental stage. Please note that future changes to the integration of Rspack and farm may not strictly adhere to semantic versioning (semver), please pin `unplugin` in your dependency when using. It's not recommended to use in production. +> **Warning**: The support for [Rspack](https://www.rspack.dev/) and [Farm](https://farm-fe.github.io/) is currently in an experimental stage. Future changes to Rspack and Farm integrations might not follow semver, please pin `unplugin` in your dependency when using. It's not recommended to use in production. ### Hook Context From f366e2ba74f4cb3f8488a006e27af46e43c4c31b Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Mon, 25 Sep 2023 15:57:50 +0800 Subject: [PATCH 37/58] chore: update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 92ce784d..c22c3c88 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Currently supports: ###### Supported -| Hook | Rollup | Vite | Webpack 4 | Webpack 5 | esbuild | Rspack | Farm | +| Hook | Rollup | Vite | Webpack 4 | Webpack 5 | esbuild | Rspack | Farm | | ----------------------------------------------------------------------- | :-------------: | :--: | :-------: | :-------: | :------------: | :----: | :--: | | [`enforce`](https://rollupjs.org/guide/en/#enforce) | ❌ 1 | ✅ | ✅ | ✅ | ❌ 1 | ✅ | ✅ | | [`buildStart`](https://rollupjs.org/guide/en/#buildstart) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | From 4cf76df5e67ae846a7b982d623b380bd505cf10b Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Tue, 26 Sep 2023 20:12:06 +0800 Subject: [PATCH 38/58] chore: update readme --- README.md | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index c22c3c88..38d49617 100644 --- a/README.md +++ b/README.md @@ -21,18 +21,19 @@ Currently supports: ###### Supported -| Hook | Rollup | Vite | Webpack 4 | Webpack 5 | esbuild | Rspack | Farm | -| ----------------------------------------------------------------------- | :-------------: | :--: | :-------: | :-------: | :------------: | :----: | :--: | -| [`enforce`](https://rollupjs.org/guide/en/#enforce) | ❌ 1 | ✅ | ✅ | ✅ | ❌ 1 | ✅ | ✅ | -| [`buildStart`](https://rollupjs.org/guide/en/#buildstart) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`resolveId`](https://rollupjs.org/guide/en/#resolveid) | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | -| `loadInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`load`](https://rollupjs.org/guide/en/#load) | ✅ | ✅ | ✅ | ✅ | ✅ 3 | ✅ | ✅ | -| `transformInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`transform`](https://rollupjs.org/guide/en/#transformers) | ✅ | ✅ | ✅ | ✅ | ✅ 3 | ✅ | ✅ | -| [`watchChange`](https://rollupjs.org/guide/en/#watchchange) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | -| [`buildEnd`](https://rollupjs.org/guide/en/#buildend) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`writeBundle`](https://rollupjs.org/guide/en/#writebundle)4 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| Hook | Rollup | Vite | Webpack 4 | Webpack 5 | esbuild | Rspack | Farm | +| ----------------------------------------------------------------------- | :-------------: | :--: | :-------: | :-------: | :-------------: | :----: | :--: | +| [`enforce`](https://rollupjs.org/guide/en/#enforce) | ❌ 1 | ✅ | ✅ | ✅ | ❌ 1 | ✅ | ✅ | +| [`buildStart`](https://rollupjs.org/guide/en/#buildstart) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`resolveId`](https://rollupjs.org/guide/en/#resolveid) | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | +| `loadInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`load`](https://rollupjs.org/guide/en/#load) | ✅ | ✅ | ✅ | ✅ | ✅ 3 | ✅ | ✅ | +| `transformInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`transform`](https://rollupjs.org/guide/en/#transformers) | ✅ | ✅ | ✅ | ✅ | ✅ 3 | ✅ | ✅ | +| [`watchChange`](https://rollupjs.org/guide/en/#watchchange) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | +| [`buildEnd`](https://rollupjs.org/guide/en/#buildend) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`writeBundle`](https://rollupjs.org/guide/en/#writebundle)4 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | + 1. Rollup and esbuild do not support using `enforce` to control the order of plugins. Users need to maintain the order manually. 2. Webpack's id filter is outside of loader logic; an additional hook is needed for better perf on Webpack. In Rollup and Vite, this hook has been polyfilled to match the behaviors. See for the following usage examples. @@ -45,14 +46,14 @@ Currently supports: ###### Supported -| Hook | Rollup | Vite | Webpack 4 | Webpack 5 | esbuild | Rspack | Farm | -| -------------------------------------------------------------------------- | :----: | :--: | :------: | :------: | :-----: | :----: | :--: | -| [`this.parse`](https://rollupjs.org/guide/en/#thisparse) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`this.addWatchFile`](https://rollupjs.org/guide/en/#thisaddwatchfile) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | -| [`this.emitFile`](https://rollupjs.org/guide/en/#thisemitfile)5 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`this.getWatchFiles`](https://rollupjs.org/guide/en/#thisgetwatchfiles) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | -| [`this.warn`](https://rollupjs.org/guide/en/#thiswarn) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`this.error`](https://rollupjs.org/guide/en/#thiserror) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| Hook | Rollup | Vite | Webpack 4 | Webpack 5 | esbuild | Rspack | Farm | +| -------------------------------------------------------------------------- | :----: | :--: | :-------: | :-------: | :-----: | :----: | :--: | +| [`this.parse`](https://rollupjs.org/guide/en/#thisparse) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`this.addWatchFile`](https://rollupjs.org/guide/en/#thisaddwatchfile) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | +| [`this.emitFile`](https://rollupjs.org/guide/en/#thisemitfile)5 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`this.getWatchFiles`](https://rollupjs.org/guide/en/#thisgetwatchfiles) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | +| [`this.warn`](https://rollupjs.org/guide/en/#thiswarn) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`this.error`](https://rollupjs.org/guide/en/#thiserror) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | 5. Currently, [`this.emitFile`](https://rollupjs.org/guide/en/#thisemitfile) only supports the `EmittedAsset` variant. @@ -91,9 +92,9 @@ Since `v0.10.0`, unplugin supports constructing multiple nested plugins to behav ###### Supported -| Rollup | Vite | Webpack 4 | Webpack 5 | Rspack | esbuild | Farm | -| :-------------------: | :---: | :-------: | :-------: | :----: | :-----------: | :---: | -| ✅ `>=3.1`6 | ✅ | ✅ | ✅ | ✅ | ⚠️7 | ✅ | +| Rollup | Vite | Webpack 4 | Webpack 5 | Rspack | esbuild | Farm | +| :--------------------: | :--: | :-------: | :-------: | :----: | :------------: | :--: | +| ✅ `>=3.1`6 | ✅ | ✅ | ✅ | ✅ | ⚠️7 | ✅ | 6. Rollup supports nested plugins since [v3.1.0](https://github.com/rollup/rollup/releases/tag/v3.1.0). Plugin author should ask users to have a Rollup version of `>=3.1.0` when using nested plugins. For single plugin format, unplugin works for any version of Rollup. 7. Since esbuild does not have a built-in transform phase, the `transform` hook of the nested plugin will not work on esbuild yet. Other hooks like `load` or `resolveId` work fine. We will try to find a way to support it in the future. From 615ca8d7531727ba90b9d234a2a9f1a6fab09bd4 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Wed, 4 Oct 2023 11:57:19 +0800 Subject: [PATCH 39/58] chore: add moduletype when transform id --- src/farm/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/farm/index.ts b/src/farm/index.ts index 64e2d98b..3f83b4de 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -160,7 +160,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { if (plugin.transform) { const _transform = plugin.transform farmPlugin.transform = { - filters: { resolvedPaths: ['.*'] }, + filters: { resolvedPaths: ['.*'], moduleTypes: ['.*'] }, async executor( params: PluginTransformHookParam, context: CompilationContext, From 8bf06ac339bdbc414f54c488059e0a1aba027dfb Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Sun, 7 Jan 2024 11:09:47 +0800 Subject: [PATCH 40/58] chore: update farm plugins --- package.json | 4 ++-- src/farm/context.ts | 4 ++-- src/farm/index.ts | 18 ++++++++++++++---- test/fixtures/load/farm.config.js | 17 ----------------- test/fixtures/transform/farm.config.js | 16 ---------------- 5 files changed, 18 insertions(+), 41 deletions(-) diff --git a/package.json b/package.json index 9c39c02b..885b6138 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "unplugin", - "version": "1.6.0", + "name": "unplugin-test", + "version": "2.0.0", "packageManager": "pnpm@8.12.1", "description": "Unified plugin system for build tools", "license": "MIT", diff --git a/src/farm/context.ts b/src/farm/context.ts index 236935de..50e7b9de 100644 --- a/src/farm/context.ts +++ b/src/farm/context.ts @@ -8,8 +8,8 @@ export function createFarmContext( context: CompilationContext, currentResolveId?: string, ): UnpluginBuildContext & { - addWatchFile: (id: string, currentResolveId: string) => void - } { + addWatchFile: (id: string, currentResolveId: string) => void +} { return { parse(code: string, opts: any = {}) { return Parser.parse(code, { diff --git a/src/farm/index.ts b/src/farm/index.ts index 3f83b4de..5f0c064c 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -30,7 +30,8 @@ import { import { createFarmContext } from './context' export function getFarmPlugin< - UserOptions = Record, Nested extends boolean = boolean, + UserOptions = Record, + Nested extends boolean = boolean, >(factory: UnpluginFactory) { return ((userOptions?: UserOptions) => { const meta: UnpluginContextMeta = { @@ -55,13 +56,18 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { priority: convertEnforceToPriority(plugin.enforce), } if (plugin.farm) { - const { config, configDevServer, updateModules } = plugin.farm + const { config, configDevServer, configResolved, configureCompiler, updateModules } = plugin.farm if (config) farmPlugin.config = config + if (configResolved) + farmPlugin.configResolved = configResolved if (configDevServer) farmPlugin.configDevServer = configDevServer if (updateModules) farmPlugin.updateModules = updateModules + if (configureCompiler) { + farmPlugin.configureCompiler = configureCompiler + } } if (plugin.buildStart) { @@ -77,7 +83,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { const _resolveId = plugin.resolveId farmPlugin.resolve = { filters: { sources: ['.*'], importers: ['.*'] }, - async executor(params: PluginResolveHookParam) { + async executor(params: PluginResolveHookParam, context) { const resolvedIdPath = path.resolve( process.cwd(), params.importer?.relativePath ?? '', @@ -87,11 +93,15 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { const kindWithEntry = params.kind as { entry: string } isEntry = kindWithEntry.entry === 'index' } - const resolveIdResult = await _resolveId( + const resolveIdResult = await _resolveId.call( + // TODO: type error in farm + // @ts-ignore + createFarmContext(context!), params.source, resolvedIdPath ?? null, { isEntry }, ) + if (isString(resolveIdResult)) { return { resolvedPath: resolveIdResult, diff --git a/test/fixtures/load/farm.config.js b/test/fixtures/load/farm.config.js index ebd5f87b..0d17e0f2 100644 --- a/test/fixtures/load/farm.config.js +++ b/test/fixtures/load/farm.config.js @@ -1,4 +1,3 @@ -const { builtinModules } = require('module') const { farm } = require('./unplugin') /** @@ -14,24 +13,8 @@ module.exports = { targetEnv: 'node', format: 'cjs', }, - external: [ - ...builtinModules.map(m => `^${m}$`), - ...builtinModules.map(m => `^node:${m}$`), - ], - partialBundling: { - moduleBuckets: [ - { - name: 'node.bundle.js', - test: ['.+'], - }, - ], - }, - presetEnv: false, }, plugins: [ farm({ msg: 'Farm' }), ], - server: { - hmr: false, - }, } diff --git a/test/fixtures/transform/farm.config.js b/test/fixtures/transform/farm.config.js index 3248438b..cad8d115 100644 --- a/test/fixtures/transform/farm.config.js +++ b/test/fixtures/transform/farm.config.js @@ -1,4 +1,3 @@ -const { builtinModules } = require('module') const { farm } = require('./unplugin') /** @@ -15,24 +14,9 @@ module.exports = { targetEnv: 'node', format: 'cjs', }, - external: [ - ...builtinModules.map(m => `^${m}$`), - ...builtinModules.map(m => `^node:${m}$`), - ], - partialBundling: { - moduleBuckets: [ - { - name: 'node.bundle.js', - test: ['.+'], - }, - ], - }, presetEnv: false, }, plugins: [ farm({ msg: 'Farm' }), ], - server: { - hmr: false, - }, } From 4d42abc037c77ef8f9692e47aa1f39d7e8b9b71d Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Sat, 13 Jan 2024 15:35:42 +0800 Subject: [PATCH 41/58] chore: bump farm version --- package.json | 6 +-- pnpm-lock.yaml | 100 +++++++++++++++++++++++-------------------------- 2 files changed, 49 insertions(+), 57 deletions(-) diff --git a/package.json b/package.json index 885b6138..c7abacce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "unplugin-test", - "version": "2.0.0", + "version": "2.0.1", "packageManager": "pnpm@8.12.1", "description": "Unified plugin system for build tools", "license": "MIT", @@ -44,8 +44,8 @@ "@ampproject/remapping": "^2.2.1", "@antfu/eslint-config": "^2.6.0", "@antfu/ni": "^0.21.12", - "@farmfe/cli": "^0.5.11", - "@farmfe/core": "^0.14.18", + "@farmfe/cli": "^0.6.0", + "@farmfe/core": "^0.15.3", "@rspack/cli": "^0.4.5", "@rspack/core": "^0.4.5", "@types/fs-extra": "^11.0.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b27e3bf0..eb0f9dcb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -29,11 +29,11 @@ devDependencies: specifier: ^0.21.12 version: 0.21.12 '@farmfe/cli': - specifier: ^0.5.11 - version: 0.5.11 + specifier: ^0.6.0 + version: 0.6.0 '@farmfe/core': - specifier: ^0.14.18 - version: 0.14.18 + specifier: ^0.15.3 + version: 0.15.3 '@rspack/cli': specifier: ^0.4.5 version: 0.4.5(@rspack/core@0.4.5)(esbuild@0.19.11)(webpack-cli@4.10.0) @@ -541,8 +541,8 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /@farmfe/cli@0.5.11: - resolution: {integrity: sha512-W5kMsPlyGh+zKhgyiVPcEf2ZFID1RwqZQUO1zdiFakEv22b6sgbdEkyiUafYS1hsdtYFunQjFccCjz4AqZN2kg==} + /@farmfe/cli@0.6.0: + resolution: {integrity: sha512-ipbD1krq3NTZChUl55Lgjeu+eXPDJAMbEVXxQxqnLYwXgy5F4jVqOap0Cmi426y/tTl86pRCiakpc6ACCPyk1g==} engines: {node: '>= 16'} hasBin: true dependencies: @@ -553,8 +553,8 @@ packages: walkdir: 0.4.1 dev: true - /@farmfe/core-darwin-arm64@0.14.18: - resolution: {integrity: sha512-699ULidSPIT0f7I53FFkCdLQYplBWGTeHQoysDPGmsblU7VufA4hQaNRBFYcwraGpuReInbYOJ1658EpRljooA==} + /@farmfe/core-darwin-arm64@0.15.3: + resolution: {integrity: sha512-+5V9r03O2RVFzHtF2GApbBovKGQ/J3uPAK2uAnX+PvzJqphHShuuZWkAqiO/9+GrSgJi5xfWl4caea201GxBeQ==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] @@ -562,8 +562,8 @@ packages: dev: true optional: true - /@farmfe/core-darwin-x64@0.14.18: - resolution: {integrity: sha512-o43mU+U3MSwZOF/EBnEmh9yjW8yp5yQuwI4f3zKmS+dRoOxvnedOjfvVEyYS/dkiQwVueD75jxkJ0J/LEFtKww==} + /@farmfe/core-darwin-x64@0.15.3: + resolution: {integrity: sha512-WtwobGiHjKIz1nd8jGSSq8YHPHO+Rt/n53bCeoXIkYD2/GKR2kGRUZCahana7/7HB3wW9uiu6yDdh/OyVOC4Ng==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] @@ -571,8 +571,8 @@ packages: dev: true optional: true - /@farmfe/core-linux-arm64-gnu@0.14.18: - resolution: {integrity: sha512-ROeh1QvnKAB3UUR3aVK8W02zQgjiHo05iDmgqK1Y1veM4OI5mK4jUc49j7oUiLQLqpdYxbQH4RWq0pVa7/HBeg==} + /@farmfe/core-linux-arm64-gnu@0.15.3: + resolution: {integrity: sha512-u+LkJIw8Qht6w+7hLfU7wf91ZfacCzAVj6FkBJDxGQpviK+0MEb2T7xjbBoqs45IuLSZ2yzbdI78PWgnUVEfUA==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] @@ -580,8 +580,8 @@ packages: dev: true optional: true - /@farmfe/core-linux-arm64-musl@0.14.18: - resolution: {integrity: sha512-L33EZFhCKsj3PCfZsbcANQJQ48jOT/jzmGyf25Af6tlmcQudI9mBIkDZqms2E51WAkn1h0DIH/Ujt/b1rpSmSA==} + /@farmfe/core-linux-arm64-musl@0.15.3: + resolution: {integrity: sha512-v7D5Fx6y6Aa9zU3VbrTCqrvlQZVwQbgem9BrpZfu/MEB1Uh8Vi/A+czyp8WjNHQOPNkuF+tCkWH2mUrfBQLgKQ==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] @@ -589,8 +589,8 @@ packages: dev: true optional: true - /@farmfe/core-linux-x64-gnu@0.14.18: - resolution: {integrity: sha512-dAu8FmiJ2GO2JTQcYkpKXKf6DfLUaKAC7FgnIppIBn57woEpQvthQQSLswUGOZu53y2O14dao0qfKMiVfT/q8w==} + /@farmfe/core-linux-x64-gnu@0.15.3: + resolution: {integrity: sha512-oraEaEYhm59wGRWXUEcopz+WmDDvcc34AE/DUXTz7c6LvnKB8g78QpTcuApC3f+GM3PjL/JS18KNXYxApVxRXA==} engines: {node: '>= 10'} cpu: [x64] os: [linux] @@ -598,8 +598,8 @@ packages: dev: true optional: true - /@farmfe/core-linux-x64-musl@0.14.18: - resolution: {integrity: sha512-2O8dpextT2aA1uL+UKzn3tpsaTyy3TzUq26UgAuYwrMNKzKCzsnMJpSc3qHAyCDgVaV8F/zxnljxKv2pG2IwOg==} + /@farmfe/core-linux-x64-musl@0.15.3: + resolution: {integrity: sha512-aL7veBNptoINbbm8sTqQQLHOL01bQvxbPH/9nngpfVNBhuC728/5i0rvVV963OaBQZSuBxG0HVqpy8Q+GQBl4A==} engines: {node: '>= 10'} cpu: [x64] os: [linux] @@ -607,8 +607,8 @@ packages: dev: true optional: true - /@farmfe/core-win32-arm64-msvc@0.14.18: - resolution: {integrity: sha512-2Vx8UfzJovKX2B0MrTpmkXAwhi71Mkz1Voi3lVASC6YTcVRYQpEtMxBddyhylkSYnmXcjya9tVJxVr45JJd6gQ==} + /@farmfe/core-win32-arm64-msvc@0.15.3: + resolution: {integrity: sha512-sx+Y7ca4R+5o1AGnaviMgbKywFdlu0HR65J9p1ZBtaekDHxxyl4cif1JuikfH6uL90Roy1u7ZhS5heVnHhal3g==} engines: {node: '>= 10'} cpu: [arm64] os: [win32] @@ -616,8 +616,8 @@ packages: dev: true optional: true - /@farmfe/core-win32-ia32-msvc@0.14.18: - resolution: {integrity: sha512-wPcUvSVtnpvKyj+UXUumf3pVBNatok9mGcXGO9ecAl657rjT7GyYfqw5VhvAySCWLBY5YnOvV0nt3rbgsY9sQQ==} + /@farmfe/core-win32-ia32-msvc@0.15.3: + resolution: {integrity: sha512-j5OPb5eO38aZOLvH+RBWd4C2JnOWHEku54A7KwVVYxYLXjIEgwQ221JgUG+9B0Hi85FIlfHfopPV6CcFn+gusA==} engines: {node: '>= 10'} cpu: [ia32] os: [win32] @@ -625,8 +625,8 @@ packages: dev: true optional: true - /@farmfe/core-win32-x64-msvc@0.14.18: - resolution: {integrity: sha512-1n8Aobsr8QNIYi5Blrjdnm9qnA7ch5WEmGNPAFPDYKKmuYmYhKiZw5wL+rFzd81RJdGEvQUa7DmCvghh6f4dFA==} + /@farmfe/core-win32-x64-msvc@0.15.3: + resolution: {integrity: sha512-YiMLSuk71e2kAsukhuBx164kSmUe6NfhSEHRBGWqXHQoPm3OG6F+IWVjHO0qIwnT8olLG2ZMBFp9GSChYBiJtw==} engines: {node: '>= 10'} cpu: [x64] os: [win32] @@ -634,13 +634,13 @@ packages: dev: true optional: true - /@farmfe/core@0.14.18: - resolution: {integrity: sha512-XoKziU/ps8/uC54+IoJHehBVPgUmL6KIHb1v+cIvD8kMzBUJjg5O1Llzg1Bs/PUNWVyY18SOwUw7xHcyn7NAvw==} + /@farmfe/core@0.15.3: + resolution: {integrity: sha512-RLHIUFj/tusDwN0LgNt+N5WWXz5yzOv9f6Rs9D9RzmdjxIIryIav2M367k2wmldOBoplzLBR23AEVPdTzH9/ew==} engines: {node: '>= 16'} dependencies: - '@farmfe/runtime': 0.8.4 - '@farmfe/runtime-plugin-hmr': 3.3.1 - '@farmfe/runtime-plugin-import-meta': 0.0.4 + '@farmfe/runtime': 0.9.0 + '@farmfe/runtime-plugin-hmr': 3.4.0 + '@farmfe/runtime-plugin-import-meta': 0.1.0 '@koa/cors': 4.0.0 '@swc/helpers': 0.5.1 dotenv: 16.3.1 @@ -662,15 +662,15 @@ packages: zod: 3.21.4 zod-validation-error: 1.5.0(zod@3.21.4) optionalDependencies: - '@farmfe/core-darwin-arm64': 0.14.18 - '@farmfe/core-darwin-x64': 0.14.18 - '@farmfe/core-linux-arm64-gnu': 0.14.18 - '@farmfe/core-linux-arm64-musl': 0.14.18 - '@farmfe/core-linux-x64-gnu': 0.14.18 - '@farmfe/core-linux-x64-musl': 0.14.18 - '@farmfe/core-win32-arm64-msvc': 0.14.18 - '@farmfe/core-win32-ia32-msvc': 0.14.18 - '@farmfe/core-win32-x64-msvc': 0.14.18 + '@farmfe/core-darwin-arm64': 0.15.3 + '@farmfe/core-darwin-x64': 0.15.3 + '@farmfe/core-linux-arm64-gnu': 0.15.3 + '@farmfe/core-linux-arm64-musl': 0.15.3 + '@farmfe/core-linux-x64-gnu': 0.15.3 + '@farmfe/core-linux-x64-musl': 0.15.3 + '@farmfe/core-win32-arm64-msvc': 0.15.3 + '@farmfe/core-win32-ia32-msvc': 0.15.3 + '@farmfe/core-win32-x64-msvc': 0.15.3 transitivePeerDependencies: - bufferutil - debug @@ -678,20 +678,20 @@ packages: - utf-8-validate dev: true - /@farmfe/runtime-plugin-hmr@3.3.1: - resolution: {integrity: sha512-zoT0pzP+W901wnBEhhaH1IBK4JOzOJCoQ7dHXlJ4zdqDD7M139SGmkDs/YW7pBsAxbwh8sa0FUOPfsemjzTlEA==} + /@farmfe/runtime-plugin-hmr@3.4.0: + resolution: {integrity: sha512-x2zif74XeU/1nZPtGIhkLx3+3gugPkzPRPRlnfDrsrANi0mCKiuQ81oNPHTcHJOhaQfchMyCgA+X5h/ZJHrIhg==} dependencies: core-js: 3.32.2 dev: true - /@farmfe/runtime-plugin-import-meta@0.0.4: - resolution: {integrity: sha512-E6m6RlRU+oGwSFGOA57awEGi100noNIyzBz1QMbJVzQwKDSrFYWDpVILVrgcBDXDtC9+jjrNLMvuWoKzkNAIpA==} + /@farmfe/runtime-plugin-import-meta@0.1.0: + resolution: {integrity: sha512-PswyQOug3jz1a0Bpb+d4hEyRyYxJhg+8Ei0gvu9ZL1owvCWCXfkViUrZIPjTjH6xqrAQRNNBLp7C4z24HLutEg==} dependencies: core-js: 3.32.2 dev: true - /@farmfe/runtime@0.8.4: - resolution: {integrity: sha512-zh23JSIcmy1Dl111sMrV5VztxamJE0NY9ratneed286XGPjrd7Hqfw/1earevB3Cd8PpwsYxHNpBfBJCHUds5A==} + /@farmfe/runtime@0.9.0: + resolution: {integrity: sha512-68JSv3tesGFoOlrtjTtiJpbZr5B0m6SuNbsKoWtb7DsmbUICCKq/F4ikM5Eyf6AdoY/z+he/6xhdAuXaV32Jww==} dependencies: core-js: 3.32.2 dev: true @@ -2323,7 +2323,7 @@ packages: normalize-path: 3.0.0 readdirp: 3.6.0 optionalDependencies: - fsevents: 2.3.2 + fsevents: 2.3.3 /chownr@2.0.0: resolution: {integrity: sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==} @@ -3743,19 +3743,11 @@ packages: resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} dev: true - /fsevents@2.3.2: - resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==} - engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} - os: [darwin] - requiresBuild: true - optional: true - /fsevents@2.3.3: resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} os: [darwin] requiresBuild: true - dev: true optional: true /function-bind@1.1.1: @@ -5709,7 +5701,7 @@ packages: '@rollup/rollup-win32-arm64-msvc': 4.9.2 '@rollup/rollup-win32-ia32-msvc': 4.9.2 '@rollup/rollup-win32-x64-msvc': 4.9.2 - fsevents: 2.3.2 + fsevents: 2.3.3 dev: true /run-applescript@5.0.0: From b3f636eaeffcf2926e124ba1b78b79287ab120ab Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Sat, 13 Jan 2024 16:17:07 +0800 Subject: [PATCH 42/58] chore: bump farm version --- package.json | 2 +- src/farm/index.ts | 24 +++++++++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index c7abacce..42757b2b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "unplugin-test", - "version": "2.0.1", + "version": "2.0.2", "packageManager": "pnpm@8.12.1", "description": "Unified plugin system for build tools", "license": "MIT", diff --git a/src/farm/index.ts b/src/farm/index.ts index 5f0c064c..8638d0fe 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -56,18 +56,20 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { priority: convertEnforceToPriority(plugin.enforce), } if (plugin.farm) { - const { config, configDevServer, configResolved, configureCompiler, updateModules } = plugin.farm + const { config, configureDevServer, configResolved, configureCompiler, updateModules, renderResourcePot } = plugin.farm if (config) farmPlugin.config = config - if (configResolved) + if (configResolved) farmPlugin.configResolved = configResolved - if (configDevServer) - farmPlugin.configDevServer = configDevServer + if (configureDevServer) + farmPlugin.configureDevServer = configureDevServer if (updateModules) farmPlugin.updateModules = updateModules - if (configureCompiler) { - farmPlugin.configureCompiler = configureCompiler - } + if (configureCompiler) + farmPlugin.configureCompiler = configureCompiler + + if (renderResourcePot) + farmPlugin.renderResourcePot = renderResourcePot } if (plugin.buildStart) { @@ -83,10 +85,10 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { const _resolveId = plugin.resolveId farmPlugin.resolve = { filters: { sources: ['.*'], importers: ['.*'] }, - async executor(params: PluginResolveHookParam, context) { + async executor(params: PluginResolveHookParam, context: CompilationContext) { const resolvedIdPath = path.resolve( process.cwd(), - params.importer?.relativePath ?? '', + params.importer ?? '', ) let isEntry = false if (isObject(params.kind) && 'entry' in params.kind) { @@ -95,13 +97,13 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { } const resolveIdResult = await _resolveId.call( // TODO: type error in farm - // @ts-ignore + // @ts-expect-error need context type createFarmContext(context!), params.source, resolvedIdPath ?? null, { isEntry }, ) - + if (isString(resolveIdResult)) { return { resolvedPath: resolveIdResult, From 50eaf0e3ec91a81c9c167734f46fade0471d6ab2 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Sat, 13 Jan 2024 16:42:20 +0800 Subject: [PATCH 43/58] chore: bump farm version --- src/farm/index.ts | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/farm/index.ts b/src/farm/index.ts index 8638d0fe..41c03408 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -55,21 +55,30 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { name: plugin.name, priority: convertEnforceToPriority(plugin.enforce), } - if (plugin.farm) { - const { config, configureDevServer, configResolved, configureCompiler, updateModules, renderResourcePot } = plugin.farm - if (config) - farmPlugin.config = config - if (configResolved) - farmPlugin.configResolved = configResolved - if (configureDevServer) - farmPlugin.configureDevServer = configureDevServer - if (updateModules) - farmPlugin.updateModules = updateModules - if (configureCompiler) - farmPlugin.configureCompiler = configureCompiler + // if (plugin.farm) { + // const { config, configureDevServer, configResolved, configureCompiler, updateModules, renderResourcePot } = plugin.farm + // if (config) + // farmPlugin.config = config + // if (configResolved) + // farmPlugin.configResolved = configResolved + // if (configureDevServer) + // farmPlugin.configureDevServer = configureDevServer + // if (updateModules) + // farmPlugin.updateModules = updateModules + // if (configureCompiler) + // farmPlugin.configureCompiler = configureCompiler + // if (renderResourcePot) + // farmPlugin.renderResourcePot = renderResourcePot + // } - if (renderResourcePot) - farmPlugin.renderResourcePot = renderResourcePot + if (plugin.farm) { + Object.keys(plugin.farm).forEach((key) => { + // @ts-expect-error farm type error + if (plugin.farm[key]) { + // @ts-expect-error farm type error + Reflect.set(farmPlugin, key, plugin.farm[key]) + } + }) } if (plugin.buildStart) { From d6b5319720bfac27335dbbb7c0dd239388bfa4c8 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Sun, 14 Jan 2024 19:29:21 +0800 Subject: [PATCH 44/58] chore: update code --- package.json | 2 +- src/farm/index.ts | 24 ++++----------------- src/types.ts | 4 ++++ test/fixtures/load/farm.config.js | 1 + test/fixtures/virtual-module/farm.config.js | 21 ++++++++++++++++++ 5 files changed, 31 insertions(+), 21 deletions(-) create mode 100644 test/fixtures/virtual-module/farm.config.js diff --git a/package.json b/package.json index 42757b2b..eb29d556 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "unplugin-test", + "name": "unplugin", "version": "2.0.2", "packageManager": "pnpm@8.12.1", "description": "Unified plugin system for build tools", diff --git a/src/farm/index.ts b/src/farm/index.ts index 41c03408..e35a5186 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -8,6 +8,7 @@ import type { } from '@farmfe/core/binding' import type { CompilationContext, JsPlugin } from '@farmfe/core' import type { + JsPluginExtended, TransformResult, UnpluginContext, UnpluginContextMeta, @@ -55,29 +56,12 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { name: plugin.name, priority: convertEnforceToPriority(plugin.enforce), } - // if (plugin.farm) { - // const { config, configureDevServer, configResolved, configureCompiler, updateModules, renderResourcePot } = plugin.farm - // if (config) - // farmPlugin.config = config - // if (configResolved) - // farmPlugin.configResolved = configResolved - // if (configureDevServer) - // farmPlugin.configureDevServer = configureDevServer - // if (updateModules) - // farmPlugin.updateModules = updateModules - // if (configureCompiler) - // farmPlugin.configureCompiler = configureCompiler - // if (renderResourcePot) - // farmPlugin.renderResourcePot = renderResourcePot - // } if (plugin.farm) { Object.keys(plugin.farm).forEach((key) => { - // @ts-expect-error farm type error - if (plugin.farm[key]) { - // @ts-expect-error farm type error - Reflect.set(farmPlugin, key, plugin.farm[key]) - } + const value = (plugin.farm as JsPluginExtended)[key] + if (value) + Reflect.set(farmPlugin, key, value) }) } diff --git a/src/types.ts b/src/types.ts index 91ed140b..0edfb73b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -29,6 +29,10 @@ export interface SourceMapCompact { version: number } +export interface JsPluginExtended extends FarmPlugin { + [key: string]: any +} + export type TransformResult = string | { code: string, map?: SourceMapInput | SourceMapCompact | null } | null | undefined export interface ExternalIdResult { id: string, external?: boolean } diff --git a/test/fixtures/load/farm.config.js b/test/fixtures/load/farm.config.js index 0d17e0f2..80b5d7c1 100644 --- a/test/fixtures/load/farm.config.js +++ b/test/fixtures/load/farm.config.js @@ -5,6 +5,7 @@ const { farm } = require('./unplugin') */ module.exports = { compilation: { + persistentCache: false, input: { index: './src/main.js', }, diff --git a/test/fixtures/virtual-module/farm.config.js b/test/fixtures/virtual-module/farm.config.js new file mode 100644 index 00000000..a7843fc9 --- /dev/null +++ b/test/fixtures/virtual-module/farm.config.js @@ -0,0 +1,21 @@ +const { farm } = require('./unplugin') + +/** + * @type {import('@farmfe/core').UserConfig} + */ +module.exports = { + compilation: { + persistentCache: false, + input: { + index: './src/main.js', + }, + output: { + path: './dist/farm', + targetEnv: 'node', + format: 'cjs', + }, + }, + plugins: [ + farm(), + ], +} From d029a9280677a940f23662c9ee0d6b167a3613d7 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Sun, 14 Jan 2024 20:12:29 +0800 Subject: [PATCH 45/58] chore: update code --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index eb29d556..f621dc7a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "unplugin", - "version": "2.0.2", + "version": "2.0.3", "packageManager": "pnpm@8.12.1", "description": "Unified plugin system for build tools", "license": "MIT", From 94d20f6135c4e6bc4fd7bdfa2398072bc7add35f Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Mon, 15 Jan 2024 11:29:24 +0800 Subject: [PATCH 46/58] chore: update context --- scripts/buildFixtures.ts | 8 ++-- src/define.ts | 1 - src/farm/context.ts | 17 +++++++-- src/farm/index.ts | 38 ++++++------------- test/fixtures/load/__test__/build.test.ts | 2 +- test/fixtures/load/farm.config.js | 2 + test/fixtures/transform/farm.config.js | 1 + .../virtual-module/__test__/build.test.ts | 7 ++++ test/fixtures/virtual-module/farm.config.js | 2 + 9 files changed, 41 insertions(+), 37 deletions(-) diff --git a/scripts/buildFixtures.ts b/scripts/buildFixtures.ts index 702470f3..7684422f 100644 --- a/scripts/buildFixtures.ts +++ b/scripts/buildFixtures.ts @@ -40,11 +40,9 @@ async function run() { execSync('npx @rspack/cli', { cwd: path, stdio: 'inherit' }) } - if (name !== 'virtual-module') { - console.log(c.magenta(c.inverse(c.bold('\n Farm '))), name, '\n') - execSync('npx farm --version', { cwd: path, stdio: 'inherit' }) - execSync('npx farm build', { cwd: path, stdio: 'inherit' }) - } + console.log(c.magenta(c.inverse(c.bold('\n Farm '))), name, '\n') + execSync('npx farm --version', { cwd: path, stdio: 'inherit' }) + execSync('npx farm build', { cwd: path, stdio: 'inherit' }) } } diff --git a/src/define.ts b/src/define.ts index 3f65bdfc..a1c291de 100644 --- a/src/define.ts +++ b/src/define.ts @@ -26,7 +26,6 @@ export function createUnplugin( get rspack() { return getRspackPlugin(factory) }, - /** @experimental do not use it in production */ get farm() { return getFarmPlugin(factory) }, diff --git a/src/farm/context.ts b/src/farm/context.ts index 50e7b9de..5eec49d1 100644 --- a/src/farm/context.ts +++ b/src/farm/context.ts @@ -2,14 +2,12 @@ import { Buffer } from 'buffer' import { extname } from 'path' import { Parser } from 'acorn' import type { CompilationContext } from '@farmfe/core' -import type { UnpluginBuildContext } from '..' +import type { UnpluginBuildContext, UnpluginContext } from '..' export function createFarmContext( context: CompilationContext, currentResolveId?: string, -): UnpluginBuildContext & { - addWatchFile: (id: string, currentResolveId: string) => void -} { +): UnpluginBuildContext { return { parse(code: string, opts: any = {}) { return Parser.parse(code, { @@ -39,3 +37,14 @@ export function createFarmContext( }, } } + +export function unpluginContext(context: CompilationContext): UnpluginContext { + return { + error: (error: any) => + context!.error( + typeof error === 'string' ? new Error(error) : error, + ), + warn: (error: any) => + context!.warn(typeof error === 'string' ? new Error(error) : error), + } +} diff --git a/src/farm/index.ts b/src/farm/index.ts index e35a5186..a237828a 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -1,4 +1,5 @@ -import path from 'path' +import path from 'node:path' + import type { PluginLoadHookParam, PluginLoadHookResult, @@ -7,17 +8,15 @@ import type { PluginTransformHookResult, } from '@farmfe/core/binding' import type { CompilationContext, JsPlugin } from '@farmfe/core' +import { toArray } from '../utils' import type { JsPluginExtended, TransformResult, - UnpluginContext, UnpluginContextMeta, UnpluginFactory, UnpluginInstance, UnpluginOptions, } from '../types' -import { toArray } from '../utils' -import type { WatchChangeEvents } from './utils' import { convertEnforceToPriority, convertWatchEventChange, @@ -28,7 +27,9 @@ import { isString, transformQuery, } from './utils' -import { createFarmContext } from './context' +import { createFarmContext, unpluginContext } from './context' + +import type { WatchChangeEvents } from './utils' export function getFarmPlugin< UserOptions = Record, @@ -39,6 +40,7 @@ export function getFarmPlugin< framework: 'farm', } const rawPlugins = toArray(factory(userOptions!, meta)) + const plugins = rawPlugins.map((rawPlugin) => { const plugin = toFarmPlugin(rawPlugin) as JsPlugin if (rawPlugin.farm) @@ -83,15 +85,15 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { process.cwd(), params.importer ?? '', ) + let isEntry = false if (isObject(params.kind) && 'entry' in params.kind) { const kindWithEntry = params.kind as { entry: string } isEntry = kindWithEntry.entry === 'index' } + const farmContext = createFarmContext(context!, resolvedIdPath) const resolveIdResult = await _resolveId.call( - // TODO: type error in farm - // @ts-expect-error need context type - createFarmContext(context!), + Object.assign(unpluginContext(context), farmContext), params.source, resolvedIdPath ?? null, { isEntry }, @@ -136,17 +138,8 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { const shouldLoadInclude = plugin.loadInclude && plugin.loadInclude(id.resolvedPath) const farmContext = createFarmContext(context!, id.resolvedPath) - const unpluginContext: UnpluginContext = { - error: error => - context!.error( - typeof error === 'string' ? new Error(error) : error, - ), - warn: error => - context!.warn(typeof error === 'string' ? new Error(error) : error), - } - const content: TransformResult = await _load.call( - Object.assign(unpluginContext, farmContext), + Object.assign(unpluginContext(context!), farmContext), id.resolvedPath, ) const loadFarmResult: PluginLoadHookResult = { @@ -184,15 +177,8 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { = plugin.transformInclude && plugin.transformInclude(params.resolvedPath) const farmContext = createFarmContext(context, params.resolvedPath) - const unpluginContext: UnpluginContext = { - error: error => - context.error(typeof error === 'string' ? new Error(error) : error), - warn: error => - context.warn(typeof error === 'string' ? new Error(error) : error), - } - const resource: TransformResult = await _transform.call( - Object.assign(unpluginContext, farmContext), + Object.assign(unpluginContext(context), farmContext), params.content, params.resolvedPath, ) diff --git a/test/fixtures/load/__test__/build.test.ts b/test/fixtures/load/__test__/build.test.ts index 70371218..e3939024 100644 --- a/test/fixtures/load/__test__/build.test.ts +++ b/test/fixtures/load/__test__/build.test.ts @@ -34,7 +34,7 @@ describe('load-called-before-transform', () => { }) it('farm', async () => { - const content = await fs.readFile(r('farm/index.js'), 'utf-8') + const content = await fs.readFile(r('farm/main.js'), 'utf-8') expect(content).toContain('it is a msg -> through the load hook -> transform-[Injected Farm]') }) diff --git a/test/fixtures/load/farm.config.js b/test/fixtures/load/farm.config.js index 80b5d7c1..5943ca73 100644 --- a/test/fixtures/load/farm.config.js +++ b/test/fixtures/load/farm.config.js @@ -9,7 +9,9 @@ module.exports = { input: { index: './src/main.js', }, + presetEnv: false, output: { + entryFilename: 'main.[ext]', path: './dist/farm', targetEnv: 'node', format: 'cjs', diff --git a/test/fixtures/transform/farm.config.js b/test/fixtures/transform/farm.config.js index cad8d115..c40155b4 100644 --- a/test/fixtures/transform/farm.config.js +++ b/test/fixtures/transform/farm.config.js @@ -5,6 +5,7 @@ const { farm } = require('./unplugin') */ module.exports = { compilation: { + persistentCache: false, input: { index: './src/main.js', }, diff --git a/test/fixtures/virtual-module/__test__/build.test.ts b/test/fixtures/virtual-module/__test__/build.test.ts index 3e0d2774..5cde0c79 100644 --- a/test/fixtures/virtual-module/__test__/build.test.ts +++ b/test/fixtures/virtual-module/__test__/build.test.ts @@ -32,4 +32,11 @@ describe('virtual-module build', () => { expect(content).toContain('VIRTUAL:ONE') expect(content).toContain('VIRTUAL:TWO') }) + + it('farm', async () => { + const content = await fs.readFile(r('farm/main.js'), 'utf-8') + + expect(content).toContain('VIRTUAL:ONE') + expect(content).toContain('VIRTUAL:TWO') + }) }) diff --git a/test/fixtures/virtual-module/farm.config.js b/test/fixtures/virtual-module/farm.config.js index a7843fc9..7586761e 100644 --- a/test/fixtures/virtual-module/farm.config.js +++ b/test/fixtures/virtual-module/farm.config.js @@ -9,7 +9,9 @@ module.exports = { input: { index: './src/main.js', }, + presetEnv: false, output: { + entryFilename: 'main.[ext]', path: './dist/farm', targetEnv: 'node', format: 'cjs', From a1881f34d3d0d5ade6b2f1dc62fa933a7b86cdd9 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Mon, 15 Jan 2024 11:51:42 +0800 Subject: [PATCH 47/58] chore: update unless return value with load hook return null --- package.json | 2 +- src/farm/index.ts | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index f621dc7a..5a9a5bc8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "unplugin", - "version": "2.0.3", + "version": "2.0.8", "packageManager": "pnpm@8.12.1", "description": "Unified plugin system for build tools", "license": "MIT", diff --git a/src/farm/index.ts b/src/farm/index.ts index a237828a..6d213585 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -17,6 +17,7 @@ import type { UnpluginInstance, UnpluginOptions, } from '../types' +import { createFarmContext, unpluginContext } from './context' import { convertEnforceToPriority, convertWatchEventChange, @@ -27,7 +28,6 @@ import { isString, transformQuery, } from './utils' -import { createFarmContext, unpluginContext } from './context' import type { WatchChangeEvents } from './utils' @@ -143,14 +143,13 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { id.resolvedPath, ) const loadFarmResult: PluginLoadHookResult = { - // TODO maybe sourcemap resolve content: getContentValue(content), moduleType: loader, } if (shouldLoadInclude) return loadFarmResult - return loadFarmResult + return null }, } as JsPlugin['load'] } From 14cec34eb0a43113d535b4ac9da2f54320bb138f Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Mon, 15 Jan 2024 11:53:42 +0800 Subject: [PATCH 48/58] chore: test success --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5a9a5bc8..8b5e0e20 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "unplugin", - "version": "2.0.8", + "version": "1.6.0", "packageManager": "pnpm@8.12.1", "description": "Unified plugin system for build tools", "license": "MIT", From 9af8d8d6db9236947e4bba32ca661cc52aac7230 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Mon, 15 Jan 2024 15:03:56 +0800 Subject: [PATCH 49/58] chore: update readme --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a09be444..d811eb85 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Currently supports: - [Webpack](https://webpack.js.org/) - [esbuild](https://esbuild.github.io/) - [Rspack](https://www.rspack.dev/) (⚠️ experimental) -- [Farm](https://farm-fe.github.io/) (⚠️ experimental) +- [Farm](https://farm-fe.github.io/) ## Hooks @@ -39,7 +39,7 @@ Currently supports: 3. Although esbuild can handle both JavaScript and CSS and many other file formats, you can only return JavaScript in `load` and `transform` results. 4. Currently, `writeBundle` is only serves as a hook for the timing. It doesn't pass any arguments. -> **Warning**: The support for [Rspack](https://www.rspack.dev/) and [Farm](https://farm-fe.github.io/) is currently in an experimental stage. Future changes to Rspack and Farm integrations might not follow semver, please pin `unplugin` in your dependency when using. It's not recommended to use in production. +> **Warning**: The [Rspack](https://www.rspack.dev/) support is experimental. Future changes to Rspack integrations might not follow semver, please pin unplugin in your dependency when using. It's not recommended to use in production.. ### Hook Context @@ -192,9 +192,9 @@ module.exports = { // farm.config.ts import UnpluginFeature from './unplugin-feature' -export default { +module.exports = { plugins: [ - UnpluginFeature.farm({ /* options */ }), + require('./unplugin-feature').farm({ /* options */ }), ], } ``` @@ -250,7 +250,7 @@ export const unplugin = createUnplugin((options: UserOptions, meta) => { config(config) { // Configure Farm config }, - configDevServer(server) { + configureDevServer(server) { // Configure Farm dev server }, } From 41299c164b7b72b3c38aa4b68fdad0f6328531f6 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Fri, 19 Jan 2024 13:49:29 +0800 Subject: [PATCH 50/58] chore: update code --- package.json | 4 ++-- src/farm/index.ts | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 8b5e0e20..d9ad26f6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "unplugin", - "version": "1.6.0", + "name": "unplugin-test", + "version": "2.1.0", "packageManager": "pnpm@8.12.1", "description": "Unified plugin system for build tools", "license": "MIT", diff --git a/src/farm/index.ts b/src/farm/index.ts index 6d213585..73aea41a 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -42,7 +42,7 @@ export function getFarmPlugin< const rawPlugins = toArray(factory(userOptions!, meta)) const plugins = rawPlugins.map((rawPlugin) => { - const plugin = toFarmPlugin(rawPlugin) as JsPlugin + const plugin = toFarmPlugin(rawPlugin, userOptions as Record) as JsPlugin if (rawPlugin.farm) Object.assign(plugin, rawPlugin.farm) @@ -53,7 +53,12 @@ export function getFarmPlugin< }) as UnpluginInstance['farm'] } -export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { +export const resolveIdFilters = { + sources: ['!node_modules'], + importers: ['!node_modules'], +} + +export function toFarmPlugin(plugin: UnpluginOptions, options?: Record | undefined): JsPlugin { const farmPlugin: JsPlugin = { name: plugin.name, priority: convertEnforceToPriority(plugin.enforce), @@ -78,8 +83,12 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { if (plugin.resolveId) { const _resolveId = plugin.resolveId + let filters = [] + if (options) + filters = options?.filters ?? [] + farmPlugin.resolve = { - filters: { sources: ['.*'], importers: ['.*'] }, + filters: { sources: ['!node_modules', ...filters], importers: ['!node_modules'] }, async executor(params: PluginResolveHookParam, context: CompilationContext) { const resolvedIdPath = path.resolve( process.cwd(), @@ -126,7 +135,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { const _load = plugin.load farmPlugin.load = { filters: { - resolvedPaths: ['.*'], + resolvedPaths: ['!node_modules'], }, async executor( id: PluginLoadHookParam, @@ -157,7 +166,7 @@ export function toFarmPlugin(plugin: UnpluginOptions): JsPlugin { if (plugin.transform) { const _transform = plugin.transform farmPlugin.transform = { - filters: { resolvedPaths: ['.*'], moduleTypes: ['.*'] }, + filters: { resolvedPaths: ['!node_modules'], moduleTypes: ['!node_modules'] }, async executor( params: PluginTransformHookParam, context: CompilationContext, From be23a4076ded49add67961173ff7f1a337485901 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Fri, 19 Jan 2024 14:08:05 +0800 Subject: [PATCH 51/58] chore: update code --- package.json | 2 +- src/farm/index.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index d9ad26f6..571f55e6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "unplugin-test", - "version": "2.1.0", + "version": "2.2.1", "packageManager": "pnpm@8.12.1", "description": "Unified plugin system for build tools", "license": "MIT", diff --git a/src/farm/index.ts b/src/farm/index.ts index 73aea41a..b98f5c30 100644 --- a/src/farm/index.ts +++ b/src/farm/index.ts @@ -88,7 +88,7 @@ export function toFarmPlugin(plugin: UnpluginOptions, options?: Record Date: Tue, 12 Mar 2024 22:27:09 +0800 Subject: [PATCH 52/58] chore: bump farm version --- README.md | 1 + package.json | 4 +- pnpm-lock.yaml | 762 ++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 764 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3826ac20..246864f1 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ Currently supports: - [esbuild](https://esbuild.github.io/) - [Rspack](https://www.rspack.dev/) (⚠️ experimental) - [Rolldown](https://rolldown.rs/) (⚠️ experimental) +- [Farm](https://farm-fe.github.io/) - And every framework built on top of them. ## Documentations diff --git a/package.json b/package.json index 661f8594..a2465f12 100644 --- a/package.json +++ b/package.json @@ -51,8 +51,8 @@ "@ampproject/remapping": "^2.3.0", "@antfu/eslint-config": "^2.8.0", "@antfu/ni": "^0.21.12", - "@farmfe/cli": "^0.6.0", - "@farmfe/core": "^0.15.3", + "@farmfe/cli": "^0.7.0", + "@farmfe/core": "^1.0.0-beta.0", "@rolldown/node": "^0.0.5", "@rspack/cli": "^0.5.6", "@rspack/core": "^0.5.6", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 467dbd28..8ac2e6ec 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -30,6 +30,12 @@ importers: '@antfu/ni': specifier: ^0.21.12 version: 0.21.12 + '@farmfe/cli': + specifier: ^0.7.0 + version: 0.7.0 + '@farmfe/core': + specifier: ^1.0.0-beta.0 + version: 1.0.0-beta.0 '@rolldown/node': specifier: ^0.0.5 version: 0.0.5 @@ -1259,6 +1265,168 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true + /@farmfe/cli@0.7.0: + resolution: {integrity: sha512-bSslt5px+K8daNPVEM/J731ExCWB5hZmjUwzS+WJjtauMti+A+OemqYArsdgZQ6FntlVQmswRQDWDeeWGcvLhA==} + engines: {node: '>= 16'} + hasBin: true + dependencies: + cac: 6.7.14 + cross-spawn: 7.0.3 + inquirer: 9.2.15 + walkdir: 0.4.1 + dev: true + + /@farmfe/core-darwin-arm64@1.0.0-beta.0: + resolution: {integrity: sha512-W0fdDchFB3Q8jl9M59OWKh4rCn4VT7sbp/MoqdbKzy6GvO4iQna3jCqVZeBnNWuV9TOlsfcNoQWyZnQOz2mcmA==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /@farmfe/core-darwin-x64@1.0.0-beta.0: + resolution: {integrity: sha512-rMKU+qlJ3CqRy4dHYSsBYf466MhKdW6CG3FaWjN5YbD65u6yZhv1LOgsS24dls49EIXVJYbMcH2X1fVzj8sDFA==} + engines: {node: '>= 10'} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /@farmfe/core-linux-arm64-gnu@1.0.0-beta.0: + resolution: {integrity: sha512-xl7wsjmy3qWF8ZDyrxUqvmcGvtNH13+s8xALqh2a3BByGxNycTxmzLawjxNDVG5WBWALWNVWW+GV5M3YOiShGQ==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@farmfe/core-linux-arm64-musl@1.0.0-beta.0: + resolution: {integrity: sha512-9OHI1Rp4mE6m7GS+6llGnvEwYnz4uijxnEwFyQpTGML/ft4p0k107jNN5Lrk+SsdZyOKs6Subk0UI+XfXlIZLA==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@farmfe/core-linux-x64-gnu@1.0.0-beta.0: + resolution: {integrity: sha512-r35cyR/3UfbnYsB5/7l3oNVyFRJsmVoPi8zh56k9SXEd0EX1/3OXvcFC69aHhILqhizGekKWFNW5bg0uCxpY6w==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@farmfe/core-linux-x64-musl@1.0.0-beta.0: + resolution: {integrity: sha512-pNZQTufLUP7bTjgSSAbup6my4NZR/aRIy5e6+RilSUPOWJbzlG6Lyw/R48Buc+16SwSxbeqDdWfSDmH/0SLKlw==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@farmfe/core-win32-arm64-msvc@1.0.0-beta.0: + resolution: {integrity: sha512-VEoqzYX49AVEvSjE4Ni6bKVnogmA6igkikgR2+8YNza+HRvSH4ELHeY02s01PUATvK697FHVrNksJ/UDV0ypNg==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@farmfe/core-win32-ia32-msvc@1.0.0-beta.0: + resolution: {integrity: sha512-3SQf0+LgqWdVC2CaRdUnR5i6aYumna/A7wKC44jRx7r+juVn8wW5ZGwoeX4fg3ZW30Z3+xlOWQfVRtFxBJfBFQ==} + engines: {node: '>= 10'} + cpu: [ia32] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@farmfe/core-win32-x64-msvc@1.0.0-beta.0: + resolution: {integrity: sha512-hvwxSFSfHkbEGgxscM0nydxkwtHbZcIaBIhVj4cEb5i3FHzCHoLXamfJZoHfSOO84xz+RADDNMFm7hrkkbmz7w==} + engines: {node: '>= 10'} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@farmfe/core@1.0.0-beta.0: + resolution: {integrity: sha512-sSnDUTWBlRVf0g0ByqS3TZCGKFKWLj5dIQVsZS4g0fy+SGQMGaPBXvQ+3GQXx0mUrdSU3iXOGIGgE1EG0r2pZw==} + engines: {node: '>= 16'} + dependencies: + '@farmfe/runtime': 0.10.0 + '@farmfe/runtime-plugin-hmr': 3.5.0 + '@farmfe/runtime-plugin-import-meta': 0.2.0 + '@farmfe/utils': 0.1.0 + '@koa/cors': 4.0.0 + '@swc/helpers': 0.5.6 + browserslist-generator: 2.1.0 + chokidar: 3.6.0 + dotenv: 16.4.5 + dotenv-expand: 10.0.0 + execa: 7.2.0 + fast-glob: 3.3.2 + fs-extra: 11.2.0 + koa: 2.15.0 + koa-compress: 5.1.1 + koa-proxies: 0.12.4(koa@2.15.0) + koa-static: 5.0.0 + lodash.debounce: 4.0.8 + lodash.merge: 4.6.2 + loglevel: 1.9.1 + mime-types: 2.1.35 + open: 9.1.0 + sirv: 2.0.4 + slashes: 3.0.12 + ws: 8.16.0 + zod: 3.22.4 + zod-validation-error: 1.3.1(zod@3.22.4) + optionalDependencies: + '@farmfe/core-darwin-arm64': 1.0.0-beta.0 + '@farmfe/core-darwin-x64': 1.0.0-beta.0 + '@farmfe/core-linux-arm64-gnu': 1.0.0-beta.0 + '@farmfe/core-linux-arm64-musl': 1.0.0-beta.0 + '@farmfe/core-linux-x64-gnu': 1.0.0-beta.0 + '@farmfe/core-linux-x64-musl': 1.0.0-beta.0 + '@farmfe/core-win32-arm64-msvc': 1.0.0-beta.0 + '@farmfe/core-win32-ia32-msvc': 1.0.0-beta.0 + '@farmfe/core-win32-x64-msvc': 1.0.0-beta.0 + transitivePeerDependencies: + - bufferutil + - debug + - supports-color + - utf-8-validate + dev: true + + /@farmfe/runtime-plugin-hmr@3.5.0: + resolution: {integrity: sha512-j+f8r1wUNO4jrOziw3z/y0mUvACW9alV2Z8QqpUHtUkd8noSyawXAZPeq9hnFC3l+/p0upbjjvFmFivA5iZCOg==} + dependencies: + core-js: 3.36.0 + dev: true + + /@farmfe/runtime-plugin-import-meta@0.2.0: + resolution: {integrity: sha512-3RXUzeKDmuGiOY7k6OThNok6Dj/Nl2pK62fC7/227O6WEfvWleVxLzXkqLZrMBv1OZNem/cloftMMjYDP/+q8Q==} + dependencies: + core-js: 3.36.0 + dev: true + + /@farmfe/runtime@0.10.0: + resolution: {integrity: sha512-J3cxUwmpxriO0407esxGO12ht0xSBFNG9IgaYsp+6XRHsLUKNYy6+cJOiweLzBf30nUGCoPwPI+KzFKhx2bRhg==} + dependencies: + core-js: 3.36.0 + dev: true + + /@farmfe/utils@0.1.0: + resolution: {integrity: sha512-neNJQGqV7XL4XifG1uHOBFSFLy2yx1/DVZNRA7nfeEAXEksVZTwWA+fZrYEaI0w7Sw6K/9NYn9Jgpn+NAT0mcg==} + dev: true + /@floating-ui/core@1.6.0: resolution: {integrity: sha512-PcF++MykgmTj3CIyOQbKA/hDzOAiqI3mhuoN44WRCopIs1sgoDoU4oty4Jtqaj/y3oDU6fnVSm4QG0a3t5i0+g==} dependencies: @@ -1408,10 +1576,28 @@ packages: type-detect: 4.0.8 dev: true + /@koa/cors@4.0.0: + resolution: {integrity: sha512-Y4RrbvGTlAaa04DBoPBWJqDR5gPj32OOz827ULXfgB1F7piD1MB/zwn8JR2LAnvdILhxUbXbkXGWuNVsFuVFCQ==} + engines: {node: '>= 14.0.0'} + dependencies: + vary: 1.1.2 + dev: true + /@leichtgewicht/ip-codec@2.0.4: resolution: {integrity: sha512-Hcv+nVC0kZnQ3tD9GVu5xSMR4VVYOteQIr/hwFPVEvPdlXqgGEuRjiheChHgdM+JyqdgNcmzZOX/tnl0JOiI7A==} dev: true + /@ljharb/through@2.3.13: + resolution: {integrity: sha512-/gKJun8NNiWGZJkGzI/Ragc53cOdcLNdzjLaIa+GEjguQs0ulsurx8WN0jijdK9yPqDvziX995sMRLyLt1uZMQ==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + dev: true + + /@mdn/browser-compat-data@5.5.14: + resolution: {integrity: sha512-K7e35i4XtNWpiOr+aPiy3UccAhFop0HsfVz9RSzlcgaaHb2aD/nN0J3uPPLedyTokMiebxN0gxkL/WXpzNQuKg==} + dev: true + /@module-federation/runtime-tools@0.0.8: resolution: {integrity: sha512-tqx3wlVHnpWLk+vn22c0x9Nv1BqdZnoS6vdMb53IsVpbQIFP70nhhvymHUyFuPkoLzMFidS7GpG58DYT/4lvCw==} dependencies: @@ -1955,6 +2141,12 @@ packages: - typescript dev: true + /@swc/helpers@0.5.6: + resolution: {integrity: sha512-aYX01Ke9hunpoCexYAgQucEpARGQ5w/cqHFrIR+e9gdKb1QWTsVJuTJ2ozQzIAxLyRQe/m+2RqzkyOOGiMKRQA==} + dependencies: + tslib: 2.6.2 + dev: true + /@types/body-parser@1.19.5: resolution: {integrity: sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg==} dependencies: @@ -2111,6 +2303,10 @@ packages: resolution: {integrity: sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==} dev: true + /@types/object-path@0.11.4: + resolution: {integrity: sha512-4tgJ1Z3elF/tOMpA8JLVuR9spt9Ynsf7+JjqsQ2IqtiPJtcLoHoXcT6qU4E10cPFqyXX5HDm9QwIzZhBSkLxsw==} + dev: true + /@types/qs@6.9.12: resolution: {integrity: sha512-bZcOkJ6uWrL0Qb2NAWKa7TBU+mJHPzhx9jjLL1KHF+XpzEcR7EXHvjbHlGtR/IsP1vyPrehuS6XqkmaePy//mg==} dev: true @@ -2158,6 +2354,10 @@ packages: resolution: {integrity: sha512-5JcVt1u5HDmlXkwOD2nslZVllBBc7HDuOICfiZah2Z0is8M8g+ddAEawbmd3VjedfDHBzxCaXLs07QEmb7y54g==} dev: true + /@types/ua-parser-js@0.7.39: + resolution: {integrity: sha512-P/oDfpofrdtF5xw433SPALpdSchtJmY7nsJItf8h3KXqOslkbySh8zq4dSWXH2oTjRvJ5PczVEoCZPow6GicLg==} + dev: true + /@types/unist@2.0.10: resolution: {integrity: sha512-IfYcSBWE3hLpBg8+X2SEa8LVkJdJEkT2Ese2aaLs3ptGdVtABxndrMaxuFlQ1qdFf9Q5rDvDpxI3WwgvKFAsQA==} dev: true @@ -3094,6 +3294,13 @@ packages: '@algolia/transporter': 4.22.1 dev: true + /ansi-escapes@4.3.2: + resolution: {integrity: sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==} + engines: {node: '>=8'} + dependencies: + type-fest: 0.21.3 + dev: true + /ansi-escapes@6.2.0: resolution: {integrity: sha512-kzRaCqXnpzWs+3z5ABPQiVke+iq0KXkHo8xiWV4RPTi5Yli0l97BEQuhXV1s7+aSU/fu1kUuxgS4MsQ0fRuygw==} engines: {node: '>=14.16'} @@ -3182,14 +3389,31 @@ packages: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} dev: true + /base64-js@1.5.1: + resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} + dev: true + /batch@0.6.1: resolution: {integrity: sha512-x+VAiMRL6UPkx+kudNvxTl6hB2XNNCG2r+7wixVfIYwu/2HKRXimwQyaumLjMveWvT2Hkd/cAJw+QBMfJ/EKVw==} dev: true + /big-integer@1.6.52: + resolution: {integrity: sha512-QxD8cf2eVqJOOz63z6JIN9BzvVs/dlySa5HGSBH5xtR8dPteIRQnBxxKqkNTiT6jbDTF6jAfrd4oMcND9RGbQg==} + engines: {node: '>=0.6'} + dev: true + /binary-extensions@2.2.0: resolution: {integrity: sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==} engines: {node: '>=8'} + /bl@4.1.0: + resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==} + dependencies: + buffer: 5.7.1 + inherits: 2.0.4 + readable-stream: 3.6.2 + dev: true + /body-parser@1.20.0: resolution: {integrity: sha512-DfJ+q6EPcGKZD1QWUjSpqp+Q7bDQTsQIF4zfUAtZ6qk+H/3/QRhg9CEp39ss+/T2vw0+HaidC0ecJj/DRLIaKg==} engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16} @@ -3221,6 +3445,13 @@ packages: resolution: {integrity: sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==} dev: true + /bplist-parser@0.2.0: + resolution: {integrity: sha512-z0M+byMThzQmD9NILRniCUXYsYpjwnlO8N5uCFaCqIOpqRsJCrQL9NK3JsD67CN5a08nF5oIL2bD6loTdHOuKw==} + engines: {node: '>= 5.10.0'} + dependencies: + big-integer: 1.6.52 + dev: true + /brace-expansion@1.1.11: resolution: {integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==} dependencies: @@ -3240,6 +3471,22 @@ packages: dependencies: fill-range: 7.0.1 + /browserslist-generator@2.1.0: + resolution: {integrity: sha512-ZFz4mAOgqm0cbwKaZsfJbYDbTXGoPANlte7qRsRJOfjB9KmmISQrXJxAVrnXG8C8v/QHNzXyeJt0Cfcks6zZvQ==} + engines: {node: '>=16.15.1', npm: '>=7.0.0', pnpm: '>=3.2.0', yarn: '>=1.13'} + dependencies: + '@mdn/browser-compat-data': 5.5.14 + '@types/object-path': 0.11.4 + '@types/semver': 7.5.8 + '@types/ua-parser-js': 0.7.39 + browserslist: 4.23.0 + caniuse-lite: 1.0.30001591 + isbot: 3.8.0 + object-path: 0.11.8 + semver: 7.6.0 + ua-parser-js: 1.0.37 + dev: true + /browserslist@4.23.0: resolution: {integrity: sha512-QW8HiM1shhT2GuzkvklfjcKDiWFXHOeFCIA/huJPwHsslwcydgk7X+z2zXpEijP98UCY7HbubZt5J2Zgvf0CaQ==} engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} @@ -3255,6 +3502,13 @@ packages: resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} dev: true + /buffer@5.7.1: + resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==} + dependencies: + base64-js: 1.5.1 + ieee754: 1.2.1 + dev: true + /builtin-modules@3.3.0: resolution: {integrity: sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==} engines: {node: '>=6'} @@ -3281,6 +3535,13 @@ packages: semver: 7.6.0 dev: true + /bundle-name@3.0.0: + resolution: {integrity: sha512-PKA4BeSvBpQKQ8iPOGCSiell+N8P+Tf1DlwqmYhpe2gAhKPHn8EYOxVT+ShuGmhg8lN8XiSlS80yiExKXrURlw==} + engines: {node: '>=12'} + dependencies: + run-applescript: 5.0.0 + dev: true + /bundle-require@4.0.2(esbuild@0.19.12): resolution: {integrity: sha512-jwzPOChofl67PSTW2SGubV9HBQAhhR2i6nskiOThauo9dzwDUgOWQScFVaJkjEfYX+UXiD+LEx8EblQMc2wIag==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -3323,6 +3584,14 @@ packages: engines: {node: '>=8'} dev: true + /cache-content-type@1.0.1: + resolution: {integrity: sha512-IKufZ1o4Ut42YUrZSo8+qnMTrFuKkvyoLXUywKz9GJ5BrhOFGhLdkx9sG4KAnVvbY6kEcSFjLQul+DVmBm2bgA==} + engines: {node: '>= 6.0.0'} + dependencies: + mime-types: 2.1.35 + ylru: 1.3.2 + dev: true + /call-bind@1.0.7: resolution: {integrity: sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==} engines: {node: '>= 0.4'} @@ -3407,6 +3676,10 @@ packages: resolution: {integrity: sha512-mKKUkUbhPpQlCOfIuZkvSEgktjPFIsZKRRbC6KWVEMvlzblj3i3asQv5ODsrwt0N3pHAEvjP8KTQPHkp0+6jOg==} dev: true + /chardet@0.7.0: + resolution: {integrity: sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==} + dev: true + /check-error@1.0.3: resolution: {integrity: sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==} dependencies: @@ -3470,6 +3743,13 @@ packages: escape-string-regexp: 1.0.5 dev: true + /cli-cursor@3.1.0: + resolution: {integrity: sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==} + engines: {node: '>=8'} + dependencies: + restore-cursor: 3.1.0 + dev: true + /cli-cursor@4.0.0: resolution: {integrity: sha512-VGtlMu3x/4DOtIUwEkRezxUZ2lBacNJCHash0N0WeZDBS+7Ux1dm3XWAgWYxLJFMMdOeXMHXorshEFhbMSGelg==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -3477,6 +3757,11 @@ packages: restore-cursor: 4.0.0 dev: true + /cli-spinners@2.9.2: + resolution: {integrity: sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==} + engines: {node: '>=6'} + dev: true + /cli-truncate@4.0.0: resolution: {integrity: sha512-nPdaFdQ0h/GEigbPClz11D0v/ZJEwxmeVZGeMo3Z5StPtUTkA9o1lD6QwoirYiSDzbcwn2XcjwmCp68W1IS4TA==} engines: {node: '>=18'} @@ -3485,6 +3770,11 @@ packages: string-width: 7.1.0 dev: true + /cli-width@4.1.0: + resolution: {integrity: sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==} + engines: {node: '>= 12'} + dev: true + /cliui@8.0.1: resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==} engines: {node: '>=12'} @@ -3503,6 +3793,16 @@ packages: shallow-clone: 3.0.1 dev: true + /clone@1.0.4: + resolution: {integrity: sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==} + engines: {node: '>=0.8'} + dev: true + + /co@4.6.0: + resolution: {integrity: sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==} + engines: {iojs: '>= 1.0.0', node: '>= 0.12.0'} + dev: true + /color-convert@1.9.3: resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==} dependencies: @@ -3761,12 +4061,25 @@ packages: engines: {node: '>= 0.6'} dev: true + /cookies@0.9.1: + resolution: {integrity: sha512-TG2hpqe4ELx54QER/S3HQ9SRVnQnGBtKUz5bLQWtYAQ+o6GpgMs6sYUvaiJjVxb+UXwhRhAEP3m7LbsIZ77Hmw==} + engines: {node: '>= 0.8'} + dependencies: + depd: 2.0.0 + keygrip: 1.1.0 + dev: true + /core-js-compat@3.36.0: resolution: {integrity: sha512-iV9Pd/PsgjNWBXeq8XRtWVSgz2tKAfhfvBs7qxYty+RlRd+OCksaWmOnc4JKrTc1cToXL1N0s3l/vwlxPtdElw==} dependencies: browserslist: 4.23.0 dev: true + /core-js@3.36.0: + resolution: {integrity: sha512-mt7+TUBbTFg5+GngsAxeKBTl5/VS0guFeJacYge9OmHb+m058UwwIm41SE9T4Den7ClatV57B6TYTuJ0CX1MAw==} + requiresBuild: true + dev: true + /core-util-is@1.0.3: resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==} dev: true @@ -3854,10 +4167,32 @@ packages: type-detect: 4.0.8 dev: true + /deep-equal@1.0.1: + resolution: {integrity: sha512-bHtC0iYvWhyaTzvV3CZgPeZQqCOBGyGsVV7v4eevpdkLHfiSrXUdBG+qAuSz4RI70sszvjQ1QSZ98An1yNwpSw==} + dev: true + /deep-is@0.1.4: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} dev: true + /default-browser-id@3.0.0: + resolution: {integrity: sha512-OZ1y3y0SqSICtE8DE4S8YOE9UZOJ8wO16fKWVP5J1Qz42kV9jcnMVFrEE/noXb/ss3Q4pZIH79kxofzyNNtUNA==} + engines: {node: '>=12'} + dependencies: + bplist-parser: 0.2.0 + untildify: 4.0.0 + dev: true + + /default-browser@4.0.0: + resolution: {integrity: sha512-wX5pXO1+BrhMkSbROFsyxUm0i/cJEScyNhA4PPxc41ICuv05ZZB/MX28s8aZx6xjmatvebIapF6hLEKEcpneUA==} + engines: {node: '>=14.16'} + dependencies: + bundle-name: 3.0.0 + default-browser-id: 3.0.0 + execa: 7.2.0 + titleize: 3.0.0 + dev: true + /default-gateway@6.0.3: resolution: {integrity: sha512-fwSOJsbbNzZ/CUFpqFBqYfYNLj1NbMPm8MMCIzHjC83iSJRBEGmDUxU+WP661BaBQImeC2yHwXtz+P/O9o+XEg==} engines: {node: '>= 10'} @@ -3865,6 +4200,12 @@ packages: execa: 5.1.1 dev: true + /defaults@1.0.4: + resolution: {integrity: sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A==} + dependencies: + clone: 1.0.4 + dev: true + /define-data-property@1.1.4: resolution: {integrity: sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==} engines: {node: '>= 0.4'} @@ -3879,10 +4220,19 @@ packages: engines: {node: '>=8'} dev: true + /define-lazy-prop@3.0.0: + resolution: {integrity: sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg==} + engines: {node: '>=12'} + dev: true + /defu@6.1.4: resolution: {integrity: sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==} dev: true + /delegates@1.0.0: + resolution: {integrity: sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==} + dev: true + /depd@1.1.2: resolution: {integrity: sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==} engines: {node: '>= 0.6'} @@ -3950,6 +4300,11 @@ packages: is-obj: 2.0.0 dev: true + /dotenv-expand@10.0.0: + resolution: {integrity: sha512-GopVGCpVS1UKH75VKHGuQFqS1Gusej0z4FyQkPdwjil2gNIv+LNsqBlboOzpJFZKVT95GkCyWJbBSdFEFUWI2A==} + engines: {node: '>=12'} + dev: true + /dotenv@16.4.5: resolution: {integrity: sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==} engines: {node: '>=12'} @@ -4627,6 +4982,21 @@ packages: strip-final-newline: 2.0.0 dev: true + /execa@7.2.0: + resolution: {integrity: sha512-UduyVP7TLB5IcAQl+OzLyLcS/l32W/GLg+AhHJ+ow40FOk2U3SAllPwR44v4vmdFwIWqpdwxxpQbF1n5ta9seA==} + engines: {node: ^14.18.0 || ^16.14.0 || >=18.0.0} + dependencies: + cross-spawn: 7.0.3 + get-stream: 6.0.1 + human-signals: 4.3.1 + is-stream: 3.0.0 + merge-stream: 2.0.0 + npm-run-path: 5.3.0 + onetime: 6.0.0 + signal-exit: 3.0.7 + strip-final-newline: 3.0.0 + dev: true + /execa@8.0.1: resolution: {integrity: sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==} engines: {node: '>=16.17'} @@ -4686,6 +5056,15 @@ packages: - supports-color dev: true + /external-editor@3.1.0: + resolution: {integrity: sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==} + engines: {node: '>=4'} + dependencies: + chardet: 0.7.0 + iconv-lite: 0.4.24 + tmp: 0.0.33 + dev: true + /fast-deep-equal@3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} dev: true @@ -4727,6 +5106,13 @@ packages: websocket-driver: 0.7.4 dev: true + /figures@3.2.0: + resolution: {integrity: sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg==} + engines: {node: '>=8'} + dependencies: + escape-string-regexp: 1.0.5 + dev: true + /file-entry-cache@6.0.1: resolution: {integrity: sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==} engines: {node: ^10.12.0 || >=12.0.0} @@ -5105,6 +5491,13 @@ packages: engines: {node: '>= 0.4'} dev: true + /has-tostringtag@1.0.2: + resolution: {integrity: sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==} + engines: {node: '>= 0.4'} + dependencies: + has-symbols: 1.0.3 + dev: true + /hasown@2.0.1: resolution: {integrity: sha512-1/th4MHjnwncwXsIW6QMzlvYL9kG5e/CpVvLRZe4XPa8TOUNbCELqmvhDmnkNsAjwaG4+I8gJJL0JBvTTLO9qA==} engines: {node: '>= 0.4'} @@ -5141,10 +5534,26 @@ packages: resolution: {integrity: sha512-igBTJcNNNhvZFRtm8uA6xMY6xYleeDwn3PeBCkDz7tHttv4F2hsDI2aPgNERWzvRcNYHNT3ymRaQzllmXj4YsQ==} dev: true + /http-assert@1.5.0: + resolution: {integrity: sha512-uPpH7OKX4H25hBmU6G1jWNaqJGpTXxey+YOUizJUAgu0AjLUeC8D73hTrhvDS5D+GJN1DN1+hhc/eF/wpxtp0w==} + engines: {node: '>= 0.8'} + dependencies: + deep-equal: 1.0.1 + http-errors: 1.8.1 + dev: true + /http-deceiver@1.2.7: resolution: {integrity: sha512-LmpOGxTfbpgtGVxJrj5k7asXHCgNZp5nLfp+hWc8QQRqtb7fUy6kRY3BO1h9ddF6yIPYUARgxGOwB42DnxIaNw==} dev: true + /http-errors@1.4.0: + resolution: {integrity: sha512-oLjPqve1tuOl5aRhv8GK5eHpqP1C9fb+Ol+XTLjKfLltE44zdDbEdjPSbU7Ch5rSNsVFqZn97SrMmZLdu1/YMw==} + engines: {node: '>= 0.6'} + dependencies: + inherits: 2.0.1 + statuses: 1.5.0 + dev: true + /http-errors@1.6.3: resolution: {integrity: sha512-lks+lVC8dgGyh97jxvxeYTWQFvh4uw4yC12gVl63Cg30sjPX4wuGcdkICVXDAESr6OJGjqGA8Iz5mkeN6zlD7A==} engines: {node: '>= 0.6'} @@ -5155,6 +5564,17 @@ packages: statuses: 1.5.0 dev: true + /http-errors@1.8.1: + resolution: {integrity: sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==} + engines: {node: '>= 0.6'} + dependencies: + depd: 1.1.2 + inherits: 2.0.4 + setprototypeof: 1.2.0 + statuses: 1.5.0 + toidentifier: 1.0.1 + dev: true + /http-errors@2.0.0: resolution: {integrity: sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==} engines: {node: '>= 0.8'} @@ -5205,6 +5625,11 @@ packages: engines: {node: '>=10.17.0'} dev: true + /human-signals@4.3.1: + resolution: {integrity: sha512-nZXjEF2nbo7lIw3mgYjItAfgQXog3OjJogSbKa2CQIIvSGWcKgeJnQlNXip6NglNzYH45nSRiEVimMvYL8DDqQ==} + engines: {node: '>=14.18.0'} + dev: true + /human-signals@5.0.0: resolution: {integrity: sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==} engines: {node: '>=16.17.0'} @@ -5217,6 +5642,10 @@ packages: safer-buffer: 2.1.2 dev: true + /ieee754@1.2.1: + resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} + dev: true + /ignore@5.3.1: resolution: {integrity: sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==} engines: {node: '>= 4'} @@ -5256,6 +5685,10 @@ packages: wrappy: 1.0.2 dev: true + /inherits@2.0.1: + resolution: {integrity: sha512-8nWq2nLTAwd02jTqJExUYFSD/fKq6VH9Y/oG2accc/kdI0V98Bag8d5a4gi3XHz73rDWa2PvTtvcWYquKqSENA==} + dev: true + /inherits@2.0.3: resolution: {integrity: sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==} dev: true @@ -5264,6 +5697,27 @@ packages: resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} dev: true + /inquirer@9.2.15: + resolution: {integrity: sha512-vI2w4zl/mDluHt9YEQ/543VTCwPKWiHzKtm9dM2V0NdFcqEexDAjUHzO1oA60HRNaVifGXXM1tRRNluLVHa0Kg==} + engines: {node: '>=18'} + dependencies: + '@ljharb/through': 2.3.13 + ansi-escapes: 4.3.2 + chalk: 5.3.0 + cli-cursor: 3.1.0 + cli-width: 4.1.0 + external-editor: 3.1.0 + figures: 3.2.0 + lodash: 4.17.21 + mute-stream: 1.0.0 + ora: 5.4.1 + run-async: 3.0.0 + rxjs: 7.8.1 + string-width: 4.2.3 + strip-ansi: 6.0.1 + wrap-ansi: 6.2.0 + dev: true + /interpret@2.2.0: resolution: {integrity: sha512-Ju0Bz/cEia55xDwUWEa8+olFpCiQoypjnQySseKtmjNrnps3P+xfpUmGr90T7yjlVJmOtybRvPXhKMbHr+fWnw==} engines: {node: '>= 0.10'} @@ -5328,6 +5782,12 @@ packages: hasBin: true dev: true + /is-docker@3.0.0: + resolution: {integrity: sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + hasBin: true + dev: true + /is-extglob@2.1.1: resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} engines: {node: '>=0.10.0'} @@ -5349,6 +5809,13 @@ packages: get-east-asian-width: 1.2.0 dev: true + /is-generator-function@1.0.10: + resolution: {integrity: sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A==} + engines: {node: '>= 0.4'} + dependencies: + has-tostringtag: 1.0.2 + dev: true + /is-glob@4.0.3: resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} engines: {node: '>=0.10.0'} @@ -5359,6 +5826,19 @@ packages: resolution: {integrity: sha512-gyPJuv83bHMpocVYoqof5VDiZveEoGoFL8m3BXNb2VW8Xs+rz9kqO8LOQ5DH6EsuvilT1ApazU0pyl+ytbPtlw==} dev: true + /is-inside-container@1.0.0: + resolution: {integrity: sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==} + engines: {node: '>=14.16'} + hasBin: true + dependencies: + is-docker: 3.0.0 + dev: true + + /is-interactive@1.0.0: + resolution: {integrity: sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==} + engines: {node: '>=8'} + dev: true + /is-number@7.0.0: resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} engines: {node: '>=0.12.0'} @@ -5402,6 +5882,11 @@ packages: text-extensions: 2.4.0 dev: true + /is-unicode-supported@0.1.0: + resolution: {integrity: sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==} + engines: {node: '>=10'} + dev: true + /is-wsl@2.2.0: resolution: {integrity: sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==} engines: {node: '>=8'} @@ -5409,10 +5894,19 @@ packages: is-docker: 2.2.1 dev: true + /isarray@0.0.1: + resolution: {integrity: sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==} + dev: true + /isarray@1.0.0: resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==} dev: true + /isbot@3.8.0: + resolution: {integrity: sha512-vne1mzQUTR+qsMLeCBL9+/tgnDXRyc2pygLGl/WsgA+EZKIiB5Ehu0CiVTHIIk30zhJ24uGz4M5Ppse37aR0Hg==} + engines: {node: '>=12'} + dev: true + /isexe@2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} dev: true @@ -5549,6 +6043,13 @@ packages: engines: {'0': node >= 0.2.0} dev: true + /keygrip@1.1.0: + resolution: {integrity: sha512-iYSchDJ+liQ8iwbSI2QqsQOvqv58eJCEanyJPJi+Khyu8smkcKSFUCbPwzFcL7YVtZ6eONjqRX/38caJ7QjRAQ==} + engines: {node: '>= 0.6'} + dependencies: + tsscmp: 1.0.6 + dev: true + /keyv@4.5.4: resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==} dependencies: @@ -5565,6 +6066,97 @@ packages: engines: {node: '>=6'} dev: true + /koa-compose@4.1.0: + resolution: {integrity: sha512-8ODW8TrDuMYvXRwra/Kh7/rJo9BtOfPc6qO8eAfC80CnCvSjSl0bkRM24X6/XBBEyj0v1nRUQ1LyOy3dbqOWXw==} + dev: true + + /koa-compress@5.1.1: + resolution: {integrity: sha512-UgMIN7ZoEP2DuoSQmD6CYvFSLt0NReGlc2qSY4bO4Oq0L56OiD9pDG41Kj/zFmVY/A3Wvmn4BqKcfq5H30LGIg==} + engines: {node: '>= 12'} + dependencies: + bytes: 3.1.2 + compressible: 2.0.18 + http-errors: 1.8.1 + koa-is-json: 1.0.0 + dev: true + + /koa-convert@2.0.0: + resolution: {integrity: sha512-asOvN6bFlSnxewce2e/DK3p4tltyfC4VM7ZwuTuepI7dEQVcvpyFuBcEARu1+Hxg8DIwytce2n7jrZtRlPrARA==} + engines: {node: '>= 10'} + dependencies: + co: 4.6.0 + koa-compose: 4.1.0 + dev: true + + /koa-is-json@1.0.0: + resolution: {integrity: sha512-+97CtHAlWDx0ndt0J8y3P12EWLwTLMXIfMnYDev3wOTwH/RpBGMlfn4bDXlMEg1u73K6XRE9BbUp+5ZAYoRYWw==} + dev: true + + /koa-proxies@0.12.4(koa@2.15.0): + resolution: {integrity: sha512-xxrEtN0e7s7/gNRoOMUltCbuIaCWqTQUTZNWQqet/8MoxSW0hG422lx2Al9FfYO3nCeA+b5c5/YmILRzavivDA==} + peerDependencies: + koa: '>=2' + dependencies: + http-proxy: 1.18.1 + koa: 2.15.0 + path-match: 1.2.4 + uuid: 8.3.2 + transitivePeerDependencies: + - debug + dev: true + + /koa-send@5.0.1: + resolution: {integrity: sha512-tmcyQ/wXXuxpDxyNXv5yNNkdAMdFRqwtegBXUaowiQzUKqJehttS0x2j0eOZDQAyloAth5w6wwBImnFzkUz3pQ==} + engines: {node: '>= 8'} + dependencies: + debug: 4.3.4 + http-errors: 1.8.1 + resolve-path: 1.4.0 + transitivePeerDependencies: + - supports-color + dev: true + + /koa-static@5.0.0: + resolution: {integrity: sha512-UqyYyH5YEXaJrf9S8E23GoJFQZXkBVJ9zYYMPGz919MSX1KuvAcycIuS0ci150HCoPf4XQVhQ84Qf8xRPWxFaQ==} + engines: {node: '>= 7.6.0'} + dependencies: + debug: 3.2.7 + koa-send: 5.0.1 + transitivePeerDependencies: + - supports-color + dev: true + + /koa@2.15.0: + resolution: {integrity: sha512-KEL/vU1knsoUvfP4MC4/GthpQrY/p6dzwaaGI6Rt4NQuFqkw3qrvsdYF5pz3wOfi7IGTvMPHC9aZIcUKYFNxsw==} + engines: {node: ^4.8.4 || ^6.10.1 || ^7.10.1 || >= 8.1.4} + dependencies: + accepts: 1.3.8 + cache-content-type: 1.0.1 + content-disposition: 0.5.4 + content-type: 1.0.5 + cookies: 0.9.1 + debug: 4.3.4 + delegates: 1.0.0 + depd: 2.0.0 + destroy: 1.2.0 + encodeurl: 1.0.2 + escape-html: 1.0.3 + fresh: 0.5.2 + http-assert: 1.5.0 + http-errors: 1.6.3 + is-generator-function: 1.0.10 + koa-compose: 4.1.0 + koa-convert: 2.0.0 + on-finished: 2.4.1 + only: 0.0.2 + parseurl: 1.3.3 + statuses: 1.5.0 + type-is: 1.6.18 + vary: 1.1.2 + transitivePeerDependencies: + - supports-color + dev: true + /kolorist@1.8.0: resolution: {integrity: sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ==} dev: true @@ -5684,6 +6276,10 @@ packages: p-locate: 6.0.0 dev: true + /lodash.debounce@4.0.8: + resolution: {integrity: sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==} + dev: true + /lodash.merge@4.6.2: resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==} dev: true @@ -5696,6 +6292,14 @@ packages: resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} dev: true + /log-symbols@4.1.0: + resolution: {integrity: sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==} + engines: {node: '>=10'} + dependencies: + chalk: 4.1.2 + is-unicode-supported: 0.1.0 + dev: true + /log-update@6.0.0: resolution: {integrity: sha512-niTvB4gqvtof056rRIrTZvjNYE4rCUzO6X/X+kYjd7WFxXeJ0NwEFnRxX6ehkvv3jTwrXnNdtAak5XYZuIyPFw==} engines: {node: '>=18'} @@ -5707,6 +6311,11 @@ packages: wrap-ansi: 9.0.0 dev: true + /loglevel@1.9.1: + resolution: {integrity: sha512-hP3I3kCrDIMuRwAwHltphhDM1r8i55H33GgqjXbrisuJhF4kRhW1dNuxsRklp4bXl8DSdLaNLuiL4A/LWRfxvg==} + engines: {node: '>= 0.6.0'} + dev: true + /longest-streak@3.1.0: resolution: {integrity: sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g==} dev: true @@ -6290,6 +6899,11 @@ packages: thunky: 1.1.0 dev: true + /mute-stream@1.0.0: + resolution: {integrity: sha512-avsJQhyd+680gKXyG/sQc0nXaC6rBkPOfyHYcFb9+hdkqQkR9bdnkJ0AMZhke0oesPqIO+mFFJ+IdBc7mst4IA==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + dev: true + /mz@2.7.0: resolution: {integrity: sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==} dependencies: @@ -6397,6 +7011,11 @@ packages: resolution: {integrity: sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==} dev: true + /object-path@0.11.8: + resolution: {integrity: sha512-YJjNZrlXJFM42wTBn6zgOJVar9KFJvzx6sTWDte8sWZF//cnjl0BxHNpfZx+ZffXX63A9q0b1zsFiBX4g4X5KA==} + engines: {node: '>= 10.12.0'} + dev: true + /obuf@1.1.2: resolution: {integrity: sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg==} dev: true @@ -6445,6 +7064,10 @@ packages: mimic-fn: 4.0.0 dev: true + /only@0.0.2: + resolution: {integrity: sha512-Fvw+Jemq5fjjyWz6CpKx6w9s7xxqo3+JCyM0WXWeCSOboZ8ABkyvP8ID4CZuChA/wxSx+XSJmdOm8rGVyJ1hdQ==} + dev: true + /open@8.4.2: resolution: {integrity: sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==} engines: {node: '>=12'} @@ -6454,6 +7077,16 @@ packages: is-wsl: 2.2.0 dev: true + /open@9.1.0: + resolution: {integrity: sha512-OS+QTnw1/4vrf+9hh1jc1jnYjzSG4ttTBB8UxOwAnInG3Uo4ssetzC1ihqaIHjLJnA5GGlRl6QlZXOTQhRBUvg==} + engines: {node: '>=14.16'} + dependencies: + default-browser: 4.0.0 + define-lazy-prop: 3.0.0 + is-inside-container: 1.0.0 + is-wsl: 2.2.0 + dev: true + /opener@1.5.2: resolution: {integrity: sha512-ur5UIdyw5Y7yEj9wLzhqXiy6GZ3Mwx0yGI+5sMn2r0N0v3cKJvUmFH5yPP+WXh9e0xfyzyJX95D8l088DNFj7A==} hasBin: true @@ -6471,6 +7104,26 @@ packages: type-check: 0.4.0 dev: true + /ora@5.4.1: + resolution: {integrity: sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ==} + engines: {node: '>=10'} + dependencies: + bl: 4.1.0 + chalk: 4.1.2 + cli-cursor: 3.1.0 + cli-spinners: 2.9.2 + is-interactive: 1.0.0 + is-unicode-supported: 0.1.0 + log-symbols: 4.1.0 + strip-ansi: 6.0.1 + wcwidth: 1.0.1 + dev: true + + /os-tmpdir@1.0.2: + resolution: {integrity: sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==} + engines: {node: '>=0.10.0'} + dev: true + /p-limit@2.3.0: resolution: {integrity: sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==} engines: {node: '>=6'} @@ -6611,6 +7264,13 @@ packages: engines: {node: '>=12'} dev: true + /path-match@1.2.4: + resolution: {integrity: sha512-UWlehEdqu36jmh4h5CWJ7tARp1OEVKGHKm6+dg9qMq5RKUTV5WJrGgaZ3dN2m7WFAXDbjlHzvJvL/IUpy84Ktw==} + dependencies: + http-errors: 1.4.0 + path-to-regexp: 1.8.0 + dev: true + /path-parse@1.0.7: resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} dev: true @@ -6627,6 +7287,12 @@ packages: resolution: {integrity: sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==} dev: true + /path-to-regexp@1.8.0: + resolution: {integrity: sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==} + dependencies: + isarray: 0.0.1 + dev: true + /path-type@4.0.0: resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} engines: {node: '>=8'} @@ -6935,6 +7601,14 @@ packages: engines: {node: '>=8'} dev: true + /resolve-path@1.4.0: + resolution: {integrity: sha512-i1xevIst/Qa+nA9olDxLWnLk8YZbi8R/7JPbCMcgyWaFR6bKWaexgJgEB5oc2PKMjYdrHynyz0NY+if+H98t1w==} + engines: {node: '>= 0.8'} + dependencies: + http-errors: 1.6.3 + path-is-absolute: 1.0.1 + dev: true + /resolve-pkg-maps@1.0.0: resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==} dev: true @@ -6948,6 +7622,14 @@ packages: supports-preserve-symlinks-flag: 1.0.0 dev: true + /restore-cursor@3.1.0: + resolution: {integrity: sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==} + engines: {node: '>=8'} + dependencies: + onetime: 5.1.2 + signal-exit: 3.0.7 + dev: true + /restore-cursor@4.0.0: resolution: {integrity: sha512-I9fPXU9geO9bHOt9pHHOhOkYerIMsmVaWB0rA2AI9ERh/+x/i7MV5HKBNrg+ljO5eoPVgCcnFuRjJ9uH6I/3eg==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -7000,12 +7682,30 @@ packages: fsevents: 2.3.3 dev: true + /run-applescript@5.0.0: + resolution: {integrity: sha512-XcT5rBksx1QdIhlFOCtgZkB99ZEouFZ1E2Kc2LHqNW13U3/74YGdkQRmThTwxy4QIyookibDKYZOPqX//6BlAg==} + engines: {node: '>=12'} + dependencies: + execa: 5.1.1 + dev: true + + /run-async@3.0.0: + resolution: {integrity: sha512-540WwVDOMxA6dN6We19EcT9sc3hkXPw5mzRNGM3FkdN/vtE9NFvj5lFAPNwUDmJjXidm3v7TC1cTE7t17Ulm1Q==} + engines: {node: '>=0.12.0'} + dev: true + /run-parallel@1.2.0: resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} dependencies: queue-microtask: 1.2.3 dev: true + /rxjs@7.8.1: + resolution: {integrity: sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==} + dependencies: + tslib: 2.6.2 + dev: true + /safe-buffer@5.1.2: resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==} dev: true @@ -7250,6 +7950,10 @@ packages: engines: {node: '>=8'} dev: true + /slashes@3.0.12: + resolution: {integrity: sha512-Q9VME8WyGkc7pJf6QEkj3wE+2CnvZMI+XJhwdTPR8Z/kWQRXi7boAWLDibRPyHRTUTPx5FaU7MsyrjI3yLB4HA==} + dev: true + /slice-ansi@5.0.0: resolution: {integrity: sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ==} engines: {node: '>=12'} @@ -7627,6 +8331,18 @@ packages: engines: {node: '>=14.0.0'} dev: true + /titleize@3.0.0: + resolution: {integrity: sha512-KxVu8EYHDPBdUYdKZdKtU2aj2XfEx9AfjXxE/Aj0vT06w2icA09Vus1rh6eSu1y01akYg6BjIK/hxyLJINoMLQ==} + engines: {node: '>=12'} + dev: true + + /tmp@0.0.33: + resolution: {integrity: sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==} + engines: {node: '>=0.6.0'} + dependencies: + os-tmpdir: 1.0.2 + dev: true + /to-fast-properties@2.0.0: resolution: {integrity: sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==} engines: {node: '>=4'} @@ -7692,6 +8408,11 @@ packages: resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} dev: true + /tsscmp@1.0.6: + resolution: {integrity: sha512-LxhtAkPDTkVCMQjt2h6eBVY28KCjikZqZfMcC15YBeNjkgUpdCfBu5HoiOTDu86v6smE8yOjyEktJ8hlbANHQA==} + engines: {node: '>=0.6.x'} + dev: true + /tsup@8.0.2(typescript@5.3.3): resolution: {integrity: sha512-NY8xtQXdH7hDUAZwcQdY/Vzlw9johQsaqf7iwZ6g1DOUlFYQ5/AtVAjTvihhEyeRlGo4dLRVHtrRaL35M1daqQ==} engines: {node: '>=18'} @@ -7782,6 +8503,11 @@ packages: engines: {node: '>=10'} dev: true + /type-fest@0.21.3: + resolution: {integrity: sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==} + engines: {node: '>=10'} + dev: true + /type-fest@0.6.0: resolution: {integrity: sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==} engines: {node: '>=8'} @@ -7816,6 +8542,10 @@ packages: hasBin: true dev: true + /ua-parser-js@1.0.37: + resolution: {integrity: sha512-bhTyI94tZofjo+Dn8SN6Zv8nBDvyXTymAdM3LDI/0IboIUwTu1rEhW7v2TfiVsoYWgkQ4kOVqnI8APUFbIQIFQ==} + dev: true + /uc.micro@2.1.0: resolution: {integrity: sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==} dev: true @@ -8008,6 +8738,11 @@ packages: webpack-virtual-modules: 0.6.1 dev: true + /untildify@4.0.0: + resolution: {integrity: sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==} + engines: {node: '>=8'} + dev: true + /update-browserslist-db@1.0.13(browserslist@4.23.0): resolution: {integrity: sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==} hasBin: true @@ -8352,6 +9087,11 @@ packages: typescript: 5.3.3 dev: true + /walkdir@0.4.1: + resolution: {integrity: sha512-3eBwRyEln6E1MSzcxcVpQIhRG8Q1jLvEqRmCZqS3dsfXEDR/AhOF4d+jHg1qvDCpYaVRZjENPQyrVxAkQqxPgQ==} + engines: {node: '>=6.0.0'} + dev: true + /watchpack@2.4.0: resolution: {integrity: sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg==} engines: {node: '>=10.13.0'} @@ -8366,6 +9106,12 @@ packages: minimalistic-assert: 1.0.1 dev: true + /wcwidth@1.0.1: + resolution: {integrity: sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==} + dependencies: + defaults: 1.0.4 + dev: true + /webidl-conversions@4.0.2: resolution: {integrity: sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==} dev: true @@ -8611,6 +9357,15 @@ packages: resolution: {integrity: sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==} dev: true + /wrap-ansi@6.2.0: + resolution: {integrity: sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==} + engines: {node: '>=8'} + dependencies: + ansi-styles: 4.3.0 + string-width: 4.2.3 + strip-ansi: 6.0.1 + dev: true + /wrap-ansi@7.0.0: resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} engines: {node: '>=10'} @@ -8750,6 +9505,11 @@ packages: yargs-parser: 21.1.1 dev: true + /ylru@1.3.2: + resolution: {integrity: sha512-RXRJzMiK6U2ye0BlGGZnmpwJDPgakn6aNQ0A7gHRbD4I0uvK4TW6UqkK1V0pp9jskjJBAXd3dRrbzWkqJ+6cxA==} + engines: {node: '>= 4.0.0'} + dev: true + /yocto-queue@0.1.0: resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} engines: {node: '>=10'} @@ -8775,4 +9535,4 @@ packages: /zwitch@2.0.4: resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==} - dev: true \ No newline at end of file + dev: true From 2f03ec09edd341b6cbf1aa5be375381228ba43db Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Tue, 12 Mar 2024 22:33:20 +0800 Subject: [PATCH 53/58] chore: bump farm version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 246864f1..19e392bf 100644 --- a/README.md +++ b/README.md @@ -32,4 +32,4 @@ Learn more on the [Documentation](https://unplugin.vercel.app/) [npm-downloads-src]: https://img.shields.io/npm/dm/unplugin?style=flat&colorA=18181B&colorB=F0DB4F [npm-downloads-href]: https://npmjs.com/package/unplugin [license-src]: https://img.shields.io/github/license/unjs/unplugin.svg?style=flat&colorA=18181B&colorB=F0DB4F -[license-href]: https://github.com/unjs/unplugin/blob/main/LICENSE \ No newline at end of file +[license-href]: https://github.com/unjs/unplugin/blob/main/LICENSE From f40a359b0393f955f3a71583b17a1bcebc44f190 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Wed, 13 Mar 2024 14:42:18 +0800 Subject: [PATCH 54/58] chore: Modify the introduction mode of relative path --- src/farm/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/farm/utils.ts b/src/farm/utils.ts index 58d0063d..429444a8 100644 --- a/src/farm/utils.ts +++ b/src/farm/utils.ts @@ -1,6 +1,6 @@ import path from 'node:path' import * as querystring from 'node:querystring' -import type { TransformResult } from 'src/types' +import type { TransformResult } from '../types' export * from '../utils' From 08cee9ee760ed7c8ad026365e06c7668a8ef4090 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Wed, 13 Mar 2024 16:14:26 +0800 Subject: [PATCH 55/58] docs: add farm docs --- docs/guide/index.md | 65 +++++++++++++++++++++------------- docs/index.md | 8 ++--- docs/public/features/farm.png | Bin 0 -> 12071 bytes tsup.config.ts | 1 + 4 files changed, 46 insertions(+), 28 deletions(-) create mode 100644 docs/public/features/farm.png diff --git a/docs/guide/index.md b/docs/guide/index.md index 62b0582f..cc401753 100644 --- a/docs/guide/index.md +++ b/docs/guide/index.md @@ -17,6 +17,7 @@ lastUpdated: false - [esbuild](https://esbuild.github.io/) - [Rspack](https://www.rspack.dev/) (⚠️ experimental) - [Rolldown](https://rolldown.rs/) (⚠️ experimental) +- [Farm](https://farm-fe.github.io/) ## Trying It Online @@ -119,6 +120,19 @@ build({ }) ``` +```ts [Farm] +// farm.config.ts +import Starter from 'unplugin-starter/farm' + +export default defineConfig({ + plugins: [ + Starter({ + /* options */ + }), + ], +}) +``` + ```js [Vue-CLI] // vue.config.js module.exports = { @@ -154,18 +168,18 @@ export default defineConfig({ ## Supported Hooks -| Hook | Rollup | Vite | webpack 4 | webpack 5 | esbuild | Rspack | -| ----------------------------------------------------------------------------------| :-------------: | :--: | :-------: | :-------: | :-----------: | :----: | -| [`enforce`](https://vitejs.dev/guide/api-plugin.html#plugin-ordering) | ❌ 1 | ✅ | ✅ | ✅ | ❌ 1 | ✅ | -| [`buildStart`](https://rollupjs.org/plugin-development/#buildstart) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`resolveId`](https://rollupjs.org/plugin-development/#resolveid) | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | -| `loadInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`load`](https://rollupjs.org/plugin-development/#load) | ✅ | ✅ | ✅ | ✅ | ✅ 3 | ✅ | -| `transformInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`transform`](https://rollupjs.org/plugin-development/#transform) | ✅ | ✅ | ✅ | ✅ | ✅ 3 | ✅ | -| [`watchChange`](https://rollupjs.org/plugin-development/#watchchange) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | -| [`buildEnd`](https://rollupjs.org/plugin-development/#buildend) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`writeBundle`](https://rollupjs.org/plugin-development/#writebundle)4 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| Hook | Rollup | Vite | webpack 4 | webpack 5 | esbuild | Rspack | Farm | +| ----------------------------------------------------------------------------------| :-------------: | :--: | :-------: | :-------: | :-----------: | :----: | :---: | +| [`enforce`](https://vitejs.dev/guide/api-plugin.html#plugin-ordering) | ❌ 1 | ✅ | ✅ | ✅ | ❌ 1 | ✅ | ✅ | +| [`buildStart`](https://rollupjs.org/plugin-development/#buildstart) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`resolveId`](https://rollupjs.org/plugin-development/#resolveid) | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | +| `loadInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`load`](https://rollupjs.org/plugin-development/#load) | ✅ | ✅ | ✅ | ✅ | ✅ 3 | ✅ | ✅ | +| `transformInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`transform`](https://rollupjs.org/plugin-development/#transform) | ✅ | ✅ | ✅ | ✅ | ✅ 3 | ✅ | ✅ | +| [`watchChange`](https://rollupjs.org/plugin-development/#watchchange) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | +| [`buildEnd`](https://rollupjs.org/plugin-development/#buildend) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`writeBundle`](https://rollupjs.org/plugin-development/#writebundle)4 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ::: details Notice 1. Rollup and esbuild do not support using `enforce` to control the order of plugins. Users need to maintain the order manually. @@ -207,18 +221,19 @@ export const rollupPlugin = unplugin.rollup export const webpackPlugin = unplugin.webpack export const rspackPlugin = unplugin.rspack export const esbuildPlugin = unplugin.esbuild +export const farmPlugin = unplugin.farm ``` ## Supported Context -| Context | Rollup | Vite | webpack 4 | webpack 5 | esbuild | Rspack | -| -------------------------------------------------------------------------- | :----: | :--: | :-------: | :-------: | :-----: | :----: | -| [`this.parse`](https://rollupjs.org/plugin-development/#this-parse) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`this.addWatchFile`](https://rollupjs.org/plugin-development/#this-addwatchfile) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | -| [`this.emitFile`](https://rollupjs.org/plugin-development/#this-emitfile)1 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`this.getWatchFiles`](https://rollupjs.org/plugin-development/#this-getwatchfiles) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | -| [`this.warn`](https://rollupjs.org/plugin-development/#this-warn) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [`this.error`](https://rollupjs.org/plugin-development/#this-error) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| Context | Rollup | Vite | webpack 4 | webpack 5 | esbuild | Rspack | Farm | +| -------------------------------------------------------------------------- | :----: | :--: | :-------: | :-------: | :-----: | :----: | :---: | +| [`this.parse`](https://rollupjs.org/plugin-development/#this-parse) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`this.addWatchFile`](https://rollupjs.org/plugin-development/#this-addwatchfile) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | +| [`this.emitFile`](https://rollupjs.org/plugin-development/#this-emitfile)1 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`this.getWatchFiles`](https://rollupjs.org/plugin-development/#this-getwatchfiles) | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | +| [`this.warn`](https://rollupjs.org/plugin-development/#this-warn) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`this.error`](https://rollupjs.org/plugin-development/#this-error) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ::: info Notice 1. Currently, [`this.emitFile`](https://rollupjs.org/plugin-development/#thisemitfile) only supports the `EmittedAsset` variant. @@ -230,9 +245,9 @@ Since `v0.10.0`, **Unplugin** supports constructing multiple nested plugins to b ### Bundler Supported -| Rollup | Vite | webpack 4 | webpack 5 | Rspack | esbuild | -| :--------------------: | :--: | :-------: | :-------: | :----: | :----------: | -| ✅ `>=3.1`1 | ✅ | ✅ | ✅ | ✅ | ✅ (v1.8.0+) | +| Rollup | Vite | webpack 4 | webpack 5 | Rspack | esbuild | Farm | +| :--------------------: | :--: | :-------: | :-------: | :----: | :----------: | :--: | +| ✅ `>=3.1`1 | ✅ | ✅ | ✅ | ✅ | ✅ (v1.8.0+) | ✅ | ::: details Notice 1. Rollup supports nested plugins since [v3.1.0](https://github.com/rollup/rollup/releases/tag/v3.1.0). Plugin author should ask users to have a Rollup version of `>=3.1.0` when using nested plugins. For single plugin format, **Unplugin** works for any version of Rollup. @@ -335,10 +350,11 @@ Each of the function takes the same generic factory argument as `createUnplugin` ```ts import { createEsbuildPlugin, + createFarmPlugin, createRollupPlugin, createRspackPlugin, createVitePlugin, - createWebpackPlugin + createWebpackPlugin, } from 'unplugin' const vitePlugin = createVitePlugin({ /* options */ }) @@ -346,4 +362,5 @@ const rollupPlugin = createRollupPlugin({ /* options */ }) const esbuildPlugin = createEsbuildPlugin({ /* options */ }) const webpackPlugin = createWebpackPlugin({ /* options */ }) const rspackPlugin = createRspackPlugin({ /* options */ }) +const farmPlugin = createFarmPlugin({ /* options */ }) ``` diff --git a/docs/index.md b/docs/index.md index 6089b4ab..5854a0f6 100644 --- a/docs/index.md +++ b/docs/index.md @@ -52,9 +52,9 @@ features: icon: src: /features/rspack.png - - title: More - details: More supported bundlers... - link: /guide/#supported-hooks + - title: Farm + details: Extremely fast web build tool written in Rust + link: https://farm-fe.github.io/ icon: - src: /features/more.svg + src: /features/farm.png --- diff --git a/docs/public/features/farm.png b/docs/public/features/farm.png new file mode 100644 index 0000000000000000000000000000000000000000..e34e3455b9df7a5ed269d50b350736b60b5c4862 GIT binary patch literal 12071 zcmb7KWm6nYxZPbeK#<_U-Q9h$;BEneyF+kiad)>6EV#RFaDqdS;1Jy133uQ72X5UD zBQ;es)!oy5`Z*G%sx0#!^X_ zUK$p6Z@v4a4k!~W)CfbddgpRYe1`PZB>wc43*EzTemCYL|b5m60+utI@=mVKn?)}Baw z-0D}&D0L351U9B7MMk!|++VT%kiJZ)yXY9>hhp&+oY1{n0Z&@nhiaUbYx!C=r0Pu(aD_8Wp|Q&%@Geg!zfO z8{eL`-2BVWOjlZ*_*d`HPGyiPfsw*l&&pIev1wk#&gDy~>R8N#i4l7#+l-HOR=wNN z187VWAOkRupG4+F|CV-$%o(>Haw3^_7z@#eR>_eRis1e9Ua{xkV)6DtTAy1ze|q#6 z2_UZ$@(l;PLK5&N^^l%33ibxXAhlF8TR8_~6Y1l+P^rK~vt8yzlkZA25}5mY7gSx# zu}SgNoOSHXH+6f|4L*xDM=Y<&6uZRekMyxwRy>sn!A4-zyX2OZ!>=+qe!Zo&;G2jjS~eJB>hy?RDhBtw@hB}FCWp;IM59X6du!j1tw$gw+a;8o2C&dBxnUK=VBoNJnJq6J)zf@D%%G`i-$4ecVm297d^IgvAsvz zOQS#*OvD^65=ja6z&RY-NA`S$97#K!ikqva!U=_QjXy0LF2=Q{9J@=}C{I-kT`gSs zOgR!PWEn)mv`3p}5xr+_THkLq&<{ulNN&223Kcj>WL7bm%el`{yhv3_UcX44QrB#3 zqI-#&m(sx_kddYGm61pVup1&>I8lC2y7KJ$CBNPZ|1krhxAv#f_w>%*IQ!Fsw0_(@%e4h8vj{uIvm*a`AG?4R8Dnz(*172o_ zE)ymjcK!xBGZT zv!CP7zi-*a@QL_A&s(FzSQFtXCdUqv>&U0QtuWH_yX=bnzN(zB#FT7#)SJ?Pv7gv) zQ~QlPKe@J9xZ6^mlED@UPQ0g%(-HYaJLtNi^V4{{-_&9rm3jHB<|Q?l>Y06}O?Wde zZ<+oX3F#)qjfX#CQP2chr8xW@Wk{x`VE;*#qI-5F3N^A^Vai%r6Gt$xu*i4zfe}gsFfqnZ)B1ayXzk zjD?EWgA3+qe7P!A98Ml1W)~R=4zWwv5q_e<#sIcS0p0`5;E;&`dOTxnVq~=}mcmM4 zJk(Gsd8xK4pQ4w*ta$3h!&Z^V>b7l6dbcX2st2AVb}X!LzKV7Lq z3ipzs{VNXGs8agS(m-RxGf<;!7w9=Xmwjmb1ox^=jylfMYi9fo%!o(P79)OL`RdL$ zaKq7X$6@)x7{%UfP8E4fTwno33g{{7j9{OYV-`C?^2Tux`@o7fOMD``pWcgZvGA{2x!_lw{f53_sD zq<~LYUx&L7{N~|wd(&RBYRDYdn#HI+P~S{N7z_}#L3zx#LunSSB@0tx6JSd8agECX zr^#hM#zr1nHcx7;VV@{s%X`ui%BXZ<3~dNqNn)&C%#&=CLVJ{ncT&May9vCpY{Z`N z2B{Um+``$|UWT1#8I7g;FRo>~d8Ku1 zNO27PFG{%HwJBJ*ie(-VJ6vrv#g_ZBnvw}WGSFiwc?@&bZ8a*foZFZv(0PBgOb%Ea z$(Dm(Eh}Y#h&sb&-hv)+r;CH{EkdU%@M?WUht%>3|;`3zESDsAlkJ=n{QIY>tPcz6C z1W9w`7+sJ=9G-j5(7lY{4?c8S`!f(eqs{J<>Pju36jwn_JA9U;*@6U;LdUTX)A``F zznr6R-#x$!V=*c%xJbDbcFPKqApRSfKXdqsB+TT~nU7-#SAYO6m(SQ}Tj^%2O!zEg z*Pu(YMUmx_}5+Q(IT#H@L~HP zeJSK@Gur8Q>*7py6>j9Lz-FJ+LP6H$B7TdvlgdKv+!uW~Y3N7a!e~^m{k8!{Xu6^znx|e3cngi`I#;>?^qckFx{qrj# z(~GN&*4i$c#}-_F^!XaXua}1ak(@6d?EjfBJn8?d?&(%$91(<#w#UrG+QuJ#wzoQp zY5ob4o3fATOHwwu2B~-;zrFj~E53og$M}|xA+OU|BGnFfC_4|wNohYlvvO&-vh4^X zr0Ro?W;eo=^yQZooGTXHF7HD$o`7E{%#t;t2eV`3QWZefKYyz+a)fefzuZjxbs97q zX4O+^j+*rYh@3sd5e@a_)y|UZ_uk)2XN@exz%tJp}4+$w<8!HJC%zu9cRM-snxo*k<3?;A~i01lXut8k9d z(|FKn4d^tB!RfB9@(Dp*+n5jtdBcEieqO}72<|lV{*rRgMeoJW?6jj;hBBbdBa7k<$E~Q+An7umN14w(a0^!A#;>2&nLKK@ukGfXgqxN6)}`N9cve zMH_Gq=j4tv`x^M9?x?(wplmt1#92GXyn%MX(%n53TLdr^23s=2MnpanqQ z)Uf!%;w*@6%VHX~4SWR=^z7T2QmpNvd!<((Yst{Pg0N&WKRlz{@$-%w~=MvTc| zsSWnjioM=Or{+p73b4yof{!Me@!<~YA9ftIBNl19D(5Ye<8{zpb_`c02*)yzx*|G4 z;&L>@D~nQkEY>TwYgfAv5|7lf|G3UqFyx~K&+0I{J(w!N8pd=zc9 z88Vumoa(vHR+ue?ufhLl>5CQO1}vqV=C9hEL4t|cYAB==T&su32vmM3q;zdBY|-26h?*S z9a^gte>=X)K3V}z)dZq5Dzi5CKX|A`SMHHx*BJ0ih*I8S-8#)uCW?_?rThej$AQZ&x56 zcu34#4DIn@RqM1EnzbnqnM|y6&J#MA*$y?*{(4&%gMWH^Jv2;#`5@Y9Ey5#ha_g(k zn0N);rDlKS*pp`d&08khVa%n=HavN{V-ox|tVpRxEK0Qzuk$m98${O-RFJSQ(`|-b z^2+OQG$137pq|cG;frRU;4+FRle2mpKDh3jy`L*DMQ5`Ac#~oE=yceM0e8AxJWSwc zk!%@oLaduo6$h7`iV_N~S6Sl_)v(A6yY_gSC$Tu6tS9P!BS>w;4mJ=gyn}D=6dmu(I#q0i%PJ?Bt4Qoyg4>wOhF7k!|wJwnexVsUfC!xP9KI@7l~Wb{MwIS z>@ysI(f8t0!xbT8rbjYs+{w5mYSDa2=;W%s>!(#T<%FhK_Z@QaKgr5C+BY|ssetQ8 z7h@I4-MgUToq3S3@NND>7lU*PHe;kuL2|NCnn4rkpB3L?`ikfQXHr%gQx$ax4Ycpd zE;ea%Iw}?a(b2ne-_`T^7nt!CMzaV289!!+NzvGmlllQ&Nwk3i3Kbn!YTeyi>ph%X zquw|YgI9NH{uYump+2ssr%5CyLC{ay@JlhYPEA>~Y?wiGmXF6h@?k2L#OWxV951(7 zyjpY?m7jkVO2UIJ$30GdV z?BZsl=S_{~Kk6Uoc0a`gXj7wei_Ff*|zWx8y6eYvh$3V;zDYTWRq%rcwzNVsiJgON{lBi_8B~ zp#%y$DOS(1>e10QP)s{Eq(dGKs9!4!8x{W4Y8OqeTQeql_t!Fk%362OM4LSfAiotS z1C3senSknA?Y3gbl2;wnj^XBK^*eYrX=Gz`P^Qh&xRa_~{2 z)+)d85M6^tk0k4Q5}V=z4*9xO*>wUP^S0wy;5~71=}amlnSt`cs&f#M$Cnq7B_OR2 zq5qY*zA@p4ValhKiJ!S!(sit9y7&ET^d(a96ReZ<9)|ZLp}-Q6NXTRj-&pS=eN~nC zU#+UopwScJV)@kYKhbo}oS$>#yx%Ck_v@m{??it!vr%zBjf3y;)G<8`2x$>P);PbN zBxG27PlUQ+TwbT%BwAZ&gA{ZR^%}vw7{NsIw9q@ygH?6cf4e=BbVXs`LL--ST1>_L z{4^gW9rvwxE^+-R5K~Q6-{{f>7+;`)sMo78mk!COcy)h!2DQVjpHYmWb~aYtV>80I z@o2qx{3DlE^eji-=KfQ~vtYmvu;vcYh;kDN3_e;S5fICtl4-|W_E0}euD0dKS}h(w zcaQu|wpY}RfcmrQX-464@VcAi+#&7&E;9x^w`z+RBE?~#NOS@s?Iz;Atwt2I}B5d*!aqxU)V zdFmF~#nOVa`3^T#Zz?~X-^J3brFhf6AV9;Z{Q}ppex|8T=Z40GQW$eXNULyE>}Y75 zM8Gj0aEFy2Mi6M4uTQ1bV+SDZkWvv@{@F*R{O>;y;%{z9d1rj`4VwOG5ZSH%O>P!C zc>QfCeE5ZZ%DhiM99cxvwWw>6qV8<8Ywn8%`n1Ztmq)X2z+ZG9qFkD0TkZAai0Nlr z^IUe57KcQ4*m0Baa(5?YL{g>lQ1FGfpd5_$=)F>K;})az3h%#u;VtbQUf^N1kmW-n zFYt2J3wU8_fvmT_4m*Bo>>R8=HX>XZDIIu9`I$S+%M0XMm{Ns1bOL;a-sL zTBjXji4;*90s0=KUae?CDad=|jCVDDwC^G0&>N^~8;?dcNx}x4)GPHH_z81!?%pRv z;~K4a{fjFh#t70DMRADVDNMoC{?K`-o2I2 z2Pm40jA)5WP5?D0uY*LP0Z?ZGvG=+9;VH49VSs2r<|K2b=@H`zb8xT(2m?;~xH@4q zuVuus;ol_5#Sl#*DtbB^_BCT}RCE!;PR`q(y>v03&E4}r-a~VMndXb$*C;cJ>CW4| zWxn16`|{rNoCu>|ZeWq`j}EQt%to@C!=A6#Y7xDxboZk33E95f(v)I|F7^Fltu<4} zG7F;eu|{+|p%08Q$E&{g{@z;`%lcG^H!IQI-505y{$c&N_BU37i6S$imG5MFRAmoH zHN~#KUd+2yZ`mo|K4q%_{60)I^Ues;sJURy=r-yd`<&!ag2>W?eRW!{x%4lKx6(rB zzUg!ut|uQFd!!_*m<)-}u^Dt(*z`_(fBp;kfwx0=g~&MvrX)4xl6wOUc7r#aPH!g;dd_k%i>ZUEDnZ zs@w*4P`m;UV0!7vVK)K|PfC_GZBRKwjn)UY^WXy?naZw>y&27v_hNqPn$fdR`TA{5 zAU__tki+h%ujs#Vm}P*c`Fy;sh?zv{a^e=&x4xb|&)fPO^RVnMc}CD=W;~3m`hbEt zRKn8oDgcZ{gca*+xED3@KmLvf27V~0@KS%r^$ltq1H%vGg1?Xhq>OA6HL)Sw3q=>C zuG#_LZl$LDuM3G}Dn}e#lPPq7s8dL4zCvi`$^)m<{H+Rt0IcQ#X}oCZE*RhFowC&TsM!eONW_b&4P45 z-D%w{{jCL50)@2iWa*Vb7_Q1YyXz4OSO7=>d&KtTRkr%do5gqnR3QF-D8#! zy~=~$X%C}q;4@P9YcFYz)w${v#o@v^q4Aq0a(We1Ol^Y|#@fZ%yVOFBt104_zpj}a zT-uMZ`OXN!4MLlzu1tw~oRpaQN!;)t+U0@hv3K0KU~$^*X|)MKc2NWDyY3a@yKYHn z222bug(-Zgu`>-43hNJkV_N|9)>FkrA4Gu0i8iqZLKoK>@Z2cna*fCaU$)t6*QRJN ztd6_+I-lr_avF3H@2r8l|~Rl-r6+E&_Y&K-4F#7WTj9 zVT!=qqq-jaRfb6*4k`-D2EclwiBlhX(6eF>KeIT{6$go9o?b-Ui$js=nH(EixqC_H zMN9SaYJK`sezSZKb=|oC0-Ulr3%ZXhE?kv{kx`iVqiIR3VLfub)Z{m|lBD@G8$A{~ z7qfu>Fcf@uv*AiA2DGr z(r;+r{dIrZPRG%D?|yZKXv(eGmzS2vYAD0o^}TOB_o`z>=1_qvKyl1X_%#$GvdmJu zlKB4d%^&7f)O)1dicZ%Am!T!tb^1nkzE&4s)gOZ7K<|=O$xW#_$Pf#QPD-P(!Ti92 z2J2C;JgLVZxzA^gM)ef}O?S7Y&I)~l`lp3%rX}eUe{F3qwvM3)CePZ z?ar!^KSC~6q>h~qPJ*{Wpq?Eqe4@pB%#m}#_nPEi*-+gKZ++V390)qV>f;8Me;ffS zRt4$~qmBRI0^z3d0S=bVLO~AjCxEsT@elwSr7A}d#F!Om!VPyW@tvrWZ^Vi2Xo6N= ztS+axS73Q3W&TsH7AT8W{?SA`HuOL@Od{BLwcVa*ZPE~V+Yf|;$Y6X1{~fj9jKdNi zisgK>L4ny50^A5|p*(^7SWHGcq}CHM*dqIbDEEOO5zNnktv}Qp(HXd(^Yb%OpJ14m zfn=vANzepf0ekKfW>4u0$wrxOnE+Q{A&0s#@jxhK=mL5=6_G)cdfM~LZ5bSfM#mfB ze_rX0m%f)!FAKC_@{MIME|KBCSn8C=4tOI$)h=F*ZRhdqzhT%lwDh zhd=OOYDd(QNb$o!>b7VnguYM{a`2IyF+CUZ(-GJggN3)AyQZD;`>R7s3Lb=ig2xrQ z6Iog?u3V_!O?ZLbrVp;JDX>B%2*A{fDj&tYDI*;oDjc^SWtw6W=~}fGfT?kh?}Esr zA_%gq;DX%I{9v-VDAI)h@SCS}$3kzz-#F*e5Cwc2tdXv*>u9v_O~fPDzq;Dk@E3S+ zQ}hLahWio}GV4Y%hFVzWx~U zZA2qfYtb>0hpnI&`sLacaUQ6eK_eQ_gYXvt>}8?*9BpN^e)cEdG*Cc#86GyBv%Mcb zb+8)zn|nZNB-$h8@<}^FB@lX?tBNU^O|C&Fv zGzlFBO|QZruU&BUN=;+rUe0wXqaJ18kMc4+%vojZw4N`#(ujvv14NX)H$?c4D}{Px z7qYwCwhQFviuFJ>YM1TqQ#7Ps5ri?g;k%4zh{hmNf~}nx*&OyyzUBJWzw{)~s%VFn zdA>JSW((-}%P#ldtT zoo}m?n{nhOG2c;tS_lbO;Ni_a5mRU9!M}h7{Vl1`{>cWZa*eUkX_;2{NcH4L-dD&e z4{%vEPa0&pCCY6xcQ?atO{U0gV&jy$3<#s+Oqkm!%j}JGe;*?b(ABCrXhJbxzc`M* zLX$oYsxmlJVhi;|&g80Wo~&L7{cn+mf2HF{4;Mmud3{n^{NXRkvB8YNmH71ogIj}y zA16fl?77VTNi`B(OaF=GRAm-Mh5|wSY-<6HnXCXZ-Y~x@z6igmw&3+QbHM_C0oQ55 zFa!BTub?4puTcN#)XS>S;gE9T0W-j_JrW=h$-fRPTcRHZTojreA`@Jw_iBnSCZ^nz|73@&)l0PFyHt?bKG2hPAkKSZyMxH^&EQ~ zjwsk1za;I>^pHmf+6g7O@X|Ou8xE=1S-eu5s81X2fAz*BbpB*Zr1z5!bD)k z%tYW@4AwN%b$i135SjucPA{Ti1I-vLL2Z%4=W85lYk<>;s^mUHp*9LSJq^3_PDDIx z4Jk9?mN4lp0K__Gjz(AvEbt`>(4Eu#rxDGFs6xX0`hj^Iz;D^!%Dit7WE4tqjxgLY z?od8e2DYa?g!iq#%~Kpow4^ldn!&ka`O@WWL%9oQ3ahlm8u0a}5FQAElvlH!nXC># z4jzJ;yjh z{V!NoSct%0WN9x%uz>qy9$`W~6l2mcuak1Fen4`_H_@@?qu}e)<)<-{tawRRg39dv z9_bifHh)T84Xy2Bb%bAp9y3o0W-+dYz>~c*j2?Uq9J{<3uPmHr=xpo2j!pOhmD?El0dU4GD@jfQ&X+N#je9B_X z=P-`;`sFgVqEq9DZ2PuK&jf#UoFB$3b zm|l1pR)U*W=oSWeky^pj2>>I$b@Rz^f1Ug4G_`i5-RB{nlpkN#>^XK&8!O!Y4=s%bV?Fr9}orzLtgwBDI$=6!>aw)=yf(UHt#)+hT1 zo&rS#$sK;jjd8C}s2kl$TA)Kq?@pPT4<%6rxg!!wh|tC^e`yCv=iQGyh>X&Q?D{i@ z_(|k1xzH@;1u_hMpx^B8`a7eEt=fE71d$2b_i4DF!_)9n^U({bP71Z6_YnV{CBe~g z*4a2MUH%eo<`|G%cvnnu;J?VK7pPEB%$rpL@l*qA5Q_?I!H=!ISTxyBCP?|l{As#g zvPtj9AQTMMU35$`OOH51?WB)uj9MTHvR>b&{(e~F;8e^lqNY6|erG;3eRvHsSMA4x zKTuzA#qhFpw==BHW?P%V2u@)Y^s8?B%+<=5vbRa-+*y#-Om;lm#zTXvL0`FKQS;38 zLoTCB^1xXi(RJ+f@kbZiF z%@Ow^KcHe!v`iB`CH^z`=zW7sby%muQH_>tJCRW9k{#hH*C8fSgDyFnlhcdG(dMX5 za2kH&t}Gq)M7cIad>GZPngL1$(4&}^GtR{Dz`8Q0ytKUfVMn;L{0fEr)sSMB{xk$` z^>qDN!=#n2!6UMnD2JZJ0iP)!Nbf50?)t4AE{?AwIRA}ycAVF`pZQI;`Uwm@D1upI);w ze?}a~SPWfQZ#2KAdbb<<(TO;Ruf{kQ2LFy~x!*c2?zT^*b4W#71y;9JQhMnHs4!nt zsFRQ6%vLdb;iMn@3rnIM3Y(u5Qm{KUfy~Yi$C?vSM+&w^6w!D$D%d9;5Btk=`{%w5 z9?9$2utLjen=nN!Cgmg zVi)x89$>Gi^hM<7Kj*fC;G4&loZKUEkGZv!C8@(VEOtY)IX1TCrkjerI=1f-D*u@T zJ*%I6;5-)ojOpQoW$@bHuOFd%{S7!WGBhUqY}u4+!>3D9(6m2%^acAW57z0~SQ?Qj zIf(H-$J|%ndae1p_JO}NBop$Gt zDKlo&EZi_b+!`;)+xbm*bj10;x7vL<&5v0VcUl#J8L!%Zq#2IKhOvsgb*F`zDK?`z z@rHu2T-mHBu3CS8TA(w+ahrX|)sxgniNBD4BLw?-Cb^O@$Z zM-^XMcRr>#h#3>WkSL<7%6Y%2m?YCVxMf{Qlq0(m*1roA>3TTaXKX?$*Yvm0eYA&s zU;D1YhDPEi&VeJ=w(4Ql+b7xrCAuofG%>@o%j}iadmQW}8*8rAvy%eqqP+M6Ks;7? zDPqsKR5~dS`v8%-?E}Co<;oxg?mLoPDlBeyQ5mjOOSjplI6RAQ*VluZVXyae?^WAt zdvL=vM8q;_fNRb*m{a31W$!tibGr>@6{A&X;vEyhtSOb>mbaErBHK&oD^0SG~FDT%#k6|Q>`#=moV&HGp~2KsZ%;wqU8nP z1Lw3qyA{Olx~SBB7%vUXH!)HseYI^!qS`Ej!GM- zVj-;McVq7fufB2nV0@Se^wl_=Odf(I*m$ENiz>WkG1VWm0K=uc75OIQtJ7x!E4Vk7 zeqvgj1e_#b-f7G)?Gps7db}P5k7YM`pA}`u^^abCJj1kwxxjMrvGc6MVO@1!B4j>u!FUn5;{Cd;s@*$NxkfX9OTX7* zBL3rG^YOnb!4*^9LR51ySeOfsmSC(@6HkANZm3C7R9wYP!V$k(28JqR0QF?YA4m(R z(HB#@KNk%Ru^qjuVQF7hrGU9`)Ri}`WtWwG@g-MW zrBt-y;KdXPvd7a@+vVzgp{4Xe$BGHYIuK!bNNrE(bE;Bm2Xbbv;W@X(Oe@APk7jf! z7f-yBPD5n4DxmkJf3JfMruGQU?QoeLh{)zHN!xITB-H0r^#W&pYo^nG#=ctXfT30! zO3t$Ms3~^!6db=GZaw>hKja~9_moKlZ7VGtY9~iiJIUh)DTCT1AyE~70U>7ueLiN} z>m~lz;rh3|PCl1=l~(Vqf0N?l@C5=ki}9JC&41d=$CXJ2HwbmqgeC`C0XEpJYt38) zJ+vQk0I8OmsyHX7zuI_t%Y73NJ-;r{V6o*Gh}|dTSMa}CyAWje$21wdzq%X3K)%@v zr0U_hByBl5hXpdRZui>h;0*S$JLn#M@ALX1l2+d>8sOCW|7gDh0y1bn;sc2QPl_f1 zN)$eKg1xz_JzH?^4ajYvx|C$Y#j(`LmWVm;*s=S^r6lXP>_%jDpj Date: Wed, 13 Mar 2024 16:15:53 +0800 Subject: [PATCH 56/58] docs: add farm docs --- docs/guide/index.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/guide/index.md b/docs/guide/index.md index cc401753..ad675c45 100644 --- a/docs/guide/index.md +++ b/docs/guide/index.md @@ -334,6 +334,9 @@ export const unpluginFactory: UnpluginFactory = (options, m // Or you can completely replace the setup logic // setup?: EsbuildPlugin.setup, }, + farm: { + // Farm plugin + } } } From 0e28c78a6b32136ce00ca330f16ac1a55a632eee Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Wed, 13 Mar 2024 16:23:14 +0800 Subject: [PATCH 57/58] docs: add farm docs --- docs/index.md | 12 ++++++++++++ docs/public/features/rolldown.svg | 13 +++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 docs/public/features/rolldown.svg diff --git a/docs/index.md b/docs/index.md index 5854a0f6..9d0d7a6d 100644 --- a/docs/index.md +++ b/docs/index.md @@ -57,4 +57,16 @@ features: link: https://farm-fe.github.io/ icon: src: /features/farm.png + + - title: Rolldown + details: Fast Rust bundler for JavaScript with Rollup-compatible API + link: https://rolldown.rs/ + icon: + src: /features/rolldown.svg + + - title: More + details: More supported bundlers... + link: /guide/#supported-hooks + icon: + src: /features/more.svg --- diff --git a/docs/public/features/rolldown.svg b/docs/public/features/rolldown.svg new file mode 100644 index 00000000..f1fdfa40 --- /dev/null +++ b/docs/public/features/rolldown.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + From dcb30bac7294344229618c03d83c05e4606ad19a Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Wed, 13 Mar 2024 09:34:17 +0100 Subject: [PATCH 58/58] chore: update imports --- src/farm/context.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/farm/context.ts b/src/farm/context.ts index 5eec49d1..b1cbfe72 100644 --- a/src/farm/context.ts +++ b/src/farm/context.ts @@ -2,7 +2,7 @@ import { Buffer } from 'buffer' import { extname } from 'path' import { Parser } from 'acorn' import type { CompilationContext } from '@farmfe/core' -import type { UnpluginBuildContext, UnpluginContext } from '..' +import type { UnpluginBuildContext, UnpluginContext } from '../types' export function createFarmContext( context: CompilationContext,