Skip to content

fix: import handling for ESM compatibility#3399

Merged
kamilmysliwiec merged 1 commit intonestjs:masterfrom
CatsMiaow:fix/esm-compatible
Apr 14, 2025
Merged

fix: import handling for ESM compatibility#3399
kamilmysliwiec merged 1 commit intonestjs:masterfrom
CatsMiaow:fix/esm-compatible

Conversation

@CatsMiaow
Copy link
Copy Markdown
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #3362
Fixing errors in the environment that were not tested in the previous PR.

  • ✅ commonjs
  • ✅ esm + swc
  • ❌ esm + tsc

What is the new behavior?

  • ✅ esm + tsc

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

The format of the output when building in swc and tsc is different.
swc converts require to import in the metadata, but tsc does not.

tsc

__decorate([
    Get('memo/:id'),
    openapi.ApiResponse({ status: 200, type: require("../entities/test/memo.entity.js").Memo }),
    __param(0, Param('id', ParseIntPipe)),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Number]),
    __metadata("design:returntype", Promise)
], SampleController.prototype, "read", null);

swc

_ts_decorate([
    Get('memo/:id'),
    _ts_param(0, Param('id', ParseIntPipe)),
    _ts_metadata("design:type", Function),
    _ts_metadata("design:paramtypes", [
        Number
    ]),
    _ts_metadata("design:returntype", Promise)
], SampleController.prototype, "read", null);

@kamilmysliwiec kamilmysliwiec merged commit 4ba111c into nestjs:master Apr 14, 2025
1 check passed
@kamilmysliwiec
Copy link
Copy Markdown
Member

LGTM

@CatsMiaow CatsMiaow deleted the fix/esm-compatible branch April 15, 2025 02:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants