Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ESM imports and tree-shaking #363

Merged
merged 45 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
152e831
update import styles to use file suffixes
trxcllnt Jan 3, 2024
1c9b32a
update gulp scripts to use ESM, add tree-shaking bundle command for t…
trxcllnt Jan 3, 2024
be079eb
update jest configs to use ESM, update tsconfigs
trxcllnt Jan 3, 2024
07e09d4
update dependencies
trxcllnt Jan 3, 2024
37b6dc7
rename .eslintrc.js -> .eslintrc.cjs
trxcllnt Jan 3, 2024
c95c350
formatting
trxcllnt Jan 3, 2024
133b05c
Merge branch 'master' of github.com:ReactiveX/IxJS into fix/import-wi…
trxcllnt May 17, 2024
ff7a3af
get it all working
trxcllnt May 18, 2024
50c6c1c
Update job names
trxcllnt May 18, 2024
90241f2
add concurrency
trxcllnt May 18, 2024
ca60151
add @rollup/rollup-linux-x64-gnu as an optional dependency
trxcllnt May 18, 2024
dc4ab75
drop node 14.x
trxcllnt May 18, 2024
2e0c024
don't fail fast
trxcllnt May 18, 2024
3769617
share more node_modules caches
trxcllnt May 18, 2024
2cdc776
fix module name mapper
trxcllnt May 18, 2024
80814cb
simplify main.pr.yaml, add job to test bundler tree-shaking
trxcllnt May 18, 2024
26fd7fc
increase due times in timeout-spec.ts
trxcllnt May 18, 2024
e9cd99f
commit yarn lockfile
trxcllnt May 18, 2024
5beb9ee
automatically generate files to test bundler tree-shaking for every I…
trxcllnt May 18, 2024
0f18ff1
import the function directly
trxcllnt May 18, 2024
6ce05c6
consider source files in the cache key
trxcllnt May 18, 2024
be2fe59
update docs
trxcllnt May 20, 2024
a7a87d7
run bundle integration tests on each package
trxcllnt May 20, 2024
10801c7
run bundle integration tests in parallel
trxcllnt May 20, 2024
bc216ed
remove node from integration matrix
trxcllnt May 20, 2024
bdd4837
fix ix matrix entries
trxcllnt May 20, 2024
a0e5371
fix cache key
trxcllnt May 20, 2024
9e23152
fix typo
trxcllnt May 20, 2024
6f7efde
fix imports missing .js extensions
trxcllnt May 20, 2024
302e666
fix UMD bundle main keys in package.json
trxcllnt May 20, 2024
e8ea432
add step to test importing the package as cjs and esm
trxcllnt May 20, 2024
ea7fa29
don't use npm link -g
trxcllnt May 20, 2024
3d0e7db
install globally
trxcllnt May 20, 2024
f208616
fix package names
trxcllnt May 20, 2024
2ee23bd
install into tmpdir
trxcllnt May 20, 2024
5407ade
fix typo
trxcllnt May 20, 2024
48f8bf4
fix copy destination
trxcllnt May 20, 2024
fa4088e
mkdir before copy
trxcllnt May 20, 2024
4a3de8b
use globstar
trxcllnt May 20, 2024
fe0bf0f
don't globstar
trxcllnt May 20, 2024
1e1f5e5
use dirname
trxcllnt May 20, 2024
05f78c7
make import step non-optional
trxcllnt May 21, 2024
75c1abb
Better names for CI jobs
trxcllnt May 21, 2024
3473e0d
refactor into reusable workflows
trxcllnt May 21, 2024
de1707e
change PR workflow name, fix bundle cache key + script
trxcllnt May 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 0 additions & 7 deletions .esdoc.json

This file was deleted.

