Skip to content
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

Imprv/156177 159580 change pdf converter type to module #9520

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
9 changes: 9 additions & 0 deletions apps/pdf-converter/nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extensions": ["ts"],
"watch": ["src/**/*.ts"],
"ignore": ["node_modules/**/*"],
"delay": 100,
"execMap": {
"ts": "node --import @swc-node/register/esm-register"
Copy link
Contributor Author

@arafubeatbox arafubeatbox Dec 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dev での ts の実行に swc-node を使うように変更

}
}
38 changes: 21 additions & 17 deletions apps/pdf-converter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,32 @@
"types": "dist/index.d.ts",
"license": "MIT",
"private": true,
"type": "module",
"scripts": {
"dev:pdf-converter:ci": "ts-node -r \"dotenv-flow/config\" src/index.ts --ci",
"dev:pdf-converter": "nodemon --watch \"src/**/*.ts\" --ignore \"node_modules/**/*\" --exec ts-node -r \"dotenv-flow/config\" src/index.ts",
"dev:pdf-converter:ci": "node --import @swc-node/register/esm-register -r \"dotenv-flow/config\" src/index.ts --ci",
"dev:pdf-converter": "nodemon -r \"dotenv-flow/config\" src/index.ts",
"start:prod:ci": "pnpm start:prod --ci",
"start:prod": "node dist/index.js",
"lint": "pnpm eslint **/*.{js,ts}",
"gen:swagger-spec": "SWAGGER_GENERATION=true tsed run generate-swagger --output ./specs",
"gen:swagger-spec": "SWAGGER_GENERATION=true node --import @swc-node/register/esm-register src/bin/index.ts generate-swagger --output ./specs",
Copy link
Contributor Author

@arafubeatbox arafubeatbox Dec 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tsed run だとバグがあり、エラーが生じるようになってしまったが、内部実装を確認するとただのエイリアスコマンドであり、実行している内容は node --import @swc-node/register/esm-register src/bin/index.ts だったため、直接そちらを書くように変更。

@tsed/cli は依存するパッケージの量も多いため、generate-swagger のみを実行する場合、こちらの方が軽くて良さげ。

"build": "pnpm tsc -p tsconfig.build.json"
},
"dependencies": {
"@godaddy/terminus": "^4.12.1",
"@tsed/cli": "=5.4.3",
"@tsed/cli-core": "=5.4.3",
"@tsed/cli-generate-swagger": "=5.4.3",
"@tsed/common": "=7.84.1",
"@tsed/components-scan": "=7.84.1",
"@tsed/core": "=7.84.1",
"@tsed/di": "=7.84.1",
"@tsed/exceptions": "=7.84.1",
"@tsed/json-mapper": "=7.84.1",
"@tsed/platform-express": "=7.84.1",
"@tsed/schema": "=7.84.1",
"@tsed/swagger": "=7.84.1",
"@tsed/terminus": "=7.84.1",
"@tsed/cli-core": "=6.1.4",
"@tsed/cli-generate-swagger": "=6.1.4",
"@tsed/common": "=8.3.5",
"@tsed/components-scan": "=8.3.5",
"@tsed/core": "=8.3.5",
"@tsed/engines": "=8.3.5",
"@tsed/di": "=8.3.5",
"@tsed/exceptions": "=8.3.5",
"@tsed/json-mapper": "=8.3.5",
"@tsed/platform-express": "=8.3.5",
"@tsed/schema": "=8.3.5",
"@tsed/swagger": "=8.3.5",
"@tsed/terminus": "=8.3.5",
"@tsed/platform-http": "=8.3.5",
"axios": "^0.24.0",
"express": "^4.19.2",
"puppeteer": "^23.1.1",
Expand All @@ -39,6 +41,8 @@
"@types/connect": "^3.4.38",
"@types/express": "^4.17.21",
"@types/multer": "^1.4.12",
"@types/node": "^22.5.4"
"@types/node": "^22.5.4",
"@swc-node/register": "^1.10.9",
"@swc/core": "^1.9.2"
}
}
2 changes: 1 addition & 1 deletion apps/pdf-converter/src/bin/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CliCore } from '@tsed/cli-core';
import { GenerateSwaggerCmd } from '@tsed/cli-generate-swagger';

import Server from '../server';
import Server from '../server.js';

CliCore.bootstrap({
server: Server,
Expand Down
4 changes: 2 additions & 2 deletions apps/pdf-converter/src/controllers/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { default as PdfCtrl } from './pdf';
export { default as TerminusCtrl } from './terminus';
export { default as PdfCtrl } from './pdf.js';
export { default as TerminusCtrl } from './terminus.js';
2 changes: 1 addition & 1 deletion apps/pdf-converter/src/controllers/pdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
Post, Returns, Enum, Description,
} from '@tsed/schema';

import PdfConvertService, { JobStatusSharedWithGrowi, JobStatus } from '../service/pdf-convert';
import PdfConvertService, { JobStatusSharedWithGrowi, JobStatus } from '../service/pdf-convert.js';

@Controller('/pdf')
class PdfCtrl {
Expand Down
2 changes: 1 addition & 1 deletion apps/pdf-converter/src/controllers/terminus.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Logger } from '@tsed/common';
import { Inject, Injectable } from '@tsed/di';

import PdfConvertService from '../service/pdf-convert';
import PdfConvertService from '../service/pdf-convert.js';

@Injectable()
class TerminusCtrl {
Expand Down
2 changes: 1 addition & 1 deletion apps/pdf-converter/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { $log } from '@tsed/common';
import { PlatformExpress } from '@tsed/platform-express';

import Server from './server';
import Server from './server.js';

function hasProcessFlag(flag: string): boolean {
return process.argv.join('').indexOf(flag) > -1;
Expand Down
2 changes: 1 addition & 1 deletion apps/pdf-converter/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import express from 'express';
import '@tsed/swagger';
import '@tsed/terminus';

import * as Controllers from './controllers';
import * as Controllers from './controllers/index.js';

import '@tsed/platform-express';

Expand Down
4 changes: 0 additions & 4 deletions apps/pdf-converter/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"baseUrl": ".",
"outDir": "dist",
"declaration": true,
"target": "ES2020",
"lib": ["ES2020", "dom"],
"module": "commonjs",
"moduleResolution": "node",
"rootDir": "src",
"esModuleInterop": true,
"experimentalDecorators": true,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@changesets/cli": "^2.27.3",
"@faker-js/faker": "^9.0.1",
"@playwright/test": "^1.46.0",
"@swc-node/register": "^1.9.1",
"@swc-node/register": "^1.10.9",
"@swc/core": "^1.5.25",
"@swc/helpers": "^0.5.11",
"@types/css-modules": "^1.0.2",
Expand Down
Loading
Loading