Skip to content

Commit

Permalink
feat: postcss config .cts support (#14660)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red authored Oct 19, 2023
1 parent 6ebac4c commit e5ee420
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 4 deletions.
2 changes: 2 additions & 0 deletions docs/guide/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ If you'd like to temporarily ignore the warning, you can run your script with th
VITE_CJS_IGNORE_WARNING=true vite dev
```

Note that postcss config files does not support ESM + TypeScript (`.mts` or `.ts` in `"type": "module"`) yet. If you have postcss configs with `.ts` and added `"type": "module"` to package.json, you'll also need to rename the postcss config to use `.cts`.

## CLI

### `Error: Cannot find module 'C:\foo\bar&baz\vite\bin\vite.js'`
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@
"patchedDependencies": {
"[email protected]": "patches/[email protected]",
"[email protected]": "patches/[email protected]",
"[email protected]": "patches/[email protected]"
"[email protected]": "patches/[email protected]",
"[email protected]": "patches/[email protected]"
},
"peerDependencyRules": {
"allowedVersions": {
Expand Down
38 changes: 38 additions & 0 deletions patches/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
diff --git a/src/index.js b/src/index.js
index a7d16703a96a1229381beef905287192db332332..53a29ba20c7826caefc18bc0e786493a6ffcf978 100644
--- a/src/index.js
+++ b/src/index.js
@@ -85,10 +85,12 @@ const addTypeScriptLoader = (options = {}, loader) => {
`.${moduleName}rc.yaml`,
`.${moduleName}rc.yml`,
`.${moduleName}rc.ts`,
+ `.${moduleName}rc.cts`,
`.${moduleName}rc.js`,
`.${moduleName}rc.cjs`,
`.${moduleName}rc.mjs`,
`${moduleName}.config.ts`,
+ `${moduleName}.config.cts`,
`${moduleName}.config.js`,
`${moduleName}.config.cjs`,
`${moduleName}.config.mjs`
@@ -100,7 +102,8 @@ const addTypeScriptLoader = (options = {}, loader) => {
'.js': importDefault,
'.cjs': importDefault,
'.mjs': importDefault,
- '.ts': loader
+ '.ts': loader,
+ '.cts': loader
}
}
}
@@ -112,7 +115,9 @@ const withTypeScriptLoader = (rcFunc) => {

try {
// Register TypeScript compiler instance
- registerer = require('ts-node').register()
+ registerer = require('ts-node').register({
+ moduleTypes: { '**/*.cts': 'cjs' }
+ })

return require(configFile)
} catch (err) {
10 changes: 7 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e5ee420

Please sign in to comment.