Skip to content

Commit

Permalink
feat: use shared-types instead of files
Browse files Browse the repository at this point in the history
  • Loading branch information
Aqours committed Aug 10, 2023
1 parent afb0680 commit 6ad6e66
Show file tree
Hide file tree
Showing 15 changed files with 1,785 additions and 1,688 deletions.
2 changes: 2 additions & 0 deletions helpers/shared-types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/// <reference path="lib/debug.d.ts" />
/// <reference path="lib/webpack.d.ts" />
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions helpers/shared-types/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "@types/shared-types",
"version": "1.0.0",
"private": true,
"types": "index.d.ts",
"description": "Shared Types for Project",
"keywords": [],
"author": "Hellcom",
"license": "ISC"
}
6 changes: 3 additions & 3 deletions helpers/webpack-config/lib/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class BaseDefaultConfig {
};
}

static getEnvProxy(_env): Record<string, any> {
static getEnvProxy(_env: any): Record<string, any> {
return new Proxy(BaseDefaultConfig.env, {
get(target, key, receiver) {
if (_env[key] != null) return _env[key];
Expand All @@ -31,7 +31,7 @@ export default class BaseDefaultConfig {
});
}

static getArgvProxy(_argv): Record<string, any> {
static getArgvProxy(_argv: any): Record<string, any> {
return new Proxy(BaseDefaultConfig.argv, {
get(target, key, receiver) {
if (_argv[key] != null) return _argv[key];
Expand All @@ -46,7 +46,7 @@ export default class BaseDefaultConfig {
protected readonly _projectName: string;
protected readonly _lastCompiled: string;

constructor(_env = Object.create(null), _argv = Object.create(null), projectName = null) {
constructor(_env = Object.create(null), _argv = Object.create(null), projectName: string = null) {
this._envProxy = BaseDefaultConfig.getEnvProxy(_env);
this._argvProxy = BaseDefaultConfig.getArgvProxy(_argv);
this._manifest = JSON.parse(fs.readFileSync(path.resolve(process.cwd(), 'package.json'), { encoding: 'utf8' }));
Expand Down
82 changes: 40 additions & 42 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"husky:commit-msg": "commitlint --edit ${1}",
"test": "pnpm run eslint && pnpm run tscheck",
"eslint": "eslint '**/*.{js,jsx,ts,tsx}' --quiet",
"tscheck": "tsc --noEmit"
"tscheck": "pnpm -r --parallel exec tsc --noEmit",
"tscheck:whole": "tsc --noEmit"
},
"repository": {
"type": "git",
Expand All @@ -34,63 +35,60 @@
},
"devDependencies": {
"@apex/webpack-config": "workspace:*",
"@babel/cli": "7.21.0",
"@babel/core": "7.21.4",
"@babel/preset-env": "7.21.4",
"@babel/runtime": "7.21.0",
"@changesets/cli": "2.26.1",
"@commitlint/cli": "17.6.1",
"@commitlint/config-conventional": "17.6.1",
"@babel/cli": "7.22.10",
"@babel/core": "7.22.10",
"@babel/preset-env": "7.22.10",
"@babel/runtime": "7.22.10",
"@changesets/cli": "2.26.2",
"@commitlint/cli": "17.7.0",
"@commitlint/config-conventional": "17.7.0",
"@types/event-hooks-webpack-plugin": "2.2.2",
"@types/events": "3.0.0",
"@types/git-rev-sync": "2.0.0",
"@types/node": "18.15.11",
"@types/react": "18.0.37",
"@types/react-dom": "18.0.11",
"@types/node": "20.4.9",
"@types/rimraf": "3.0.2",
"@types/shared-types": "workspace:*",
"@types/terser-webpack-plugin": "5.0.4",
"@types/webpack-bundle-analyzer": "4.6.0",
"@typescript-eslint/eslint-plugin": "5.59.0",
"@typescript-eslint/parser": "5.59.0",
"@typescript-eslint/eslint-plugin": "6.3.0",
"@typescript-eslint/parser": "6.3.0",
"autoprefixer": "10.4.14",
"babel-loader": "9.1.2",
"babel-loader": "9.1.3",
"ci-info": "3.8.0",
"cross-env": "7.0.3",
"css-loader": "6.7.3",
"cssnano": "6.0.0",
"dotenv": "16.0.3",
"esbuild-loader": "3.0.1",
"eslint": "8.38.0",
"eslint-config-prettier": "8.8.0",
"css-loader": "6.8.1",
"cssnano": "6.0.1",
"dotenv": "16.3.1",
"esbuild-loader": "4.0.0",
"eslint": "8.46.0",
"eslint-config-prettier": "9.0.0",
"event-hooks-webpack-plugin": "2.3.0",
"git-rev-sync": "3.0.2",
"husky": "8.0.3",
"less": "4.1.3",
"less-loader": "11.1.0",
"moment": "2.29.4",
"npm-check-updates": "16.10.8",
"postcss": "8.4.22",
"postcss-custom-properties": "13.1.5",
"postcss-loader": "7.2.4",
"postcss-preset-env": "8.3.2",
"prettier": "2.8.7",
"less": "4.2.0",
"less-loader": "11.1.3",
"npm-check-updates": "16.10.18",
"postcss": "8.4.27",
"postcss-custom-properties": "13.3.0",
"postcss-loader": "7.3.3",
"postcss-preset-env": "9.1.1",
"prettier": "2.8.8",
"pretty-quick": "3.1.3",
"rimraf": "5.0.0",
"semver": "7.5.0",
"style-loader": "3.3.2",
"rimraf": "5.0.1",
"semver": "7.5.4",
"style-loader": "3.3.3",
"svg-inline-loader": "0.8.2",
"svgo": "3.0.2",
"svgo-loader": "4.0.0",
"terser-webpack-plugin": "5.3.7",
"ts-loader": "9.4.2",
"terser-webpack-plugin": "5.3.9",
"ts-loader": "9.4.4",
"ts-node": "10.9.1",
"tslib": "2.5.0",
"typescript": "5.0.4",
"webpack": "5.79.0",
"webpack-bundle-analyzer": "4.8.0",
"webpack-cli": "5.0.1",
"webpack-dev-server": "4.13.3",
"webpack-merge": "5.8.0",
"tslib": "2.6.1",
"typescript": "5.1.6",
"webpack": "5.88.2",
"webpack-bundle-analyzer": "4.9.0",
"webpack-cli": "5.1.4",
"webpack-dev-server": "4.15.1",
"webpack-merge": "5.9.0",
"webpack-retry-chunk-load-plugin": "3.1.1",
"webpackbar": "5.0.2"
}
Expand Down
1 change: 1 addition & 0 deletions packages/js-project/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export function noop() {}
9 changes: 9 additions & 0 deletions packages/js-project/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "@apex/js-project",
"version": "1.0.0",
"description": "Fake JavaScript Project without Types",
"main": "index.js",
"keywords": [],
"author": "Hellcom",
"license": "ISC"
}
4 changes: 4 additions & 0 deletions packages/react-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@
"mobx-react-lite": "3.4.3",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@types/react": "18.2.20",
"@types/react-dom": "18.2.7"
}
}
3 changes: 0 additions & 3 deletions packages/react-demo/types.d.ts

This file was deleted.

4 changes: 0 additions & 4 deletions packages/vue-demo/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
declare module '*.svg' {
export default string;
}

declare module '*.vue' {
import { DefineComponent } from 'vue';
const component: DefineComponent<unknown, unknown, unknown>;
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-demo/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default getWebpackConfig('vue-demo', function (env, argv, config) {
plugins: [basePlugin.webpackBar, basePlugin.bannerPlugin, basePlugin.definePlugin, new VueLoaderPlugin()],
output: {
// @see https://github.com/vuejs/vue-cli/issues/2978#issuecomment-1204992527
devtoolModuleFilenameTemplate: (info) => {
devtoolModuleFilenameTemplate: (info: any) => {
const resPath = info.resourcePath.split(path.sep).join('/');
const isVue = resPath.match(/\.vue$/);
const isGenerated = info.allLoaders;
Expand Down
Loading

0 comments on commit 6ad6e66

Please sign in to comment.