Skip to content

Fix ESM imports and tree-shaking #56

Fix ESM imports and tree-shaking

Fix ESM imports and tree-shaking #56

Workflow file for this run

name: Build pull request
concurrency:
group: pr-on-${{ github.event_name }}-from-${{ github.ref_name }}
cancel-in-progress: true
on:
pull_request:
branches:
- "master"
jobs:
lint-pull-request:
name: Lint
runs-on: ubuntu-22.04
strategy:
fail-fast: true
matrix:
node: [20.x]
steps:
- name: Setup node v${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Cache node_modules
uses: actions/cache@v4
with:
key: ${{ runner.os }}-node_modules-${{ matrix.node }}-${{ hashFiles('package.json', 'yarn.lock') }}
path: |
node_modules
- name: Check if source or test files changed
id: files_changed
uses: tj-actions/changed-files@v44
with:
files: |
src/**/*
spec/**/*
- name: Lint files
if: ${{ steps.files_changed.outputs.any_modified == 'true' }}
run: |
yarn --ignore-engines --non-interactive
yarn lint:ci
build-and-test-pull-request:
needs:
- lint-pull-request
name: Test
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
node: [16.x, 18.x, 20.x]
module: [cjs, esm, umd]
target: [es5, es2015, esnext]
include:
- {node: 20.x, target: src, args: --coverage}
steps:
- name: Setup node v${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Cache targets
uses: actions/cache@v4
with:
key: ${{ runner.os }}-targets-${{ matrix.node }}-${{ matrix.target }}-${{ matrix.module }}-${{ hashFiles('package.json', 'yarn.lock', 'src/**/*') }}
path: targets
- name: Cache node_modules
uses: actions/cache@v4
with:
key: ${{ runner.os }}-node_modules-${{ matrix.node }}-${{ hashFiles('package.json', 'yarn.lock') }}
path: node_modules
- name: Check if test files changed
id: test_files_changed
uses: tj-actions/changed-files@v44
with:
files: |
spec/**/*
- name: Check if source files changed
id: source_files_changed
uses: tj-actions/changed-files@v44
with:
files: |
.npmrc
yarn.lock
package.json
src/**/*
- name: Install dependencies
if: ${{ steps.source_files_changed.outputs.any_modified == 'true' || steps.test_files_changed.outputs.any_modified == 'true' }}
run: |
yarn --ignore-engines --non-interactive
- name: Build package
if: ${{ steps.source_files_changed.outputs.any_modified == 'true' && matrix.target != 'src' }}
env:
ecmascriptver: "${{ matrix.target }}"
module_format: "${{ matrix.module }}"
run: |
yarn build ${ecmascriptver:+-t ${ecmascriptver}} ${module_format:+-m ${module_format}}
- name: Test package
if: ${{ steps.source_files_changed.outputs.any_modified == 'true' || steps.test_files_changed.outputs.any_modified == 'true' }}
env:
ecmascriptver: "${{ matrix.target }}"
module_format: "${{ matrix.module }}"
run: |
yarn test ${ecmascriptver:+-t ${ecmascriptver}} ${module_format:+-m ${module_format}} ${{ matrix.args }}
test-tree-shaking-pull-request:
needs:
- build-and-test-pull-request
name: Test tree shaking
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
node: [20.x]
steps:
- name: Setup node v${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Cache targets
uses: actions/cache@v4
with:
key: ${{ runner.os }}-targets-${{ matrix.node }}-ix-${{ hashFiles('package.json', 'yarn.lock', 'src/**/*') }}
path: targets
- name: Cache node_modules
uses: actions/cache@v4
with:
key: ${{ runner.os }}-node_modules-${{ matrix.node }}-${{ hashFiles('package.json', 'yarn.lock') }}
path: node_modules
- name: Check if source files changed
id: source_files_changed
uses: tj-actions/changed-files@v44
with:
files: |
.npmrc
yarn.lock
package.json
src/**/*
test/bundle/**/*
- name: Test bundler tree-shaking
if: ${{ steps.source_files_changed.outputs.any_modified == 'true' }}
run: |
yarn --ignore-engines --non-interactive
yarn build -t ix
test/bundle/make-files-to-bundle.sh
yarn test:bundle