bundlers.yml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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. - run: npx rollup --version
  85. - name: Create Rollup config file
  86. run: >-
  87. echo '
  88. import cjs from "@rollup/plugin-commonjs";
  89. import { nodeResolve } from "@rollup/plugin-node-resolve";
  90. export default {
  91. input: "./index.mjs",
  92. output: {
  93. file: "/dev/null",
  94. },
  95. plugins: [
  96. cjs(),
  97. nodeResolve({ browser: true, exportConditions: ["browser"] }),
  98. ],
  99. };' > rollup.config.mjs
  100. - name: Bundle
  101. run: npx rollup -c
  102. webpack:
  103. needs: isolate_uppy
  104. name: Webpack
  105. runs-on: ubuntu-latest
  106. strategy:
  107. matrix:
  108. bundler-version: [latest]
  109. steps:
  110. - name: Download uppy tarball
  111. uses: actions/download-artifact@v3
  112. with:
  113. path: /tmp/
  114. - name: Extract tarball
  115. run: tar -xzf /tmp/packages/uppy-${{ github.sha }}.tgz --strip-components 1
  116. - name: Add Webpack as a dev dependency
  117. run: npm i --save-dev webpack-cli webpack@${{matrix.bundler-version}}
  118. - run: npx webpack --version
  119. - name: Create Webpack config file
  120. run: echo 'module.exports={mode:"production",target:"web",entry:"./index.mjs"}' > webpack.config.js
  121. - name: Bundle
  122. run: npx webpack
  123. parcel:
  124. needs: isolate_uppy
  125. name: Parcel
  126. runs-on: ubuntu-latest
  127. strategy:
  128. matrix:
  129. bundler-version: [latest]
  130. steps:
  131. - name: Download uppy tarball
  132. uses: actions/download-artifact@v3
  133. with:
  134. path: /tmp/
  135. - name: Extract tarball
  136. run: tar -xzf /tmp/packages/uppy-${{ github.sha }}.tgz --strip-components 1
  137. - name: Fix package.json to work with Parcel
  138. run: |
  139. node <<'EOF'
  140. const pkg = require('./package.json');
  141. delete pkg.main
  142. delete pkg.types
  143. pkg.module = 'output.mjs'
  144. require('node:fs').writeFileSync('./package.json', JSON.stringify(pkg));
  145. EOF
  146. - name: Add Parcel as a dev dependency
  147. run: npm i --save-dev parcel@${{matrix.bundler-version}}
  148. - run: npx parcel --version
  149. - name: Bundle
  150. run: npx parcel build index.mjs
  151. vite:
  152. needs: isolate_uppy
  153. name: Vite
  154. runs-on: ubuntu-latest
  155. strategy:
  156. matrix:
  157. bundler-version: [latest]
  158. steps:
  159. - name: Download uppy tarball
  160. uses: actions/download-artifact@v3
  161. with:
  162. path: /tmp/
  163. - name: Extract tarball
  164. run: tar -xzf /tmp/packages/uppy-${{ github.sha }}.tgz --strip-components 1
  165. - name: Add Vite as a dev dependency
  166. run: npm i --save-dev vite@${{matrix.bundler-version}}
  167. - run: npx vite --version
  168. - name: Create index.html
  169. run: echo '<!doctype html><html><head><script type="module" src="./index.mjs"></script></head></html>' > index.html
  170. - name: Bundle
  171. run: npx vite build
  172. esbuild:
  173. needs: isolate_uppy
  174. name: ESBuild
  175. runs-on: ubuntu-latest
  176. strategy:
  177. matrix:
  178. bundler-version: [latest]
  179. steps:
  180. - name: Download uppy tarball
  181. uses: actions/download-artifact@v3
  182. with:
  183. path: /tmp/
  184. - name: Extract tarball
  185. run: tar -xzf /tmp/packages/uppy-${{ github.sha }}.tgz --strip-components 1
  186. - name: Add ESBuild as a dev dependency
  187. run: npm i --save-dev esbuild@${{matrix.bundler-version}}
  188. - run: npx esbuild --version
  189. - name: Bundle
  190. run: npx esbuild index.mjs --bundle --outfile=/dev/null
  191. # Browserify: doesn't support ESM.