You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Execute tsoa to generate routes/index.ts successfully.
When project is ESM project, run the app will receive error:
ReferenceError: require is not defined in ES module scope, you can use import instead
Context (Environment)
Version of the library: 5.0.0
Version of NodeJS: v18.12.0
Confirm you were using yarn not npm:
using yarn
Detailed Description
When I observe the same file (packages/cli/src/routeGeneration/templates/koa.hbs), most of requirements use import instead of require. Only useFileUploads has been ignored.
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
{{#ifcanImportByAlias}}
import { Controller, ValidationService, FieldErrors, ValidateError, TsoaRoute, HttpStatusCodeLiteral, TsoaResponse, fetchMiddlewares } from '@tsoa/runtime';
{{else}}
import { Controller, ValidationService, FieldErrors, ValidateError, TsoaRoute, TsoaResponse, HttpStatusCodeLiteral } from '../../../src';
{{/if}}{{#eachcontrollers}}
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
import { {{name}} } from '{{modulePath}}';
{{/each}}{{#ifauthenticationModule}}
import { koaAuthentication } from '{{authenticationModule}}';
// @ts-ignore - no great way to install types from subpackage
{{/if}}{{#ifiocModule}}
import { iocContainer } from '{{iocModule}}';
import type { IocContainer, IocContainerFactory } from '@tsoa/runtime';
{{/if}}
import type { Middleware } from 'koa';
import type * as KoaRouter from '@koa/router';
{{#ifuseFileUploads}}
const multer = require('@koa/multer'); // <------------------ THIS LINE
const upload = multer({{{jsonmulterOpts}}});
{{/if}}
Breaking change?
I think this change doesn't cause breaking change.
The text was updated successfully, but these errors were encountered:
Sorting
I'm submitting a ...
I confirm that I
Expected Behavior
The generated
src/routes/index.ts
still usesinstead of
Current Behavior
Run the unexpected
routes/index.ts
, and then throw the error:Possible Solution
packages/cli/src/routeGeneration/templates/koa.hbs
have to update the source fromto
Steps to Reproduce
tsoa.json
partial config below:@UploadedFile
in method of controller.tsoa
to generateroutes/index.ts
successfully.Context (Environment)
Version of the library:
5.0.0
Version of NodeJS:
v18.12.0
Detailed Description
When I observe the same file (
packages/cli/src/routeGeneration/templates/koa.hbs
), most of requirements useimport
instead ofrequire
. OnlyuseFileUploads
has been ignored.Breaking change?
I think this change doesn't cause breaking change.
The text was updated successfully, but these errors were encountered: