bundlers.yml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. jobs:
  17. isolate_uppy:
  18. name: Isolate Uppy package
  19. runs-on: ubuntu-latest
  20. steps:
  21. - name: Checkout sources
  22. uses: actions/checkout@v3
  23. - name: Get yarn cache directory path
  24. id: yarn-cache-dir-path
  25. run: echo "dir=$(corepack yarn config get cacheFolder)" >> $GITHUB_OUTPUT
  26. - uses: actions/cache@v3
  27. id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
  28. with:
  29. path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
  30. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  31. restore-keys: |
  32. ${{ runner.os }}-yarn-
  33. - name: Install Node.js
  34. uses: actions/setup-node@v3
  35. with:
  36. node-version: lts/*
  37. - name: Install dependencies
  38. run: corepack yarn workspaces focus $(corepack yarn workspaces list --json | jq -r .name | awk '/^@uppy-example/{ next } { if ($0!="uppy.io") print $0 }')
  39. env:
  40. # https://docs.cypress.io/guides/references/advanced-installation#Skipping-installation
  41. CYPRESS_INSTALL_BINARY: 0
  42. - name: Build lib
  43. run: corepack yarn run build:lib
  44. - name: Make Uppy bundle use local version
  45. run: |
  46. node <<'EOF'
  47. const pkg = require('./packages/uppy/package.json')
  48. for(const key of Object.keys(pkg.dependencies)) {
  49. if (key.startsWith('@uppy/')) {
  50. pkg.dependencies[key] = `/tmp/packages/${key.replace('/', '-')}-${{ github.sha }}.tgz`
  51. }
  52. }
  53. require('node:fs').writeFileSync('./packages/uppy/package.json', JSON.stringify(pkg))
  54. EOF
  55. - name: Eject public packages from repo
  56. run: mkdir /tmp/artifacts && corepack yarn workspaces foreach --no-private pack --install-if-needed -o /tmp/artifacts/%s-${{ github.sha }}.tgz
  57. - name: Upload artifact
  58. if: success()
  59. uses: actions/upload-artifact@v3
  60. with:
  61. name: packages
  62. path: /tmp/artifacts/
  63. rollup:
  64. needs: isolate_uppy
  65. name: Rollup
  66. runs-on: ubuntu-latest
  67. strategy:
  68. matrix:
  69. rollup-version: [latest]
  70. steps:
  71. - name: Download uppy tarball
  72. uses: actions/download-artifact@v3
  73. with:
  74. path: /tmp/
  75. - name: Extract tarball
  76. run: tar -xzf /tmp/packages/uppy-${{ github.sha }}.tgz --strip-components 1
  77. - name: Add Rollup as a dev dependency
  78. run: >-
  79. npm i --save-dev
  80. @rollup/plugin-commonjs @rollup/plugin-node-resolve
  81. rollup@${{matrix.rollup-version}}
  82. - name: Create Rollup config file
  83. run: >-
  84. echo '
  85. import cjs from "@rollup/plugin-commonjs";
  86. import { nodeResolve } from "@rollup/plugin-node-resolve";
  87. export default {
  88. input: "./index.mjs",
  89. output: {
  90. file: "/dev/null",
  91. },
  92. plugins: [
  93. cjs(),
  94. nodeResolve({ browser: true, exportConditions: ["browser"] }),
  95. ],
  96. };' > rollup.config.mjs
  97. - name: Bundle
  98. run: npx rollup -c
  99. webpack:
  100. needs: isolate_uppy
  101. name: Webpack
  102. runs-on: ubuntu-latest
  103. strategy:
  104. matrix:
  105. webpack-version: [latest]
  106. steps:
  107. - name: Download uppy tarball
  108. uses: actions/download-artifact@v3
  109. with:
  110. path: /tmp/
  111. - name: Extract tarball
  112. run: tar -xzf /tmp/packages/uppy-${{ github.sha }}.tgz --strip-components 1
  113. - name: Add Webpack as a dev dependency
  114. run: npm i --save-dev webpack-cli webpack@${{matrix.webpack-version}}
  115. - name: Create Webpack config file
  116. run: echo 'module.exports={mode:"production",target:"web",entry:"./index.mjs"}' > webpack.config.js
  117. - name: Bundle
  118. run: npx webpack
  119. # ESBuild: We are already testing it when generating the actual bundle.
  120. # Browserify: doesn't support ESM.
  121. # Parcel: We are already testing it with our e2e tests.