bundlers.yml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. pkg.overrides = {};
  51. (async () => {
  52. for await (const { name } of await require('node:fs/promises').opendir('./packages/@uppy/')) {
  53. pkg.overrides["@uppy/" + name] = `/tmp/packages/@uppy-${name}-${{ github.sha }}.tgz`;
  54. }
  55. for(const key of Object.keys(pkg.dependencies)) {
  56. if (key in pkg.overrides) {
  57. pkg.dependencies[key] = pkg.overrides[key];
  58. }
  59. }
  60. require('node:fs').writeFileSync('./packages/uppy/package.json', JSON.stringify(pkg));
  61. })();
  62. EOF
  63. - name: Eject public packages from repo
  64. run: mkdir /tmp/artifacts && corepack yarn workspaces foreach --no-private pack --install-if-needed -o /tmp/artifacts/%s-${{ github.sha }}.tgz
  65. - name: Upload artifact
  66. if: success()
  67. uses: actions/upload-artifact@v3
  68. with:
  69. name: packages
  70. path: /tmp/artifacts/
  71. rollup:
  72. needs: isolate_uppy
  73. name: Rollup
  74. runs-on: ubuntu-latest
  75. strategy:
  76. matrix:
  77. bundler-version: [latest]
  78. steps:
  79. - name: Download uppy tarball
  80. uses: actions/download-artifact@v3
  81. with:
  82. path: /tmp/
  83. - name: Extract tarball
  84. run: tar -xzf /tmp/packages/uppy-${{ github.sha }}.tgz --strip-components 1
  85. - name: Add Rollup as a dev dependency
  86. run: >-
  87. npm i --save-dev
  88. @rollup/plugin-commonjs @rollup/plugin-node-resolve
  89. rollup@${{matrix.bundler-version}}
  90. - run: npx rollup --version
  91. - name: Create Rollup config file
  92. run: >-
  93. echo '
  94. import cjs from "@rollup/plugin-commonjs";
  95. import { nodeResolve } from "@rollup/plugin-node-resolve";
  96. export default {
  97. input: "./index.mjs",
  98. output: {
  99. file: "/dev/null",
  100. },
  101. plugins: [
  102. cjs(),
  103. nodeResolve({ browser: true, exportConditions: ["browser"] }),
  104. ],
  105. };' > rollup.config.mjs
  106. - name: Bundle
  107. run: npx rollup -c
  108. webpack:
  109. needs: isolate_uppy
  110. name: Webpack
  111. runs-on: ubuntu-latest
  112. strategy:
  113. matrix:
  114. bundler-version: [latest]
  115. steps:
  116. - name: Download uppy tarball
  117. uses: actions/download-artifact@v3
  118. with:
  119. path: /tmp/
  120. - name: Extract tarball
  121. run: tar -xzf /tmp/packages/uppy-${{ github.sha }}.tgz --strip-components 1
  122. - name: Add Webpack as a dev dependency
  123. run: npm i --save-dev webpack-cli webpack@${{matrix.bundler-version}}
  124. - run: npx webpack --version
  125. - name: Create Webpack config file
  126. run: echo 'module.exports={mode:"production",target:"web",entry:"./index.mjs"}' > webpack.config.js
  127. - name: Bundle
  128. run: npx webpack
  129. parcel:
  130. needs: isolate_uppy
  131. name: Parcel
  132. runs-on: ubuntu-latest
  133. strategy:
  134. matrix:
  135. bundler-version: [latest]
  136. steps:
  137. - name: Download uppy tarball
  138. uses: actions/download-artifact@v3
  139. with:
  140. path: /tmp/
  141. - name: Extract tarball
  142. run: tar -xzf /tmp/packages/uppy-${{ github.sha }}.tgz --strip-components 1
  143. - name: Fix package.json to work with Parcel
  144. run: |
  145. node <<'EOF'
  146. const pkg = require('./package.json');
  147. delete pkg.main
  148. delete pkg.types
  149. pkg.module = 'output.mjs'
  150. require('node:fs').writeFileSync('./package.json', JSON.stringify(pkg));
  151. EOF
  152. - name: Add Parcel as a dev dependency
  153. run: npm i --save-dev parcel@${{matrix.bundler-version}}
  154. - run: npx parcel --version
  155. - name: Bundle
  156. run: npx parcel build index.mjs
  157. vite:
  158. needs: isolate_uppy
  159. name: Vite
  160. runs-on: ubuntu-latest
  161. strategy:
  162. matrix:
  163. bundler-version: [latest]
  164. steps:
  165. - name: Download uppy tarball
  166. uses: actions/download-artifact@v3
  167. with:
  168. path: /tmp/
  169. - name: Extract tarball
  170. run: tar -xzf /tmp/packages/uppy-${{ github.sha }}.tgz --strip-components 1
  171. - name: Add Vite as a dev dependency
  172. run: npm i --save-dev vite@${{matrix.bundler-version}}
  173. - run: npx vite --version
  174. - name: Create index.html
  175. run: echo '<!doctype html><html><head><script type="module" src="./index.mjs"></script></head></html>' > index.html
  176. - name: Bundle
  177. run: npx vite build
  178. esbuild:
  179. needs: isolate_uppy
  180. name: ESBuild
  181. runs-on: ubuntu-latest
  182. strategy:
  183. matrix:
  184. bundler-version: [latest]
  185. steps:
  186. - name: Download uppy tarball
  187. uses: actions/download-artifact@v3
  188. with:
  189. path: /tmp/
  190. - name: Extract tarball
  191. run: tar -xzf /tmp/packages/uppy-${{ github.sha }}.tgz --strip-components 1
  192. - name: Add ESBuild as a dev dependency
  193. run: npm i --save-dev esbuild@${{matrix.bundler-version}}
  194. - run: npx esbuild --version
  195. - name: Bundle
  196. run: npx esbuild index.mjs --bundle --outfile=/dev/null
  197. # Browserify: doesn't support ESM.