bundlers.yml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. name: Test different bundlers with Uppy
  2. on:
  3. push:
  4. branches: [ main ]
  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@v3
  25. - name: Get yarn cache directory path
  26. id: yarn-cache-dir-path
  27. run: echo "dir=$(corepack yarn config get cacheFolder)" >> $GITHUB_OUTPUT
  28. - uses: actions/cache@v3
  29. id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
  30. with:
  31. path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
  32. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  33. restore-keys: |
  34. ${{ runner.os }}-yarn-
  35. - name: Install Node.js
  36. uses: actions/setup-node@v3
  37. with:
  38. node-version: lts/*
  39. - name: Install dependencies
  40. run: corepack yarn workspaces focus $(corepack yarn workspaces list --json | jq -r .name | awk '/^@uppy-example/{ next } { if ($0!="uppy.io") print $0 }')
  41. env:
  42. # https://docs.cypress.io/guides/references/advanced-installation#Skipping-installation
  43. CYPRESS_INSTALL_BINARY: 0
  44. - name: Build lib
  45. run: corepack yarn run build:lib
  46. - name: Make Uppy bundle use local version
  47. run: |
  48. node <<'EOF'
  49. const pkg = require('./packages/uppy/package.json');
  50. for(const key of Object.keys(pkg.dependencies)) {
  51. if (key.startsWith('@uppy/')) {
  52. pkg.dependencies[key] = `/tmp/packages/${key.replace('/', '-')}-${{ github.sha }}.tgz`;
  53. }
  54. }
  55. require('node:fs').writeFileSync('./packages/uppy/package.json', JSON.stringify(pkg));
  56. EOF
  57. - name: Eject public packages from repo
  58. run: mkdir /tmp/artifacts && corepack yarn workspaces foreach --no-private pack --install-if-needed -o /tmp/artifacts/%s-${{ github.sha }}.tgz
  59. - name: Upload artifact
  60. if: success()
  61. uses: actions/upload-artifact@v3
  62. with:
  63. name: packages
  64. path: /tmp/artifacts/
  65. rollup:
  66. needs: isolate_uppy
  67. name: Rollup
  68. runs-on: ubuntu-latest
  69. strategy:
  70. matrix:
  71. bundler-version: [latest]
  72. steps:
  73. - name: Download uppy tarball
  74. uses: actions/download-artifact@v3
  75. with:
  76. path: /tmp/
  77. - name: Extract tarball
  78. run: tar -xzf /tmp/packages/uppy-${{ github.sha }}.tgz --strip-components 1
  79. - name: Add Rollup as a dev dependency
  80. run: >-
  81. npm i --save-dev
  82. @rollup/plugin-commonjs @rollup/plugin-node-resolve
  83. rollup@${{matrix.bundler-version}}
  84. - name: Create Rollup config file
  85. run: >-
  86. echo '
  87. import cjs from "@rollup/plugin-commonjs";
  88. import { nodeResolve } from "@rollup/plugin-node-resolve";
  89. export default {
  90. input: "./index.mjs",
  91. output: {
  92. file: "/dev/null",
  93. },
  94. plugins: [
  95. cjs(),
  96. nodeResolve({ browser: true, exportConditions: ["browser"] }),
  97. ],
  98. };' > rollup.config.mjs
  99. - name: Bundle
  100. run: npx rollup -c
  101. webpack:
  102. needs: isolate_uppy
  103. name: Webpack
  104. runs-on: ubuntu-latest
  105. strategy:
  106. matrix:
  107. bundler-version: [latest]
  108. steps:
  109. - name: Download uppy tarball
  110. uses: actions/download-artifact@v3
  111. with:
  112. path: /tmp/
  113. - name: Extract tarball
  114. run: tar -xzf /tmp/packages/uppy-${{ github.sha }}.tgz --strip-components 1
  115. - name: Add Webpack as a dev dependency
  116. run: npm i --save-dev webpack-cli webpack@${{matrix.bundler-version}}
  117. - name: Create Webpack config file
  118. run: echo 'module.exports={mode:"production",target:"web",entry:"./index.mjs"}' > webpack.config.js
  119. - name: Bundle
  120. run: npx webpack
  121. parcel:
  122. needs: isolate_uppy
  123. name: Parcel
  124. runs-on: ubuntu-latest
  125. strategy:
  126. matrix:
  127. bundler-version: [latest]
  128. steps:
  129. - name: Download uppy tarball
  130. uses: actions/download-artifact@v3
  131. with:
  132. path: /tmp/
  133. - name: Extract tarball
  134. run: tar -xzf /tmp/packages/uppy-${{ github.sha }}.tgz --strip-components 1
  135. - name: Fix package.json to work with Parcel
  136. run: |
  137. node <<'EOF'
  138. const pkg = require('./package.json');
  139. delete pkg.main
  140. delete pkg.types
  141. pkg.module = 'output.mjs'
  142. require('node:fs').writeFileSync('./package.json', JSON.stringify(pkg));
  143. EOF
  144. - name: Add Parcel as a dev dependency
  145. run: npm i --save-dev parcel@${{matrix.bundler-version}}
  146. - name: Bundle
  147. run: npx parcel build index.mjs
  148. vite:
  149. needs: isolate_uppy
  150. name: Vite
  151. runs-on: ubuntu-latest
  152. strategy:
  153. matrix:
  154. bundler-version: [latest]
  155. steps:
  156. - name: Download uppy tarball
  157. uses: actions/download-artifact@v3
  158. with:
  159. path: /tmp/
  160. - name: Extract tarball
  161. run: tar -xzf /tmp/packages/uppy-${{ github.sha }}.tgz --strip-components 1
  162. - name: Add Vite as a dev dependency
  163. run: npm i --save-dev vite@${{matrix.bundler-version}}
  164. - name: Create index.html
  165. run: echo '<!doctype html><html><head><script type="module" src="./index.mjs"></script></head></html>' > index.html
  166. - name: Bundle
  167. run: npx vite build
  168. esbuild:
  169. needs: isolate_uppy
  170. name: ESBuild
  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@v3
  178. with:
  179. path: /tmp/
  180. - name: Extract tarball
  181. run: tar -xzf /tmp/packages/uppy-${{ github.sha }}.tgz --strip-components 1
  182. - name: Add ESBuild as a dev dependency
  183. run: npm i --save-dev esbuild@${{matrix.bundler-version}}
  184. - name: Bundle
  185. run: npx esbuild index.mjs --bundle --outfile=/dev/null
  186. # Browserify: doesn't support ESM.