postcss-load-config
Advanced tools
Comparing version
{ | ||
"name": "postcss-load-config", | ||
"version": "5.0.3", | ||
"version": "5.1.0", | ||
"description": "Autoload Config for PostCSS", | ||
@@ -24,8 +24,9 @@ "main": "src/index.js", | ||
"dependencies": { | ||
"lilconfig": "^3.0.0", | ||
"yaml": "^2.3.4" | ||
"lilconfig": "^3.1.1", | ||
"yaml": "^2.4.2" | ||
}, | ||
"peerDependencies": { | ||
"jiti": ">=1.21.0", | ||
"postcss": ">=8.0.9" | ||
"postcss": ">=8.0.9", | ||
"tsx": "^4.8.1" | ||
}, | ||
@@ -38,2 +39,5 @@ "peerDependenciesMeta": { | ||
"optional": true | ||
}, | ||
"tsx": { | ||
"optional": true | ||
} | ||
@@ -40,0 +44,0 @@ }, |
@@ -103,2 +103,5 @@ | ||
> [!NOTE] | ||
> For TypeScript configs, you must have [tsx](https://www.npmjs.com/package/tsx) or [jiti](https://www.npmjs.com/package/jiti) installed as a peer dependency. | ||
``` | ||
@@ -105,0 +108,0 @@ Project (Root) |
@@ -5,7 +5,10 @@ // @ts-check | ||
const TS_EXT_RE = /\.(c|m)?ts$/ | ||
const TS_EXT_RE = /\.[mc]?ts$/ | ||
/** @type {import('jiti').default | null} */ | ||
let jiti = null | ||
let tsx | ||
let jiti | ||
let importError | ||
/** | ||
@@ -26,16 +29,33 @@ * @param {string} name | ||
} | ||
if (!jiti) { | ||
try { | ||
jiti = (await import('jiti')).default | ||
} catch (jitiErr) { | ||
throw new Error( | ||
`'jiti' is required for the TypeScript configuration files. Make sure it is installed\nError: ${jitiErr.message}` | ||
) | ||
} | ||
if (tsx === undefined) { | ||
tsx = await import('tsx/cjs/api').catch(error => { | ||
importError = error | ||
}) | ||
} | ||
if (tsx) { | ||
let loaded = tsx.require(name, rootFile) | ||
return loaded && '__esModule' in loaded ? loaded.default : loaded | ||
} | ||
if (jiti === undefined) { | ||
jiti = await import('jiti').then( | ||
m => m.default, | ||
error => { | ||
importError = importError ?? error | ||
} | ||
/* c8 ignore stop */ | ||
} | ||
) | ||
} | ||
if (jiti) { | ||
return jiti(rootFile, { interopDefault: true })(name) | ||
} | ||
throw new Error( | ||
`'tsx' or 'jiti' is required for the TypeScript configuration files. Make sure it is installed\nError: ${importError.message}` | ||
) | ||
} | ||
module.exports = req |
22221
2.31%373
3.61%472
0.64%5
25%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
Updated
Updated