From 3042dabb1cc405ed7378bb4ae801f63110101347 Mon Sep 17 00:00:00 2001 From: Emerson Laurentino Date: Wed, 22 Jun 2022 18:26:47 -0300 Subject: [PATCH 01/11] feat: shared package --- packages/shared/package.json | 8 ++++++++ packages/shared/tsconfig.json | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 packages/shared/package.json create mode 100644 packages/shared/tsconfig.json diff --git a/packages/shared/package.json b/packages/shared/package.json new file mode 100644 index 0000000000..e9c5513d0b --- /dev/null +++ b/packages/shared/package.json @@ -0,0 +1,8 @@ +{ + "name": "shared", + "version": "0.0.0", + "private": true, + "files": [ + "tsconfig.json" + ] +} diff --git a/packages/shared/tsconfig.json b/packages/shared/tsconfig.json new file mode 100644 index 0000000000..54409274e8 --- /dev/null +++ b/packages/shared/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "declaration": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "importHelpers": true, + "jsx": "react", + "lib": ["dom", "esnext"], + "module": "esnext", + "moduleResolution": "node", + "noFallthroughCasesInSwitch": true, + "noImplicitReturns": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "skipLibCheck": true, + "sourceMap": true, + "strict": true, + "target": "esnext" + } +} From 35700f92dea68e973dc806d16789b89b61ac3b38 Mon Sep 17 00:00:00 2001 From: Emerson Laurentino Date: Wed, 22 Jun 2022 18:27:21 -0300 Subject: [PATCH 02/11] chore: using shared tsconfig --- packages/ui/package.json | 1 + packages/ui/tsconfig.json | 40 ++++++--------------------------------- 2 files changed, 7 insertions(+), 34 deletions(-) diff --git a/packages/ui/package.json b/packages/ui/package.json index f7b285fac0..e601218f26 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -80,6 +80,7 @@ "react": "^17.0.2", "react-docgen-typescript-loader": "^3.7.2", "react-dom": "^17.0.2", + "shared": "*", "size-limit": "^7.0.8", "storybook-addon-themes": "^6.1.0", "tsdx": "^0.14.1", diff --git a/packages/ui/tsconfig.json b/packages/ui/tsconfig.json index d395810f77..65d926d68a 100644 --- a/packages/ui/tsconfig.json +++ b/packages/ui/tsconfig.json @@ -1,41 +1,13 @@ { - // see https://www.typescriptlang.org/tsconfig to better understand tsconfigs - "include": ["src", "types"], + "extends": "shared/tsconfig.json", + "compilerOptions": { + "outDir": "dist" + }, + "include": ["src"], "exclude": [ "src/**/*.test.ts", "src/**/*.test.tsx", "src/**/*.stories.ts", "src/**/*.stories.tsx" - ], - "compilerOptions": { - "outDir": "dist", - "target": "esnext", - "module": "esnext", - "lib": ["dom", "esnext"], - "importHelpers": true, - // output .d.ts declaration files for consumers - "declaration": true, - // output .js.map sourcemap files for consumers - "sourceMap": true, - // match output dir to input dir. e.g. dist/index instead of dist/src/index - "rootDir": "./src", - // stricter type-checking for stronger correctness. Recommended by TS - "strict": true, - // linter checks for common issues - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, - // noUnused* overlap with @typescript-eslint/no-unused-vars, can disable if duplicate - "noUnusedLocals": true, - "noUnusedParameters": true, - // use Node's module resolution algorithm, instead of the legacy TS one - "moduleResolution": "node", - // transpile JSX to React.createElement - "jsx": "react", - // interop between ESM and CJS modules. Recommended by TS - "esModuleInterop": true, - // significant perf increase by skipping checking .d.ts files, particularly those in node_modules. Recommended by TS - "skipLibCheck": true, - // error out if import and file system have a casing mismatch. Recommended by TS - "forceConsistentCasingInFileNames": true - } + ] } From 32b19a3f7db10669b11cc55db75717ca3d8bee0e Mon Sep 17 00:00:00 2001 From: Emerson Laurentino Date: Wed, 22 Jun 2022 18:30:05 -0300 Subject: [PATCH 03/11] chore: sdk using shared tsconfig --- packages/sdk/package.json | 1 + packages/sdk/tsconfig.json | 43 +++++--------------------------------- 2 files changed, 6 insertions(+), 38 deletions(-) diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 45b4e25da9..45de13f9ca 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -41,6 +41,7 @@ "@testing-library/react-hooks": "^7.0.2", "fake-indexeddb": "^3.1.3", "react": "^17.0.2", + "shared": "*", "size-limit": "^7.0.8", "tsdx": "^0.14.1", "tslib": "^2.3.1", diff --git a/packages/sdk/tsconfig.json b/packages/sdk/tsconfig.json index d395810f77..0daaaf2906 100644 --- a/packages/sdk/tsconfig.json +++ b/packages/sdk/tsconfig.json @@ -1,41 +1,8 @@ { - // see https://www.typescriptlang.org/tsconfig to better understand tsconfigs - "include": ["src", "types"], - "exclude": [ - "src/**/*.test.ts", - "src/**/*.test.tsx", - "src/**/*.stories.ts", - "src/**/*.stories.tsx" - ], + "extends": "shared/tsconfig.json", "compilerOptions": { - "outDir": "dist", - "target": "esnext", - "module": "esnext", - "lib": ["dom", "esnext"], - "importHelpers": true, - // output .d.ts declaration files for consumers - "declaration": true, - // output .js.map sourcemap files for consumers - "sourceMap": true, - // match output dir to input dir. e.g. dist/index instead of dist/src/index - "rootDir": "./src", - // stricter type-checking for stronger correctness. Recommended by TS - "strict": true, - // linter checks for common issues - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, - // noUnused* overlap with @typescript-eslint/no-unused-vars, can disable if duplicate - "noUnusedLocals": true, - "noUnusedParameters": true, - // use Node's module resolution algorithm, instead of the legacy TS one - "moduleResolution": "node", - // transpile JSX to React.createElement - "jsx": "react", - // interop between ESM and CJS modules. Recommended by TS - "esModuleInterop": true, - // significant perf increase by skipping checking .d.ts files, particularly those in node_modules. Recommended by TS - "skipLibCheck": true, - // error out if import and file system have a casing mismatch. Recommended by TS - "forceConsistentCasingInFileNames": true - } + "outDir": "dist" + }, + "include": ["src"], + "exclude": ["test"] } From 119c66a6aed4d3b35efd8b0d768d60c34ed02bad Mon Sep 17 00:00:00 2001 From: Emerson Laurentino Date: Wed, 22 Jun 2022 18:34:00 -0300 Subject: [PATCH 04/11] chore: remove tsdx dependency from lighthouse --- yarn.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn.lock b/yarn.lock index 83f5621271..5505daded8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8461,7 +8461,7 @@ dependencies: postcss-cli "^8.3.1" -"@vtex/tsconfig@^0.5.0", "@vtex/tsconfig@^0.5.6": +"@vtex/tsconfig@^0.5.0": version "0.5.6" resolved "https://registry.yarnpkg.com/@vtex/tsconfig/-/tsconfig-0.5.6.tgz#c0eb4222a75d1b8a4fefb1d85bbd9349880ddbe5" integrity sha512-3pdtp0QiUjW3YqyA+2YPV3AsAJ68wHWELrg7JMlr7ULHNb4mUfmTBx31zbWG94K3OWp0KJFfF3ytQ+I68foqKA== From ccf3ed67c758877351a7e620890023062119de32 Mon Sep 17 00:00:00 2001 From: Emerson Laurentino Date: Wed, 22 Jun 2022 18:34:18 -0300 Subject: [PATCH 05/11] chore: lighthouse using shared tsconfig --- packages/lighthouse/package.json | 6 ++---- packages/lighthouse/tsconfig.json | 8 +++----- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/packages/lighthouse/package.json b/packages/lighthouse/package.json index 8d9b0a7097..efae19f2e4 100644 --- a/packages/lighthouse/package.json +++ b/packages/lighthouse/package.json @@ -21,12 +21,10 @@ "scripts": { "develop": "tsc --watch", "build": "tsc", - "lint": "eslint src/**/*.ts", - "test": "tsdx test --passWithNoTests" + "lint": "eslint src/**/*.ts" }, "devDependencies": { - "@vtex/tsconfig": "^0.5.6", - "tsdx": "^0.14.1", + "shared": "*", "typescript": "^4.2.4" } } diff --git a/packages/lighthouse/tsconfig.json b/packages/lighthouse/tsconfig.json index 9822d227ab..74f834ce09 100644 --- a/packages/lighthouse/tsconfig.json +++ b/packages/lighthouse/tsconfig.json @@ -1,9 +1,7 @@ { - "extends": "@vtex/tsconfig", - "include": ["src"], - "exclude": ["node_modules", "dist"], + "extends": "shared/tsconfig.json", "compilerOptions": { - "module": "commonjs", "outDir": "dist" - } + }, + "include": ["src"] } From 7d3c7f4719725c132973b8b98b96c9fc7fb75e7c Mon Sep 17 00:00:00 2001 From: Emerson Laurentino Date: Wed, 22 Jun 2022 18:41:43 -0300 Subject: [PATCH 06/11] chore: graphql utils using shared tsconfig --- packages/graphql-utils/package.json | 1 + packages/graphql-utils/tsconfig.json | 69 +--------------------------- 2 files changed, 3 insertions(+), 67 deletions(-) diff --git a/packages/graphql-utils/package.json b/packages/graphql-utils/package.json index 7782e4c82d..5c00709d6b 100644 --- a/packages/graphql-utils/package.json +++ b/packages/graphql-utils/package.json @@ -22,6 +22,7 @@ }, "devDependencies": { "cross-env": "^7.0.2", + "shared": "*", "typescript": "^4.2.4" }, "dependencies": { diff --git a/packages/graphql-utils/tsconfig.json b/packages/graphql-utils/tsconfig.json index 8559e8353b..087c12620d 100644 --- a/packages/graphql-utils/tsconfig.json +++ b/packages/graphql-utils/tsconfig.json @@ -1,71 +1,6 @@ { + "extends": "shared/tsconfig.json", "compilerOptions": { - /* Visit https://aka.ms/tsconfig.json to read more about this file */ - - /* Basic Options */ - // "incremental": true, /* Enable incremental compilation */ - "target": "ESNext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */, - "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */, - // "lib": [], /* Specify library files to be included in the compilation. */ - // "allowJs": true, /* Allow javascript files to be compiled. */ - // "checkJs": true, /* Report errors in .js files. */ - // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */ - "declaration": true /* Generates corresponding '.d.ts' file. */, - // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ - // "sourceMap": true, /* Generates corresponding '.map' file. */ - // "outFile": "./", /* Concatenate and emit output to single file. */ - "outDir": "dist" /* Redirect output structure to the directory. */, - "rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */, - // "composite": true, /* Enable project compilation */ - // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ - // "removeComments": true, /* Do not emit comments to output. */ - // "noEmit": true, /* Do not emit outputs. */ - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ - // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ - - /* Strict Type-Checking Options */ - "strict": true /* Enable all strict type-checking options. */, - "noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */, - "strictNullChecks": true /* Enable strict null checks. */, - "strictFunctionTypes": true /* Enable strict checking of function types. */, - "strictBindCallApply": true /* Enable strict 'bind', 'call', and 'apply' methods on functions. */, - "strictPropertyInitialization": true /* Enable strict checking of property initialization in classes. */, - "noImplicitThis": true /* Raise error on 'this' expressions with an implied 'any' type. */, - "alwaysStrict": true /* Parse in strict mode and emit "use strict" for each source file. */, - - /* Additional Checks */ - "noUnusedLocals": true /* Report errors on unused locals. */, - "noUnusedParameters": true /* Report errors on unused parameters. */, - "noImplicitReturns": true /* Report error when not all code paths in function return a value. */, - "noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */, - "noUncheckedIndexedAccess": true /* Include 'undefined' in index signature results */, - "noPropertyAccessFromIndexSignature": true /* Require undeclared properties from index signatures to use element accesses. */, - - /* Module Resolution Options */ - "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */, - // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ - // "typeRoots": [], /* List of folders to include type definitions from. */ - // "types": [], /* Type declaration files to be included in compilation. */ - "allowSyntheticDefaultImports": true /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */, - "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, - // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - - /* Source Map Options */ - // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ - // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ - - /* Experimental Options */ - // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ - // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ - - /* Advanced Options */ - "skipLibCheck": true /* Skip type checking of declaration files. */, - "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ + "outDir": "dist" } } From a90d671b3797b0a866dbc0bd0b1cb07bdadca558 Mon Sep 17 00:00:00 2001 From: Emerson Laurentino Date: Wed, 22 Jun 2022 18:46:09 -0300 Subject: [PATCH 07/11] chore: api using shared tsconfig --- packages/api/package.json | 1 + packages/api/tsconfig.json | 32 ++------------------------------ 2 files changed, 3 insertions(+), 30 deletions(-) diff --git a/packages/api/package.json b/packages/api/package.json index 6c2973254a..1f8df0ec99 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -37,6 +37,7 @@ "express-graphql": "^0.12.0", "graphql": "^15.6.0", "jest-transform-graphql": "^2.1.0", + "shared": "*", "ts-jest": "25.5.1", "tsdx": "^0.14.1", "tslib": "^2.3.1", diff --git a/packages/api/tsconfig.json b/packages/api/tsconfig.json index 9f53d94548..087c12620d 100644 --- a/packages/api/tsconfig.json +++ b/packages/api/tsconfig.json @@ -1,34 +1,6 @@ { - // see https://www.typescriptlang.org/tsconfig to better understand tsconfigs - "include": ["src", "types"], + "extends": "shared/tsconfig.json", "compilerOptions": { - "outDir": "dist", - "module": "esnext", - "lib": ["dom", "esnext"], - "importHelpers": true, - // output .d.ts declaration files for consumers - "declaration": true, - // output .js.map sourcemap files for consumers - "sourceMap": true, - // match output dir to input dir. e.g. dist/index instead of dist/src/index - "rootDir": "./src", - // stricter type-checking for stronger correctness. Recommended by TS - "strict": true, - // linter checks for common issues - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, - // noUnused* overlap with @typescript-eslint/no-unused-vars, can disable if duplicate - "noUnusedLocals": true, - "noUnusedParameters": true, - // use Node's module resolution algorithm, instead of the legacy TS one - "moduleResolution": "node", - // transpile JSX to React.createElement - "jsx": "react", - // interop between ESM and CJS modules. Recommended by TS - "esModuleInterop": true, - // significant perf increase by skipping checking .d.ts files, particularly those in node_modules. Recommended by TS - "skipLibCheck": true, - // error out if import and file system have a casing mismatch. Recommended by TS - "forceConsistentCasingInFileNames": true + "outDir": "dist" } } From 69cb1491128a6acb80c4c1910e0037a101b76bd6 Mon Sep 17 00:00:00 2001 From: Emerson Laurentino Date: Wed, 22 Jun 2022 18:55:28 -0300 Subject: [PATCH 08/11] fix: tsconfig include --- packages/api/tsconfig.json | 3 ++- packages/graphql-utils/tsconfig.json | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/api/tsconfig.json b/packages/api/tsconfig.json index 087c12620d..74f834ce09 100644 --- a/packages/api/tsconfig.json +++ b/packages/api/tsconfig.json @@ -2,5 +2,6 @@ "extends": "shared/tsconfig.json", "compilerOptions": { "outDir": "dist" - } + }, + "include": ["src"] } diff --git a/packages/graphql-utils/tsconfig.json b/packages/graphql-utils/tsconfig.json index 087c12620d..74f834ce09 100644 --- a/packages/graphql-utils/tsconfig.json +++ b/packages/graphql-utils/tsconfig.json @@ -2,5 +2,6 @@ "extends": "shared/tsconfig.json", "compilerOptions": { "outDir": "dist" - } + }, + "include": ["src"] } From 52df623bcace0bab75c71ae6f10dbf76142f2430 Mon Sep 17 00:00:00 2001 From: Emerson Laurentino Date: Wed, 22 Jun 2022 18:57:45 -0300 Subject: [PATCH 09/11] fix: remoove exclude from sdk tsconfig --- packages/sdk/tsconfig.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/sdk/tsconfig.json b/packages/sdk/tsconfig.json index 0daaaf2906..74f834ce09 100644 --- a/packages/sdk/tsconfig.json +++ b/packages/sdk/tsconfig.json @@ -3,6 +3,5 @@ "compilerOptions": { "outDir": "dist" }, - "include": ["src"], - "exclude": ["test"] + "include": ["src"] } From a27c42a90748b6eeeb5d350956c5b43469403e2d Mon Sep 17 00:00:00 2001 From: Emerson Laurentino Date: Wed, 22 Jun 2022 19:07:15 -0300 Subject: [PATCH 10/11] fix: remove shared package from build at codesandbox --- .codesandbox/ci.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.codesandbox/ci.json b/.codesandbox/ci.json index 81813ecee0..caf7ba1bcd 100644 --- a/.codesandbox/ci.json +++ b/.codesandbox/ci.json @@ -1,5 +1,5 @@ { - "buildCommand": "turbo run build --filter=./packages/*", + "buildCommand": "turbo run build --filter=./packages/* --filter=!./packages/shared", "packages": ["packages/*"], "sandboxes": ["store-ui-typescript-0gd9u"], "node": "16" From d8092020a6224ed7e3341617f311675334b52f75 Mon Sep 17 00:00:00 2001 From: Emerson Laurentino Date: Wed, 22 Jun 2022 19:12:58 -0300 Subject: [PATCH 11/11] fix: remove shared package from publish at codesandbox --- .codesandbox/ci.json | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.codesandbox/ci.json b/.codesandbox/ci.json index caf7ba1bcd..c67320c0da 100644 --- a/.codesandbox/ci.json +++ b/.codesandbox/ci.json @@ -1,6 +1,13 @@ { "buildCommand": "turbo run build --filter=./packages/* --filter=!./packages/shared", - "packages": ["packages/*"], + "packages": [ + "packages/api", + "packages/graphql-utils", + "packages/lighthouse", + "packages/sdk", + "packages/styles", + "packages/ui" + ], "sandboxes": ["store-ui-typescript-0gd9u"], "node": "16" }