-
-
Notifications
You must be signed in to change notification settings - Fork 16
refactor: split into chunk files #219
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
Merged
+1,791
−1,396
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4cfe2e9
refactor: split into chunk files
JounQin 16fb628
📝 Add docstrings to `refactor/chunks` (#220)
coderabbitai[bot] 0c7a837
test: improve test coverage
JounQin 8c215d4
chore: bump `@types/node`
JounQin c1bd3eb
Create spicy-walls-listen.md
JounQin 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "synckit": patch | ||
| --- | ||
|
|
||
| refactor: split into chunk files, add `module-sync` entry |
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,10 +1,10 @@ | ||
| root = true | ||
| root=true | ||
|
|
||
| [*] | ||
| indent_style = space | ||
| indent_size = 2 | ||
| tab_width = 2 | ||
| end_of_line = lf | ||
| charset = utf-8 | ||
| trim_trailing_whitespace = true | ||
| insert_final_newline = true | ||
| indent_style=space | ||
| indent_size=2 | ||
| tab_width=2 | ||
| end_of_line=lf | ||
| charset=utf-8 | ||
| trim_trailing_whitespace=true | ||
| insert_final_newline=true |
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,36 @@ | ||
| name: autofix.ci # For security reasons, the workflow in which the autofix.ci action is used must be named "autofix.ci". | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: | ||
| - opened | ||
| - reopened | ||
| - synchronize | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| autofix: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout Repo | ||
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | ||
|
|
||
| - name: Setup Node.js LTS | ||
| uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4 | ||
| with: | ||
| node-version: lts/* | ||
| cache: yarn | ||
|
|
||
| - name: Install dependencies | ||
| run: yarn --immutable | ||
|
|
||
| - name: Format Codes | ||
| run: yarn format | ||
|
|
||
| - name: Apply autofix.ci | ||
| uses: autofix-ci/action@2891949f3779a1cafafae1523058501de3d4e944 # v1 | ||
| with: | ||
| fail-fast: false | ||
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
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,36 @@ | ||
| name: Size Limit | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - master | ||
| - v3.x | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| size-limit: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js LTS | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: lts/* | ||
| cache: yarn | ||
|
|
||
| - name: Install Dependencies | ||
| run: yarn --immutable | ||
|
|
||
| - uses: andresz1/size-limit-action@v1.8.0 | ||
| with: | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| skip_step: install | ||
| script: yarn size-limit --json |
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,6 @@ | ||
| [ | ||
| { | ||
| "path": "./lib/index.js", | ||
| "limit": "1kB" | ||
| } | ||
| ] | ||
JounQin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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
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,25 @@ | ||
| const NODE_OPTIONS = process.env.NODE_OPTIONS?.split(/\s+/) | ||
|
|
||
| export const hasFlag = (flag: string) => | ||
| NODE_OPTIONS?.includes(flag) || process.argv.includes(flag) | ||
|
|
||
| export const parseVersion = (version: string) => | ||
| version.split('.').map(Number.parseFloat) | ||
|
|
||
| // A naive implementation of semver comparison | ||
| export const compareVersion = (version1: string, version2: string) => { | ||
| const versions1 = parseVersion(version1) | ||
| const versions2 = parseVersion(version2) | ||
| const length = Math.max(versions1.length, versions2.length) | ||
| for (let i = 0; i < length; i++) { | ||
| const v1 = versions1[i] || 0 | ||
| const v2 = versions2[i] || 0 | ||
| if (v1 > v2) { | ||
| return 1 | ||
| } | ||
| if (v1 < v2) { | ||
| return -1 | ||
| } | ||
| } | ||
| return 0 | ||
| } | ||
JounQin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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,83 @@ | ||
| import { compareVersion, hasFlag } from './common.js' | ||
| import type { GlobalShim, ValueOf } from './types.js' | ||
|
|
||
| export const TsRunner = { | ||
| // https://nodejs.org/docs/latest/api/typescript.html#type-stripping | ||
| Node: 'node', | ||
| // https://bun.sh/docs/typescript | ||
| Bun: 'bun', | ||
| // https://github.com/TypeStrong/ts-node | ||
| TsNode: 'ts-node', | ||
| // https://github.com/egoist/esbuild-register | ||
| EsbuildRegister: 'esbuild-register', | ||
| // https://github.com/folke/esbuild-runner | ||
| EsbuildRunner: 'esbuild-runner', | ||
| // https://github.com/swc-project/swc-node/tree/master/packages/register | ||
| SWC: 'swc', | ||
| // https://github.com/esbuild-kit/tsx | ||
| TSX: 'tsx', | ||
| } as const | ||
|
|
||
| export type TsRunner = ValueOf<typeof TsRunner> | ||
|
|
||
| const { | ||
| NODE_OPTIONS: NODE_OPTIONS_ = '', | ||
| SYNCKIT_EXEC_ARGV = '', | ||
| SYNCKIT_GLOBAL_SHIMS, | ||
| SYNCKIT_TIMEOUT, | ||
| SYNCKIT_TS_RUNNER, | ||
| } = process.env | ||
|
|
||
| export const MTS_SUPPORTED_NODE_VERSION = '16' | ||
| export const LOADER_SUPPORTED_NODE_VERSION = '20' | ||
|
|
||
| // https://nodejs.org/docs/latest-v22.x/api/typescript.html#type-stripping | ||
| export const STRIP_TYPES_NODE_VERSION = '22.6' | ||
|
|
||
| // https://nodejs.org/docs/latest-v23.x/api/typescript.html#modules-typescript | ||
| export const TRANSFORM_TYPES_NODE_VERSION = '22.7' | ||
|
|
||
| // https://nodejs.org/docs/latest-v22.x/api/process.html#processfeaturestypescript | ||
| export const FEATURE_TYPESCRIPT_NODE_VERSION = '22.10' | ||
|
|
||
JounQin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // https://nodejs.org/docs/latest-v23.x/api/typescript.html#type-stripping | ||
| export const DEFAULT_TYPES_NODE_VERSION = '23.6' | ||
|
|
||
| export const STRIP_TYPES_FLAG = '--experimental-strip-types' | ||
| export const TRANSFORM_TYPES_FLAG = '--experimental-transform-types' | ||
| export const NO_STRIP_TYPES_FLAG = '--no-experimental-strip-types' | ||
|
|
||
| export const NODE_OPTIONS = NODE_OPTIONS_.split(/\s+/) | ||
|
|
||
| export const NODE_VERSION = process.versions.node | ||
|
|
||
| export const NO_STRIP_TYPES = // >= | ||
| compareVersion(NODE_VERSION, FEATURE_TYPESCRIPT_NODE_VERSION) >= 0 | ||
| ? process.features.typescript === false | ||
| : hasFlag(NO_STRIP_TYPES_FLAG) && | ||
| !hasFlag(STRIP_TYPES_FLAG) && | ||
| !hasFlag(TRANSFORM_TYPES_FLAG) | ||
JounQin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| export const DEFAULT_TIMEOUT = SYNCKIT_TIMEOUT ? +SYNCKIT_TIMEOUT : undefined | ||
JounQin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| export const DEFAULT_EXEC_ARGV = SYNCKIT_EXEC_ARGV.split(',') | ||
|
|
||
| export const DEFAULT_TS_RUNNER = SYNCKIT_TS_RUNNER as TsRunner | undefined | ||
|
|
||
| export const DEFAULT_GLOBAL_SHIMS = ['1', 'true'].includes( | ||
| SYNCKIT_GLOBAL_SHIMS!, | ||
| ) | ||
|
|
||
JounQin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| export const DEFAULT_GLOBAL_SHIMS_PRESET: GlobalShim[] = [ | ||
| { | ||
| moduleName: 'node-fetch', | ||
| globalName: 'fetch', | ||
| }, | ||
| { | ||
| moduleName: 'node:perf_hooks', | ||
| globalName: 'performance', | ||
| named: 'performance', | ||
| }, | ||
| ] | ||
|
|
||
| export const INT32_BYTES = 4 | ||
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.
Uh oh!
There was an error while loading. Please reload this page.