bundlers.yml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. name: Test different bundlers with Uppy
  2. on:
  3. push:
  4. branches: [main, 4.x]
  5. pull_request:
  6. # We want all branches so we configure types to be the GH default again
  7. types: [opened, synchronize, reopened]
  8. paths-ignore:
  9. - '**.md'
  10. - '**.d.ts'
  11. - 'examples/**'
  12. - 'private/**'
  13. - 'website/**'
  14. - '.github/**'
  15. - '!.github/workflows/bundlers.yml'
  16. env:
  17. YARN_ENABLE_GLOBAL_CACHE: false
  18. jobs:
  19. isolate_uppy:
  20. name: Isolate Uppy packages
  21. runs-on: ubuntu-latest
  22. steps:
  23. - name: Checkout sources
  24. uses: actions/checkout@v4
  25. - name: Get yarn cache directory path
  26. id: yarn-cache-dir-path
  27. run:
  28. echo "dir=$(corepack yarn config get cacheFolder)" >> $GITHUB_OUTPUT
  29. - uses: actions/cache@v4
  30. id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
  31. with:
  32. path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
  33. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  34. restore-keys: |
  35. ${{ runner.os }}-yarn-
  36. - name: Install Node.js
  37. uses: actions/setup-node@v4
  38. with:
  39. node-version: lts/*
  40. - name: Install dependencies
  41. run:
  42. corepack yarn workspaces focus $(corepack yarn workspaces list --json
  43. | jq -r .name | awk '/^@uppy-example/{ next } { if ($0!="uppy.io")
  44. print $0 }')
  45. env:
  46. # https://docs.cypress.io/guides/references/advanced-installation#Skipping-installation
  47. CYPRESS_INSTALL_BINARY: 0
  48. - name: Build lib
  49. run: corepack yarn run build:lib
  50. - name: Make Uppy bundle use local version
  51. run: |
  52. node <<'EOF'
  53. const pkg = require('./packages/uppy/package.json');
  54. pkg.overrides = {};
  55. (async () => {
  56. for await (const { name } of await require('node:fs/promises').opendir('./packages/@uppy/')) {
  57. pkg.overrides["@uppy/" + name] = `/tmp/packages/@uppy-${name}-${{ github.sha }}.tgz`;
  58. }
  59. for(const key of Object.keys(pkg.dependencies)) {
  60. if (key in pkg.overrides) {
  61. pkg.dependencies[key] = pkg.overrides[key];
  62. }
  63. }
  64. require('node:fs').writeFileSync('./packages/uppy/package.json', JSON.stringify(pkg));
  65. })();
  66. EOF
  67. - name: Eject public packages from repo
  68. run:
  69. mkdir /tmp/artifacts && corepack yarn workspaces foreach --all
  70. --no-private pack --install-if-needed -o /tmp/artifacts/%s-${{
  71. github.sha }}.tgz
  72. - name: Upload artifact
  73. if: success()
  74. uses: actions/upload-artifact@v4
  75. with:
  76. name: packages
  77. path: /tmp/artifacts/
  78. rollup:
  79. needs: isolate_uppy
  80. name: Rollup
  81. runs-on: ubuntu-latest
  82. strategy:
  83. matrix:
  84. bundler-version: [latest]
  85. steps:
  86. - name: Download uppy tarball
  87. uses: actions/download-artifact@v4
  88. with:
  89. path: /tmp/
  90. - name: Extract tarball
  91. run:
  92. tar -xzf /tmp/packages/uppy-${{ github.sha }}.tgz --strip-components 1
  93. - name: Add Rollup as a dev dependency
  94. run: >-
  95. npm i --save-dev @rollup/plugin-commonjs @rollup/plugin-node-resolve
  96. rollup@${{matrix.bundler-version}}
  97. - run: npx rollup --version
  98. - name: Create Rollup config file
  99. run: >-
  100. echo ' import cjs from "@rollup/plugin-commonjs"; import { nodeResolve
  101. } from "@rollup/plugin-node-resolve";
  102. export default {
  103. input: "./index.mjs",
  104. output: {
  105. file: "/dev/null",
  106. },
  107. plugins: [
  108. cjs(),
  109. nodeResolve({ browser: true, exportConditions: ["browser"] }),
  110. ],
  111. };' > rollup.config.mjs
  112. - name: Bundle
  113. run: npx rollup -c
  114. webpack:
  115. needs: isolate_uppy
  116. name: Webpack
  117. runs-on: ubuntu-latest
  118. strategy:
  119. matrix:
  120. bundler-version: [latest]
  121. steps:
  122. - name: Download uppy tarball
  123. uses: actions/download-artifact@v4
  124. with:
  125. path: /tmp/
  126. - name: Extract tarball
  127. run:
  128. tar -xzf /tmp/packages/uppy-${{ github.sha }}.tgz --strip-components 1
  129. - name: Add Webpack as a dev dependency
  130. run: npm i --save-dev webpack-cli webpack@${{matrix.bundler-version}}
  131. - run: npx webpack --version
  132. - name: Create Webpack config file
  133. run:
  134. echo
  135. 'module.exports={mode:"production",target:"web",entry:"./index.mjs"}'
  136. > webpack.config.js
  137. - name: Bundle
  138. run: npx webpack
  139. parcel:
  140. needs: isolate_uppy
  141. name: Parcel
  142. runs-on: ubuntu-latest
  143. strategy:
  144. matrix:
  145. bundler-version: [latest]
  146. steps:
  147. - name: Download uppy tarball
  148. uses: actions/download-artifact@v4
  149. with:
  150. path: /tmp/
  151. - name: Extract tarball
  152. run:
  153. tar -xzf /tmp/packages/uppy-${{ github.sha }}.tgz --strip-components 1
  154. - name: Fix package.json to work with Parcel
  155. run: |
  156. node <<'EOF'
  157. const pkg = require('./package.json');
  158. delete pkg.main
  159. delete pkg.types
  160. pkg.module = 'output.mjs'
  161. require('node:fs').writeFileSync('./package.json', JSON.stringify(pkg));
  162. EOF
  163. - name: Add Parcel as a dev dependency
  164. run: npm i --save-dev parcel@${{matrix.bundler-version}}
  165. - run: npx parcel --version
  166. - name: Bundle
  167. run: npx parcel build index.mjs
  168. vite:
  169. needs: isolate_uppy
  170. name: Vite
  171. runs-on: ubuntu-latest
  172. strategy:
  173. matrix:
  174. bundler-version: [latest]
  175. steps:
  176. - name: Download uppy tarball
  177. uses: actions/download-artifact@v4
  178. with:
  179. path: /tmp/
  180. - name: Extract tarball
  181. run:
  182. tar -xzf /tmp/packages/uppy-${{ github.sha }}.tgz --strip-components 1
  183. - name: Add Vite as a dev dependency
  184. run: npm i --save-dev vite@${{matrix.bundler-version}}
  185. - run: npx vite --version
  186. - name: Create index.html
  187. run:
  188. echo '<!doctype html><html><head><script type="module"
  189. src="./index.mjs"></script></head></html>' > index.html
  190. - name: Bundle
  191. run: npx vite build
  192. esbuild:
  193. needs: isolate_uppy
  194. name: ESBuild
  195. runs-on: ubuntu-latest
  196. strategy:
  197. matrix:
  198. bundler-version: [latest]
  199. steps:
  200. - name: Download uppy tarball
  201. uses: actions/download-artifact@v4
  202. with:
  203. path: /tmp/
  204. - name: Extract tarball
  205. run:
  206. tar -xzf /tmp/packages/uppy-${{ github.sha }}.tgz --strip-components 1
  207. - name: Add ESBuild as a dev dependency
  208. run: npm i --save-dev esbuild@${{matrix.bundler-version}}
  209. - run: npx esbuild --version
  210. - name: Bundle
  211. run: npx esbuild index.mjs --bundle --outfile=/dev/null
  212. # Browserify: doesn't support ESM.