From 90cba4d396ad7e4271e8e20d0050d3b95c5cadb5 Mon Sep 17 00:00:00 2001 From: olivermrbl Date: Tue, 24 Sep 2024 09:06:28 +0200 Subject: [PATCH] chore: Convert plugin to use tsc build tooling --- .changeset/fuzzy-tools-report.md | 5 ++++ .../.babelrc.js | 12 -------- .../package.json | 11 +++----- .../tsconfig.json | 28 ++++++++++++++----- yarn.lock | 9 ++---- 5 files changed, 33 insertions(+), 32 deletions(-) create mode 100644 .changeset/fuzzy-tools-report.md delete mode 100644 packages/medusa-plugin-restock-notification/.babelrc.js diff --git a/.changeset/fuzzy-tools-report.md b/.changeset/fuzzy-tools-report.md new file mode 100644 index 0000000000000..adab2fb8e4af9 --- /dev/null +++ b/.changeset/fuzzy-tools-report.md @@ -0,0 +1,5 @@ +--- +"medusa-plugin-restock-notification": patch +--- + +chore: Convert plugin to use tsc diff --git a/packages/medusa-plugin-restock-notification/.babelrc.js b/packages/medusa-plugin-restock-notification/.babelrc.js deleted file mode 100644 index ae10f028d4bb1..0000000000000 --- a/packages/medusa-plugin-restock-notification/.babelrc.js +++ /dev/null @@ -1,12 +0,0 @@ -let ignore = [`**/dist`] - -// Jest needs to compile this code, but generally we don't want this copied -// to output folders -if (process.env.NODE_ENV !== `test`) { - ignore.push(`**/__tests__`) -} - -module.exports = { - presets: [["babel-preset-medusa-package"], ["@babel/preset-typescript"]], - ignore, -} diff --git a/packages/medusa-plugin-restock-notification/package.json b/packages/medusa-plugin-restock-notification/package.json index 1758d3b0b36b3..b0d4e8865333f 100644 --- a/packages/medusa-plugin-restock-notification/package.json +++ b/packages/medusa-plugin-restock-notification/package.json @@ -13,25 +13,22 @@ "author": "Sebastian Rindom ", "license": "MIT", "devDependencies": { - "@babel/cli": "^7.7.5", - "@babel/core": "^7.7.5", - "@babel/plugin-transform-typescript": "^7.13.0", - "@babel/preset-typescript": "^7.12.7", "@medusajs/medusa": "^1.20.8", - "babel-preset-medusa-package": "^1.1.20", "cross-env": "^5.2.1", "jest": "^25.5.4", "medusa-interfaces": "^1.3.10", "medusa-test-utils": "^1.1.45", "pg": "^8.5.1", + "rimraf": "^5.0.1", "typeorm": "^0.3.16", + "typescript": "^4.9.5", "ulid": "^2.3.0" }, "scripts": { "prepare": "cross-env NODE_ENV=production yarn run build", "test": "jest --silent --bail --maxWorkers=50% --forceExit", - "build": "babel src --out-dir . --ignore '**/__tests__','**/__mocks__'", - "watch": "babel -w src --out-dir . --ignore '**/__tests__','**/__mocks__'" + "build": "rimraf dist && tsc", + "watch": "tsc --watch" }, "peerDependencies": { "@medusajs/medusa": "^1.12.0", diff --git a/packages/medusa-plugin-restock-notification/tsconfig.json b/packages/medusa-plugin-restock-notification/tsconfig.json index 958846589c4e5..18d21d0f61e40 100644 --- a/packages/medusa-plugin-restock-notification/tsconfig.json +++ b/packages/medusa-plugin-restock-notification/tsconfig.json @@ -1,15 +1,29 @@ { "compilerOptions": { - "lib": [ - "es5", - "es6" - ], - "target": "es5", + "lib": ["es2020"], + "target": "es2020", + "outDir": "./dist", "esModuleInterop": true, + "declaration": true, "module": "commonjs", "moduleResolution": "node", "emitDecoratorMetadata": true, "experimentalDecorators": true, - "sourceMap": true - } + "sourceMap": true, + "noImplicitReturns": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "noImplicitThis": true, + "allowJs": true, + "skipLibCheck": true, + "downlevelIteration": true // to use ES5 specific tooling + }, + "include": ["src"], + "exclude": [ + "dist", + "src/**/__tests__", + "src/**/__mocks__", + "src/**/__fixtures__", + "node_modules" + ] } diff --git a/yarn.lock b/yarn.lock index 76450a0661f60..bcc3b2b10ad41 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3997,7 +3997,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-typescript@npm:^7.13.0, @babel/plugin-transform-typescript@npm:^7.18.6, @babel/plugin-transform-typescript@npm:^7.22.5": +"@babel/plugin-transform-typescript@npm:^7.18.6, @babel/plugin-transform-typescript@npm:^7.22.5": version: 7.22.5 resolution: "@babel/plugin-transform-typescript@npm:7.22.5" dependencies: @@ -39446,12 +39446,7 @@ __metadata: version: 0.0.0-use.local resolution: "medusa-plugin-restock-notification@workspace:packages/medusa-plugin-restock-notification" dependencies: - "@babel/cli": ^7.7.5 - "@babel/core": ^7.7.5 - "@babel/plugin-transform-typescript": ^7.13.0 - "@babel/preset-typescript": ^7.12.7 "@medusajs/medusa": ^1.20.8 - babel-preset-medusa-package: ^1.1.20 body-parser: ^1.19.0 cors: ^2.8.5 cross-env: ^5.2.1 @@ -39461,7 +39456,9 @@ __metadata: medusa-interfaces: ^1.3.10 medusa-test-utils: ^1.1.45 pg: ^8.5.1 + rimraf: ^5.0.1 typeorm: ^0.3.16 + typescript: ^4.9.5 ulid: ^2.3.0 peerDependencies: "@medusajs/medusa": ^1.12.0