6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.eslintrc.cjs
gulp
jest.config.js
jestconfigs
targets
integration
1 change: 1 addition & 0 deletions .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module.exports = {
node: true,
},
parser: "@typescript-eslint/parser",
ignorePatterns: ["spec/bundle/**/*.js"],
parserOptions: {
project: "tsconfig.json",
sourceType: "module",
Expand Down
56 changes: 56 additions & 0 deletions .github/workflows/bundle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Bundle

on:
workflow_call:

jobs:
test-tree-shaking-pull-request:
name: ${{ matrix.bundler }} ${{ matrix.target }} ${{ matrix.module }}
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
bundler: [esbuild, rollup, webpack]
target: [es5, es2015, esnext]
module: [cjs, esm, umd]
include:
- {bundler: esbuild, target: ix}
- {bundler: rollup, target: ix}
- {bundler: webpack, target: ix}
steps:
- name: Setup node v20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Construct cache keys
run: |
echo node_modules_key='["${{ runner.os }}", "node_modules", "20.x", "${{ hashFiles('package.json', 'yarn.lock') }}"]' >> $GITHUB_ENV;
echo targets_key='["${{ runner.os }}", "targets", "20.x", "ix", "", "${{ hashFiles('package.json', 'yarn.lock', 'tsconfig.json', 'src/**/*', 'tsconfigs/**/*') }}"]' >> $GITHUB_ENV;

- name: Cache targets
uses: actions/cache@v4
with:
key: ${{ join(fromJSON(env.targets_key), '-') }}
path: targets

- name: Cache node_modules
uses: actions/cache@v4
with:
key: ${{ join(fromJSON(env.node_modules_key), '-') }}
path: node_modules

- name: Test ${{ matrix.bundler }} tree-shaking
env:
t: "${{ matrix.target }}"
m: "${{ matrix.module }}"
run: |
integration/make-files-to-bundle.sh
if test "${t}" != ix; then
yarn build ${t:+-t ${t}} ${m:+-m ${m}}
fi
yarn gulp bundle${t:+:${t}}${m:+:${m}}:${{ matrix.bundler }}
8 changes: 5 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,21 @@ jobs:
container: node:16.15.1-bullseye
steps:
- name: Checkout main
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: main
persist-credentials: false
- name: Checkout gh-pages
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: gh-pages
path: gh-pages
persist-credentials: false
- name: Build Docs
working-directory: main
run: |
set -x
yarn --ignore-optional --ignore-engines --non-interactive
yarn --ignore-engines --non-interactive
yarn doc
- name: Copy Docs to gh-pages
run: |
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Lint

on:
workflow_call:

jobs:
lint-pull-request:
name: Lint
runs-on: ubuntu-22.04
steps:
- name: Setup node v20.x
uses: actions/setup-node@v4
with:
node-version: 20.x

- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Construct cache keys
run: |
echo node_modules_key='["${{ runner.os }}", "node_modules", "20.x", "${{ hashFiles('package.json', 'yarn.lock') }}"]' >> $GITHUB_ENV;

- name: Cache node_modules
uses: actions/cache@v4
with:
key: ${{ join(fromJSON(env.node_modules_key), '-') }}
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
117 changes: 15 additions & 102 deletions .github/workflows/main.pr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
name: Build pull request
name: PR

concurrency:
group: pr-on-${{ github.event_name }}-from-${{ github.ref_name }}
cancel-in-progress: true

on:
pull_request:
Expand All @@ -7,106 +11,15 @@ on:

jobs:
lint-pull-request:
name: Lint pull request
runs-on: ubuntu-20.04
strategy:
fail-fast: true
matrix:
node: [18.x]
steps:
- name: Setup node v${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- name: Checkout
uses: actions/checkout@v3

- name: Cache node_modules
uses: actions/cache@v2
with:
key: ${{ runner.os }}-node_modules-${{ matrix.node }}-${{ hashFiles('package.json') }}
path: |
node_modules

- name: Check if source or test files changed
id: files_changed
uses: tj-actions/changed-files@v41
with:
files: |
src/**/*
spec/**/*

- name: Install dependencies
if: ${{ steps.files_changed.outputs.any_changed == 'true' || steps.files_changed.outputs.any_deleted == 'true' }}
run: |
yarn

- name: Lint files
if: ${{ steps.files_changed.outputs.any_changed == 'true' || steps.files_changed.outputs.any_deleted == 'true' }}
run: |
yarn lint:ci
name: Lint
uses: ./.github/workflows/lint.yml

build-and-test-pull-request:
needs:
- lint-pull-request
name: Build and test pull request
runs-on: ubuntu-20.04
strategy:
fail-fast: true
matrix:
node: [14.x, 16.x, 18.x]
module: [cjs, esm, umd]
target: [es5, es2015, esnext]
exclude:
- {node: 14.x, target: esnext}
steps:
- name: Setup node v${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Checkout
uses: actions/checkout@v3

- name: Cache targets
uses: actions/cache@v2
with:
key: ${{ runner.os }}-targets-${{ matrix.node }}-${{ matrix.target }}-${{ matrix.module }}-${{ hashFiles('package.json') }}
path: |
targets

- name: Cache node_modules
uses: actions/cache@v2
with:
key: ${{ runner.os }}-node_modules-${{ matrix.node }}-${{ matrix.target }}-${{ matrix.module }}-${{ hashFiles('package.json') }}
path: |
node_modules

- name: Check if test files changed
id: test_files_changed
uses: tj-actions/changed-files@v41
with:
files: |
spec/**/*

- name: Check if source files changed
id: source_files_changed
uses: tj-actions/changed-files@v41
with:
files: |
src/**/*

- name: Install dependencies
if: ${{ steps.test_files_changed.outputs.any_changed == 'true' || steps.test_files_changed.outputs.any_deleted == 'true' || steps.source_files_changed.outputs.any_changed == 'true' || steps.source_files_changed.outputs.any_deleted == 'true' }}
run: |
yarn --ignore-optional --ignore-engines --non-interactive

- name: Build package
if: ${{ steps.source_files_changed.outputs.any_changed == 'true' || steps.source_files_changed.outputs.any_deleted == 'true' }}
run: |
yarn build -t ${{ matrix.target }} -m ${{ matrix.module }}

- name: Test package
if: ${{ steps.test_files_changed.outputs.any_changed == 'true' || steps.test_files_changed.outputs.any_deleted == 'true' || steps.source_files_changed.outputs.any_changed == 'true' || steps.source_files_changed.outputs.any_deleted == 'true' }}
run: |
yarn test -t ${{ matrix.target }} -m ${{ matrix.module }}
name: Test
needs: lint-pull-request
uses: ./.github/workflows/test.yml

test-tree-shaking-pull-request:
needs: build-and-test-pull-request
name: Bundle
uses: ./.github/workflows/bundle.yml
Loading
Loading