-
Notifications
You must be signed in to change notification settings - Fork 32
Rust extractor + faster native transform #236
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
Draft
timofei-iatsenko
wants to merge
57
commits into
lingui:main
Choose a base branch
from
timofei-iatsenko:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
bdfa475
implement rust extractor
timofei-iatsenko fe5c99c
ci: publish workflow
timofei-iatsenko 98a9d66
ci: publish workflow
timofei-iatsenko ea86355
ci: publish workflow
timofei-iatsenko cd906b0
ci: publish workflow
timofei-iatsenko dfb3157
add repository url
timofei-iatsenko 6a136fe
disable gh release and update readme
timofei-iatsenko 93114fc
disable gh release
timofei-iatsenko b221ca9
Merge branch 'main' into main-fork
timofei-iatsenko 1703909
fix after merging with v6
timofei-iatsenko fc16b32
update claude md
timofei-iatsenko b6d6a00
pass macro options from extractor surface
timofei-iatsenko d7ca4e1
implement syntax autodetection
timofei-iatsenko f4dcb06
add pluggable swc extractor implementation
timofei-iatsenko b635f6f
disable js workspaces
timofei-iatsenko 4f9cffa
bump swc version
timofei-iatsenko 26e2a51
fix: pass message to onMessageExtracted
timofei-iatsenko 434fcb4
update readme
timofei-iatsenko 0ecb78b
version bump
timofei-iatsenko dee62db
Merge branch 'main' into main-fork
timofei-iatsenko 014f923
fixes after merge
timofei-iatsenko 0c9664b
regenerate bindings
timofei-iatsenko 3895a8a
bump a version
timofei-iatsenko a3c0443
refactor: convert packages/lingui-swc to proper yarn workspace member
timofei-iatsenko 5d1fc8c
Merge branch 'main' into main-fork
timofei-iatsenko d6fce9d
bring back publishing
timofei-iatsenko 1427217
bump version
timofei-iatsenko c9d649d
use typings from `@lingui/swc-plugin/options`; extend mapping
timofei-iatsenko 0031cc2
fix: widen constraint for @lingui/swc-plugin
timofei-iatsenko 4888fe9
chore: version bump
timofei-iatsenko 906749a
Merge branch 'main' into main-fork
timofei-iatsenko 333c00a
chore: inline macro options into lingui-swc
timofei-iatsenko 04b793a
chore: bump version
timofei-iatsenko eba2614
feat: support extractFromFiles in the extractor binding
timofei-iatsenko 851df90
Merge branch 'main' into main-fork
timofei-iatsenko 6cc0645
test: add test for module declaration extraction issue
timofei-iatsenko 5cd75c5
chore: version bump
timofei-iatsenko 9fb8874
Merge branch 'main' into main-fork
timofei-iatsenko c3491e6
bump version
timofei-iatsenko 9fc7ef7
add transformer
timofei-iatsenko 0c223ca
bump version
timofei-iatsenko cbb6e6d
fix
timofei-iatsenko 6e113de
Merge branch 'main' into main-fork
timofei-iatsenko 84ea1bc
fix merge issues
timofei-iatsenko 125e016
attempt to fix ci
timofei-iatsenko 0bcd024
Merge branch 'main' into main-fork
timofei-iatsenko 159963e
Merge branch 'main' into main-fork
timofei-iatsenko 486ba07
bump version
timofei-iatsenko 270bddb
update readme
timofei-iatsenko ef02dc7
try to fix CI
timofei-iatsenko 73afe8d
try to fix CI 2
timofei-iatsenko 5a99727
fix clippy problems
timofei-iatsenko 1922351
feat: support /** i18n */ in extractor
timofei-iatsenko dc3cadb
feat: support inline/emitted sourcemaps
timofei-iatsenko af6eeca
bump version
timofei-iatsenko 56ef37e
formatting
timofei-iatsenko 1636627
Merge branch 'main' into main
timofei-iatsenko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,349 @@ | ||
| name: CI - Lingui SWC | ||
| env: | ||
| DEBUG: napi:* | ||
| APP_NAME: lingui-swc | ||
| MACOSX_DEPLOYMENT_TARGET: '10.13' | ||
| CARGO_INCREMENTAL: '1' | ||
| on: | ||
| # push: | ||
| # branches: | ||
| # - main | ||
| # tags-ignore: | ||
| # - '**' | ||
| # paths-ignore: | ||
| # - '**/*.md' | ||
| # - LICENSE | ||
| # - '**/*.gitignore' | ||
| # - .editorconfig | ||
| # - docs/** | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| defaults: | ||
| run: | ||
| working-directory: ./packages/lingui-swc | ||
|
|
||
| jobs: | ||
| lint: | ||
| name: Lint | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - name: Setup node | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: 24 | ||
| - run: corepack enable | ||
| - name: Install Rust Toolchain | ||
| uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| components: clippy, rustfmt | ||
| - name: Install dependencies | ||
| run: yarn install | ||
| working-directory: . | ||
| - name: Oxlint | ||
| run: yarn lint | ||
| - name: Cargo fmt | ||
| run: cargo fmt -- --check | ||
| - name: Clippy | ||
| run: cargo clippy | ||
| build: | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| settings: | ||
| - host: macos-latest | ||
| target: x86_64-apple-darwin | ||
| build: yarn build --target x86_64-apple-darwin | ||
| - host: windows-latest | ||
| build: yarn build --target x86_64-pc-windows-msvc | ||
| target: x86_64-pc-windows-msvc | ||
| # - host: windows-latest | ||
| # build: yarn build --target i686-pc-windows-msvc | ||
| # target: i686-pc-windows-msvc# | ||
| - host: ubuntu-latest | ||
| target: x86_64-unknown-linux-gnu | ||
| build: yarn build --target x86_64-unknown-linux-gnu --use-napi-cross | ||
| - host: ubuntu-latest | ||
| target: x86_64-unknown-linux-musl | ||
| build: yarn build --target x86_64-unknown-linux-musl -x | ||
| - host: macos-latest | ||
| target: aarch64-apple-darwin | ||
| build: yarn build --target aarch64-apple-darwin | ||
| - host: ubuntu-latest | ||
| target: aarch64-unknown-linux-gnu | ||
| build: yarn build --target aarch64-unknown-linux-gnu --use-napi-cross | ||
| - host: ubuntu-latest | ||
| target: aarch64-linux-android | ||
| build: yarn build --target aarch64-linux-android | ||
| - host: ubuntu-latest | ||
| target: aarch64-unknown-linux-musl | ||
| build: yarn build --target aarch64-unknown-linux-musl -x | ||
| - host: windows-latest | ||
| target: aarch64-pc-windows-msvc | ||
| build: yarn build --target aarch64-pc-windows-msvc | ||
| name: stable - ${{ matrix.settings.target }} - node@24 | ||
| runs-on: ${{ matrix.settings.host }} | ||
| env: | ||
| RUSTUP_TOOLCHAIN: stable | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - name: Setup node | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: 24 | ||
| - run: corepack enable | ||
| - name: Install Rust Toolchain | ||
| uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| toolchain: stable | ||
| targets: ${{ matrix.settings.target }} | ||
| - name: Cache cargo | ||
| uses: actions/cache@v5 | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry/index/ | ||
| ~/.cargo/registry/cache/ | ||
| ~/.cargo/git/db/ | ||
| ~/.napi-rs | ||
| .cargo-cache | ||
| target/ | ||
| key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }} | ||
| - uses: mlugg/setup-zig@v2 | ||
| if: ${{ contains(matrix.settings.target, 'musl') }} | ||
| with: | ||
| version: 0.14.1 | ||
| - name: Install cargo-zigbuild | ||
| uses: taiki-e/install-action@v2 | ||
| if: ${{ contains(matrix.settings.target, 'musl') }} | ||
| env: | ||
| GITHUB_TOKEN: ${{ github.token }} | ||
| with: | ||
| tool: cargo-zigbuild | ||
| - name: Setup toolchain | ||
| run: ${{ matrix.settings.setup }} | ||
| if: ${{ matrix.settings.setup }} | ||
| shell: bash | ||
| - name: Install dependencies | ||
| run: yarn install | ||
| working-directory: . | ||
| - name: Build | ||
| run: ${{ matrix.settings.build }} | ||
| shell: bash | ||
| - name: Upload artifact | ||
| uses: actions/upload-artifact@v6 | ||
| with: | ||
| name: bindings-${{ matrix.settings.target }} | ||
|
|
||
| path: | | ||
| ./packages/lingui-swc/${{ env.APP_NAME }}.*.node | ||
| ./packages/lingui-swc/${{ env.APP_NAME }}.*.wasm | ||
| if-no-files-found: error | ||
| # build-freebsd: | ||
| # runs-on: ubuntu-latest | ||
| # name: Build FreeBSD | ||
| # steps: | ||
| # - uses: actions/checkout@v6 | ||
| # - name: Build | ||
| # id: build | ||
| # uses: cross-platform-actions/action@v0.32.0 | ||
| # env: | ||
| # DEBUG: napi:* | ||
| # RUSTUP_IO_THREADS: 1 | ||
| # with: | ||
| # operating_system: freebsd | ||
| # version: '15.0' | ||
| # memory: 8G | ||
| # cpu_count: 3 | ||
| # environment_variables: DEBUG RUSTUP_IO_THREADS | ||
| # shell: bash | ||
| # # language=bash | ||
| # run: | | ||
| # sudo pkg install -y -f curl node libnghttp2 npm cmake | ||
| # corepack enable | ||
| # # sudo npm install -g yarn --ignore-scripts | ||
| # curl https://sh.rustup.rs -sSf --output rustup.sh | ||
| # sh rustup.sh -y --profile minimal --default-toolchain stable | ||
| # source "$HOME/.cargo/env" | ||
| # echo "~~~~ rustc --version ~~~~" | ||
| # rustc --version | ||
| # echo "~~~~ node -v ~~~~" | ||
| # node -v | ||
| # echo "~~~~ yarn --version ~~~~" | ||
| # yarn --version | ||
| # pwd | ||
| # ls -lah | ||
| # whoami | ||
| # env | ||
| # freebsd-version | ||
| # yarn install | ||
| # yarn build | ||
| # - name: Upload artifact | ||
| # uses: actions/upload-artifact@v6 | ||
| # with: | ||
| # name: bindings-freebsd | ||
| # path: ./packages/lingui-swc/${{ env.APP_NAME }}.*.node | ||
| # if-no-files-found: error | ||
| test-macOS-windows-binding: | ||
| name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }} | ||
| needs: | ||
| - build | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| settings: | ||
| - host: windows-latest | ||
| target: x86_64-pc-windows-msvc | ||
| architecture: x64 | ||
| - host: macos-latest | ||
| target: aarch64-apple-darwin | ||
| architecture: arm64 | ||
| - host: macos-latest | ||
| target: x86_64-apple-darwin | ||
| architecture: x64 | ||
| node: | ||
| - '22' | ||
| - '24' | ||
| runs-on: ${{ matrix.settings.host }} | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - name: Setup node | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: ${{ matrix.node }} | ||
| architecture: ${{ matrix.settings.architecture }} | ||
| - run: corepack enable | ||
| - name: Install dependencies | ||
| run: yarn install | ||
| working-directory: . | ||
| - name: Download artifacts | ||
| uses: actions/download-artifact@v7 | ||
| with: | ||
| name: bindings-${{ matrix.settings.target }} | ||
| path: ./packages/lingui-swc | ||
| - name: List packages | ||
| run: ls -R . | ||
| shell: bash | ||
| - name: Test bindings | ||
| run: yarn test | ||
| test-linux-binding: | ||
| name: Test ${{ matrix.target }} - node@${{ matrix.node }} | ||
| needs: | ||
| - build | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| target: | ||
| - x86_64-unknown-linux-gnu | ||
| - x86_64-unknown-linux-musl | ||
| - aarch64-unknown-linux-gnu | ||
| - aarch64-unknown-linux-musl | ||
| node: | ||
| - '22' | ||
| - '24' | ||
| runs-on: ${{ contains(matrix.target, 'aarch64') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }} | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| # - name: Setup node | ||
| # uses: actions/setup-node@v6 | ||
| # with: | ||
| # node-version: ${{ matrix.node }} | ||
| - run: corepack enable | ||
| - name: Output docker params | ||
| uses: actions/github-script@v8 | ||
| id: docker | ||
| with: | ||
| # language=javascript | ||
| script: | | ||
| const target = '${{ matrix.target }}'; | ||
| const node = '${{ matrix.node }}'; | ||
|
|
||
| if (target.startsWith('aarch64')) { | ||
| core.setOutput('PLATFORM', 'linux/arm64'); | ||
| } else if (target.startsWith('armv7')) { | ||
| core.setOutput('PLATFORM', 'linux/arm/v7'); | ||
| } else { | ||
| core.setOutput('PLATFORM', 'linux/amd64'); | ||
| } | ||
|
|
||
| const suffix = target.endsWith('-musl') ? 'alpine' : 'slim'; | ||
| core.setOutput('IMAGE', `node:${node}-${suffix}`) | ||
|
|
||
| - name: Download artifacts | ||
| uses: actions/download-artifact@v7 | ||
| with: | ||
| name: bindings-${{ matrix.target }} | ||
| path: ./packages/lingui-swc | ||
| - name: List packages | ||
| run: ls -R . | ||
| shell: bash | ||
| - name: Set up QEMU | ||
| uses: docker/setup-qemu-action@v3 | ||
| if: ${{ contains(matrix.target, 'armv7') }} | ||
| with: | ||
| platforms: all | ||
| - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes | ||
| if: ${{ contains(matrix.target, 'armv7') }} | ||
| - name: Test bindings | ||
| run: | | ||
| docker run --rm \ | ||
| -v ${{ github.workspace }}:/repo \ | ||
| -w /repo \ | ||
| --platform ${{ steps.docker.outputs.PLATFORM }} \ | ||
| ${{ steps.docker.outputs.IMAGE }} \ | ||
| sh -c "corepack enable && yarn install && cd packages/lingui-swc && yarn test" | ||
| publish: | ||
| name: Publish | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| id-token: write | ||
| needs: | ||
| - lint | ||
| # - build-freebsd | ||
| - test-macOS-windows-binding | ||
| - test-linux-binding | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - name: Setup node | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: 24 | ||
| - run: corepack enable | ||
| - name: Install dependencies | ||
| run: yarn install | ||
| working-directory: . | ||
| - name: create npm dirs | ||
| run: yarn napi create-npm-dirs | ||
| - name: Download all artifacts | ||
| uses: actions/download-artifact@v7 | ||
| with: | ||
| path: ./packages/lingui-swc/artifacts | ||
| - name: Move artifacts | ||
| run: yarn artifacts | ||
| - name: List packages | ||
| run: ls -R ./npm | ||
| shell: bash | ||
| - name: Publish | ||
| if: github.event_name == 'workflow_dispatch' | ||
| # language=bash | ||
| run: | | ||
| echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc | ||
| npm publish --provenance --access public | ||
| # | ||
| # if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$"; | ||
| # then | ||
| # npm publish --provenance --access public | ||
| # elif git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+"; | ||
| # then | ||
| # npm publish --access public --tag next | ||
| # else | ||
| # echo "Not a release, skipping publish" | ||
| # fi | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| nodeLinker: node-modules | ||
|
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a lot of commented code in this workflow. Is there anything we can do to eliminate it?