nestjs / nest-cli

CLI tool for Nest applications 🍹

Home Page:https://nestjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SWC builder output imports JSON files from outside the dist directory

andrucz opened this issue · comments

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Output imports JSON files from outside the dist directory:

"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
const _packagejson = require("../package.json");
async function bootstrap() {
    console.log('Version', _packagejson.version);
}
bootstrap();

Minimum reproduction code

https://gist.github.com/andrucz/d6b09ce51083f1c71b7d4b9c1f19ee29

Steps to reproduce

  1. Enable resolveJsonModule in tsconfig.json
  2. Enable SWC builder
  3. Add import { version } from '../package.json'; to main.ts
  4. Run npm run build
  5. Note that the imported JSON isn't copied to the dist directory

Expected behavior

SWC builder should copy the imported JSON to dist just like tsc does.

Package version

^10.0.0

NestJS version

^10.0.0

Node.js version

20

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

Please, report this issue in the swc repository