bundlers.yml 6.9 KB

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