Explorar el Código

exclude vendor-styles files from TypeScript compilation and add ts-nocheck directive to prebuilt JS files

Yuki Takei hace 1 mes
padre
commit
bbb04d777c
Se han modificado 2 ficheros con 11 adiciones y 6 borrados
  1. 4 0
      apps/app/tsconfig.json
  2. 7 6
      apps/app/vite.vendor-styles-components.ts

+ 4 - 0
apps/app/tsconfig.json

@@ -27,6 +27,10 @@
     ]
     ]
   },
   },
   "include": ["next-env.d.ts", "config", "src"],
   "include": ["next-env.d.ts", "config", "src"],
+  "exclude": [
+    "src/**/*.vendor-styles.ts",
+    "src/**/*.vendor-styles.prebuilt.js"
+  ],
   "ts-node": {
   "ts-node": {
     "transpileOnly": true,
     "transpileOnly": true,
     "swc": true,
     "swc": true,

+ 7 - 6
apps/app/vite.vendor-styles-components.ts

@@ -34,19 +34,20 @@ function moveAssetsToPublic(): Plugin {
       }
       }
       fs.rmdirSync(srcDir);
       fs.rmdirSync(srcDir);
 
 
-      // Rewrite /assets/ -> /static/fonts/ in prebuilt JS files
+      // Rewrite /assets/ -> /static/fonts/ and prepend // @ts-nocheck in prebuilt JS files
       const prebuiltFiles = fs.globSync('src/**/*.vendor-styles.prebuilt.js', {
       const prebuiltFiles = fs.globSync('src/**/*.vendor-styles.prebuilt.js', {
         cwd: __dirname,
         cwd: __dirname,
       });
       });
       for (const file of prebuiltFiles) {
       for (const file of prebuiltFiles) {
         const filePath = path.resolve(__dirname, file);
         const filePath = path.resolve(__dirname, file);
-        const content = fs.readFileSync(filePath, 'utf-8');
+        let content = fs.readFileSync(filePath, 'utf-8');
         if (content.includes('/assets/')) {
         if (content.includes('/assets/')) {
-          fs.writeFileSync(
-            filePath,
-            content.replaceAll('/assets/', '/static/fonts/'),
-          );
+          content = content.replaceAll('/assets/', '/static/fonts/');
         }
         }
+        if (!content.startsWith('// @ts-nocheck')) {
+          content = `// @ts-nocheck\n${content}`;
+        }
+        fs.writeFileSync(filePath, content);
       }
       }
     },
     },
   };
   };