From 75c6188ff767a2079f993b262d8cfcd6288802e3 Mon Sep 17 00:00:00 2001 From: fi3ework Date: Thu, 10 Oct 2024 13:47:40 +0800 Subject: [PATCH 1/3] fix: count in `optionalDependencies` in `autoExternal`. --- packages/core/src/config.ts | 20 +++++++++++++------- packages/core/src/types/utils.ts | 3 ++- packages/plugin-dts/src/dts.ts | 2 ++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/packages/core/src/config.ts b/packages/core/src/config.ts index cd9350a72..1d3f355fd 100644 --- a/packages/core/src/config.ts +++ b/packages/core/src/config.ts @@ -227,21 +227,27 @@ export const composeAutoExternalConfig = (options: { return {}; } + // User externals configuration has higher priority than autoExternal + // eg: autoExternal: ['react'], user: output: { externals: { react: 'react-1' } } + // Only handle the case where the externals type is object, string / string[] does not need to be processed, other types are too complex. + const userExternalKeys = + userExternals && isObject(userExternals) ? Object.keys(userExternals) : []; + const externalOptions = { dependencies: true, + optionalDependencies: true, peerDependencies: true, devDependencies: false, ...(autoExternal === true ? {} : autoExternal), }; - // User externals configuration has higher priority than autoExternal - // eg: autoExternal: ['react'], user: output: { externals: { react: 'react-1' } } - // Only handle the case where the externals type is object, string / string[] does not need to be processed, other types are too complex. - const userExternalKeys = - userExternals && isObject(userExternals) ? Object.keys(userExternals) : []; - const externals = ( - ['dependencies', 'peerDependencies', 'devDependencies'] as const + [ + 'dependencies', + 'peerDependencies', + 'devDependencies', + 'optionalDependencies', + ] as const ) .reduce((prev, type) => { if (externalOptions[type]) { diff --git a/packages/core/src/types/utils.ts b/packages/core/src/types/utils.ts index 8b3d31293..bc99ee756 100644 --- a/packages/core/src/types/utils.ts +++ b/packages/core/src/types/utils.ts @@ -1,6 +1,7 @@ export type PkgJson = { + type?: 'module' | 'commonjs'; dependencies?: Record; peerDependencies?: Record; devDependencies?: Record; - [key: string]: unknown; + optionalDependencies?: Record; }; diff --git a/packages/plugin-dts/src/dts.ts b/packages/plugin-dts/src/dts.ts index d30252052..d689f335a 100644 --- a/packages/plugin-dts/src/dts.ts +++ b/packages/plugin-dts/src/dts.ts @@ -26,6 +26,7 @@ export const calcBundledPackages = (options: { dependencies?: Record; peerDependencies?: Record; devDependencies?: Record; + optionalDependencies?: Record; }; try { @@ -42,6 +43,7 @@ export const calcBundledPackages = (options: { ? { dependencies: true, peerDependencies: true, + optionalDependencies: true, devDependencies: false, ...(autoExternal === true ? {} : autoExternal), } From fad137661fdb7c1bb99377ecc8820df3df6353d3 Mon Sep 17 00:00:00 2001 From: fi3ework Date: Thu, 10 Oct 2024 14:05:18 +0800 Subject: [PATCH 2/3] ci: node version --- .github/workflows/lint.yml | 4 ++-- .github/workflows/release-pull-request.yml | 4 ++-- .github/workflows/release.yml | 4 ++-- .github/workflows/test-ubuntu.yml | 4 ++-- .github/workflows/test-windows.yml | 4 ++-- .nvmrc | 2 +- CONTRIBUTING.md | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 54b52a4be..a5480c843 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -30,10 +30,10 @@ jobs: - name: Install Pnpm run: corepack enable - - name: Setup Node.js 18.x + - name: Setup Node.js 20 uses: actions/setup-node@v4 with: - node-version: 18.x + node-version: 20 cache: 'pnpm' - name: Install Dependencies diff --git a/.github/workflows/release-pull-request.yml b/.github/workflows/release-pull-request.yml index e7c76daac..bff548808 100644 --- a/.github/workflows/release-pull-request.yml +++ b/.github/workflows/release-pull-request.yml @@ -29,10 +29,10 @@ jobs: - name: Install Pnpm run: corepack enable - - name: Setup Node.js 18 + - name: Setup Node.js 20 uses: actions/setup-node@v4 with: - node-version: '18' + node-version: 20 cache: 'pnpm' - name: Install Dependencies diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 73e4046e7..cc5c972e6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,10 +37,10 @@ jobs: - name: Install Pnpm run: corepack enable - - name: Setup Node.js 18 + - name: Setup Node.js 20 uses: actions/setup-node@v4 with: - node-version: '18' + node-version: 20 cache: 'pnpm' - name: Install Dependencies diff --git a/.github/workflows/test-ubuntu.yml b/.github/workflows/test-ubuntu.yml index d7dab8e3c..18ff508a4 100644 --- a/.github/workflows/test-ubuntu.yml +++ b/.github/workflows/test-ubuntu.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [18.x] + node-version: [20] # Steps represent a sequence of tasks that will be executed as part of the job steps: @@ -64,7 +64,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [18.x] + node-version: [20] # Steps represent a sequence of tasks that will be executed as part of the job steps: diff --git a/.github/workflows/test-windows.yml b/.github/workflows/test-windows.yml index 32a5cc547..31d93ec72 100644 --- a/.github/workflows/test-windows.yml +++ b/.github/workflows/test-windows.yml @@ -21,7 +21,7 @@ jobs: runs-on: windows-latest strategy: matrix: - node-version: [18.x] + node-version: [20] # Steps represent a sequence of tasks that will be executed as part of the job steps: @@ -69,7 +69,7 @@ jobs: runs-on: windows-latest strategy: matrix: - node-version: [18.x] + node-version: [20] # Steps represent a sequence of tasks that will be executed as part of the job steps: diff --git a/.nvmrc b/.nvmrc index ef65309b0..2edeafb09 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v18.20.2 \ No newline at end of file +20 \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f2265ffe9..3310c0c7a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,7 @@ Thanks for that you are interested in contributing to Rslib. Before starting you ## Install Node.js -Use [fnm](https://github.com/Schniz/fnm) or [nvm](https://github.com/nvm-sh/nvm) to run the command below. This will switch to the Node.js version (currently 18) specified in the project's `.nvmrc` file. +Use [fnm](https://github.com/Schniz/fnm) or [nvm](https://github.com/nvm-sh/nvm) to run the command below. This will switch to the Node.js version (currently 20) specified in the project's `.nvmrc` file. ```bash # with fnm From f9fca306c940452a4278049e8d619709f3e0757e Mon Sep 17 00:00:00 2001 From: fi3ework Date: Thu, 10 Oct 2024 14:16:15 +0800 Subject: [PATCH 3/3] Revert "ci: node version" This reverts commit fad137661fdb7c1bb99377ecc8820df3df6353d3. --- .github/workflows/lint.yml | 4 ++-- .github/workflows/release-pull-request.yml | 4 ++-- .github/workflows/release.yml | 4 ++-- .github/workflows/test-ubuntu.yml | 4 ++-- .github/workflows/test-windows.yml | 4 ++-- .nvmrc | 2 +- CONTRIBUTING.md | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a5480c843..54b52a4be 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -30,10 +30,10 @@ jobs: - name: Install Pnpm run: corepack enable - - name: Setup Node.js 20 + - name: Setup Node.js 18.x uses: actions/setup-node@v4 with: - node-version: 20 + node-version: 18.x cache: 'pnpm' - name: Install Dependencies diff --git a/.github/workflows/release-pull-request.yml b/.github/workflows/release-pull-request.yml index bff548808..e7c76daac 100644 --- a/.github/workflows/release-pull-request.yml +++ b/.github/workflows/release-pull-request.yml @@ -29,10 +29,10 @@ jobs: - name: Install Pnpm run: corepack enable - - name: Setup Node.js 20 + - name: Setup Node.js 18 uses: actions/setup-node@v4 with: - node-version: 20 + node-version: '18' cache: 'pnpm' - name: Install Dependencies diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cc5c972e6..73e4046e7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,10 +37,10 @@ jobs: - name: Install Pnpm run: corepack enable - - name: Setup Node.js 20 + - name: Setup Node.js 18 uses: actions/setup-node@v4 with: - node-version: 20 + node-version: '18' cache: 'pnpm' - name: Install Dependencies diff --git a/.github/workflows/test-ubuntu.yml b/.github/workflows/test-ubuntu.yml index 18ff508a4..d7dab8e3c 100644 --- a/.github/workflows/test-ubuntu.yml +++ b/.github/workflows/test-ubuntu.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [20] + node-version: [18.x] # Steps represent a sequence of tasks that will be executed as part of the job steps: @@ -64,7 +64,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [20] + node-version: [18.x] # Steps represent a sequence of tasks that will be executed as part of the job steps: diff --git a/.github/workflows/test-windows.yml b/.github/workflows/test-windows.yml index 31d93ec72..32a5cc547 100644 --- a/.github/workflows/test-windows.yml +++ b/.github/workflows/test-windows.yml @@ -21,7 +21,7 @@ jobs: runs-on: windows-latest strategy: matrix: - node-version: [20] + node-version: [18.x] # Steps represent a sequence of tasks that will be executed as part of the job steps: @@ -69,7 +69,7 @@ jobs: runs-on: windows-latest strategy: matrix: - node-version: [20] + node-version: [18.x] # Steps represent a sequence of tasks that will be executed as part of the job steps: diff --git a/.nvmrc b/.nvmrc index 2edeafb09..ef65309b0 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -20 \ No newline at end of file +v18.20.2 \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3310c0c7a..f2265ffe9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,7 @@ Thanks for that you are interested in contributing to Rslib. Before starting you ## Install Node.js -Use [fnm](https://github.com/Schniz/fnm) or [nvm](https://github.com/nvm-sh/nvm) to run the command below. This will switch to the Node.js version (currently 20) specified in the project's `.nvmrc` file. +Use [fnm](https://github.com/Schniz/fnm) or [nvm](https://github.com/nvm-sh/nvm) to run the command below. This will switch to the Node.js version (currently 18) specified in the project's `.nvmrc` file. ```bash # with fnm