feat: scaffold Astro + Tailwind project
This commit is contained in:
21
node_modules/get-tsconfig/LICENSE
generated
vendored
Normal file
21
node_modules/get-tsconfig/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Hiroki Osame <hiroki.osame@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
263
node_modules/get-tsconfig/README.md
generated
vendored
Normal file
263
node_modules/get-tsconfig/README.md
generated
vendored
Normal file
@@ -0,0 +1,263 @@
|
||||
<p align="center">
|
||||
<img width="160" src=".github/logo.webp">
|
||||
</p>
|
||||
<h1 align="center">
|
||||
<sup>get-tsconfig</sup>
|
||||
<br>
|
||||
<a href="https://npm.im/get-tsconfig"><img src="https://badgen.net/npm/v/get-tsconfig"></a> <a href="https://npm.im/get-tsconfig"><img src="https://badgen.net/npm/dm/get-tsconfig"></a>
|
||||
</h1>
|
||||
|
||||
Find and parse `tsconfig.json` files.
|
||||
|
||||
## Features
|
||||
- Tiny! `9 kB` Minified + Gzipped
|
||||
- Tested against TypeScript for correctness
|
||||
- Resolves [`extends`](https://www.typescriptlang.org/tsconfig/#extends)
|
||||
- Fully typed `tsconfig.json`
|
||||
- Validates and throws parsing errors
|
||||
|
||||
<br>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/sponsors/privatenumber/sponsorships?tier_id=398771"><img width="412" src="https://raw.githubusercontent.com/privatenumber/sponsors/master/banners/assets/donate.webp"></a>
|
||||
<a href="https://github.com/sponsors/privatenumber/sponsorships?tier_id=397608"><img width="412" src="https://raw.githubusercontent.com/privatenumber/sponsors/master/banners/assets/sponsor.webp"></a>
|
||||
</p>
|
||||
<p align="center"><sup><i>Already a sponsor?</i> Join the discussion in the <a href="https://github.com/pvtnbr/get-tsconfig">Development repo</a>!</sup></p>
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
npm install get-tsconfig
|
||||
```
|
||||
|
||||
## Why?
|
||||
|
||||
TypeScript tooling (bundlers, linters, loaders, test runners) needs to read `tsconfig.json` to understand compiler options, path aliases, and file inclusion rules. But TypeScript's own config parser is buried inside the compiler and requires TypeScript as a dependency.
|
||||
|
||||
`get-tsconfig` provides the same functionality as a lightweight, standalone library — tested against TypeScript for correctness.
|
||||
|
||||
## Quick start
|
||||
|
||||
```ts
|
||||
import { getTsconfig, isFileIncluded, resolvePathAlias } from 'get-tsconfig'
|
||||
|
||||
// Find and parse the nearest tsconfig.json
|
||||
const tsconfig = getTsconfig()
|
||||
|
||||
// To resolve path aliases (compilerOptions.paths):
|
||||
if (tsconfig) {
|
||||
const resolved = resolvePathAlias(tsconfig, '@/utils/helper')
|
||||
// → ['/project/src/utils/helper']
|
||||
}
|
||||
|
||||
// To check if a file belongs to this tsconfig:
|
||||
if (tsconfig && isFileIncluded(tsconfig, '/project/src/index.ts')) {
|
||||
// Use tsconfig.config.compilerOptions for transformation
|
||||
}
|
||||
```
|
||||
|
||||
## Finding & reading tsconfig
|
||||
|
||||
These functions find, read, and parse tsconfig files from the filesystem. All return a `TsconfigResult`:
|
||||
|
||||
```ts
|
||||
type TsconfigResult<Config = TsconfigJsonResolved> = {
|
||||
path: string
|
||||
config: Config
|
||||
sources: string[]
|
||||
}
|
||||
```
|
||||
|
||||
- **path**: absolute path to the tsconfig file
|
||||
- **config**: the fully resolved config (extends merged, options normalized)
|
||||
- **sources**: paths of all tsconfig files that contributed to the resolved config via [`extends`](https://www.typescriptlang.org/tsconfig/#extends). When there are no `extends`, this is just `[path]`. Since `extends` can be an array, the order does not imply a linear chain.
|
||||
|
||||
### getTsconfig(searchPath?, options?)
|
||||
|
||||
Searches for a tsconfig file and parses it. If you already know the path, use [`readTsconfig`](#readtsconfigtsconfigpath-options) instead. Returns `undefined` if not found.
|
||||
|
||||
#### searchPath
|
||||
Type: `string`
|
||||
|
||||
Default: `process.cwd()`
|
||||
|
||||
Path to a file or directory. The directory tree is searched up for `tsconfig.json`.
|
||||
|
||||
#### options
|
||||
Type: `GetTsconfigOptions`
|
||||
|
||||
```ts
|
||||
type GetTsconfigOptions = {
|
||||
configName?: string // default: 'tsconfig.json'
|
||||
cache?: Map<string, unknown>
|
||||
includes?: boolean // default: false
|
||||
}
|
||||
```
|
||||
|
||||
- **configName**: file name to search for (e.g. `'jsconfig.json'`)
|
||||
- **cache**: snapshot cache for fs operations. Reusing after filesystem changes can return stale results.
|
||||
- **includes**: when `true`, validates the file is a root file (matched by `include`/`files` globs, not excluded) before accepting the tsconfig. Matches VS Code's Language Server behavior. Default matches `tsc` CLI behavior (nearest tsconfig). Note: this checks glob matching only — a file can still be part of a TypeScript program via transitive imports even if not matched by `include`.
|
||||
|
||||
#### Example
|
||||
|
||||
```ts
|
||||
import { getTsconfig } from 'get-tsconfig'
|
||||
|
||||
// Find from current directory
|
||||
getTsconfig()
|
||||
|
||||
// Find from a file path
|
||||
getTsconfig('./src/index.ts')
|
||||
|
||||
// Search for jsconfig.json
|
||||
getTsconfig('.', { configName: 'jsconfig.json' })
|
||||
|
||||
// Language Server behavior — validate the file is included
|
||||
getTsconfig('./src/index.ts', { includes: true })
|
||||
```
|
||||
|
||||
### findTsconfig(searchPath?, options?)
|
||||
|
||||
Like `getTsconfig`, but returns only the path (`string | undefined`) without parsing. Same options.
|
||||
|
||||
```ts
|
||||
import { findTsconfig } from 'get-tsconfig'
|
||||
|
||||
findTsconfig() // → '/project/tsconfig.json'
|
||||
```
|
||||
|
||||
### readTsconfig(tsconfigPath, options?)
|
||||
|
||||
Reads and resolves a tsconfig at a known path. Used internally by `getTsconfig`.
|
||||
|
||||
```ts
|
||||
type ReadTsconfigOptions = {
|
||||
cache?: Map<string, unknown>
|
||||
}
|
||||
```
|
||||
|
||||
```ts
|
||||
import { readTsconfig } from 'get-tsconfig'
|
||||
|
||||
const { path, config } = readTsconfig('./tsconfig.json')
|
||||
```
|
||||
|
||||
## Tsconfig `extends`
|
||||
|
||||
`readTsconfig` and `getTsconfig` fully resolve the [`extends`](https://www.typescriptlang.org/tsconfig/#extends) chain and return a flattened config. These two functions expose the chain for use cases like watch mode and config auditing.
|
||||
|
||||
### getExtendsChain(tsconfigPath, options?)
|
||||
|
||||
Collects the full extends chain. Returns an array of `TsconfigResult<TsconfigJson>` entries — each containing the raw (unmerged) config with `extends` resolved to absolute paths. (`TsconfigJson` is the raw tsconfig.json shape, including the `extends` field.)
|
||||
|
||||
`chain[0]` is the root. Ancestors follow in resolution order.
|
||||
|
||||
```ts
|
||||
type GetExtendsChainOptions = {
|
||||
cache?: Map<string, unknown>
|
||||
}
|
||||
```
|
||||
|
||||
```ts
|
||||
import { getExtendsChain } from 'get-tsconfig'
|
||||
|
||||
const chain = getExtendsChain('./tsconfig.json')
|
||||
// [
|
||||
// { path: '/project/tsconfig.json', config: { extends: '/project/base.json', ... } },
|
||||
// { path: '/project/base.json', config: { ... } },
|
||||
// ]
|
||||
|
||||
// Watch all files in the extends chain
|
||||
const filesToWatch = chain.map(entry => entry.path)
|
||||
```
|
||||
|
||||
### resolveExtendsChain(chain)
|
||||
|
||||
Merges a collected extends chain into a resolved tsconfig. Pure function — no filesystem access.
|
||||
|
||||
```ts
|
||||
import { getExtendsChain, resolveExtendsChain } from 'get-tsconfig'
|
||||
|
||||
const chain = getExtendsChain('./tsconfig.json')
|
||||
|
||||
// Modify before merging
|
||||
chain[0].config.compilerOptions = {
|
||||
...chain[0].config.compilerOptions,
|
||||
sourceMap: true
|
||||
}
|
||||
|
||||
const result = resolveExtendsChain(chain)
|
||||
// TsconfigResult { path, config, sources }
|
||||
```
|
||||
|
||||
## Working with a tsconfig
|
||||
|
||||
These functions take a parsed `TsconfigResult` (from `getTsconfig` or `readTsconfig`) and answer questions about it. They cache compiled state per tsconfig object — do not mutate the tsconfig after the first call.
|
||||
|
||||
### isFileIncluded(tsconfig, filePath)
|
||||
|
||||
Checks whether an absolute file path matches a tsconfig's `files`, `include`, and `exclude` globs — i.e., whether it's a **root file**. Case sensitivity is auto-detected from the filesystem. Non-absolute paths return `false`.
|
||||
|
||||
> [!NOTE]
|
||||
> This checks glob matching only, not transitive imports. A file outside `include` can still be part of the TypeScript program if it's imported by a root file. `exclude` only filters the initial glob matching — it doesn't prevent transitively imported files from being compiled.
|
||||
|
||||
```ts
|
||||
import { getTsconfig, isFileIncluded } from 'get-tsconfig'
|
||||
|
||||
const tsconfig = getTsconfig()
|
||||
|
||||
if (tsconfig && isFileIncluded(tsconfig, '/path/to/file.ts')) {
|
||||
// file is a root file of this tsconfig
|
||||
}
|
||||
```
|
||||
|
||||
### resolvePathAlias(tsconfig, specifier)
|
||||
|
||||
Resolves an [import specifier](https://nodejs.org/api/esm.html#terminology) against [`compilerOptions.paths`](https://www.typescriptlang.org/tsconfig#paths). Returns an array of possible file paths, or an empty array if no match. Does not perform actual file resolution.
|
||||
|
||||
```ts
|
||||
import { getTsconfig, resolvePathAlias } from 'get-tsconfig'
|
||||
|
||||
const tsconfig = getTsconfig()
|
||||
|
||||
const tryPaths = tsconfig && resolvePathAlias(tsconfig, '@/utils/helper')
|
||||
if (tryPaths?.length) {
|
||||
// Check if paths in tryPaths exist
|
||||
}
|
||||
```
|
||||
|
||||
## FAQ
|
||||
|
||||
### How can I use TypeScript to parse `tsconfig.json`?
|
||||
This package is a re-implementation of TypeScript's `tsconfig.json` parser.
|
||||
|
||||
However, if you already have TypeScript as a dependency, you can simply use it's API:
|
||||
|
||||
```ts
|
||||
import {
|
||||
sys as tsSys,
|
||||
findConfigFile,
|
||||
readConfigFile,
|
||||
parseJsonConfigFileContent
|
||||
} from 'typescript'
|
||||
|
||||
// Find tsconfig.json file
|
||||
const tsconfigPath = findConfigFile(process.cwd(), tsSys.fileExists, 'tsconfig.json')
|
||||
|
||||
// Read tsconfig.json file
|
||||
const tsconfigFile = readConfigFile(tsconfigPath, tsSys.readFile)
|
||||
|
||||
// Resolve extends
|
||||
const parsedTsconfig = parseJsonConfigFileContent(
|
||||
tsconfigFile.config,
|
||||
tsSys,
|
||||
path.dirname(tsconfigPath)
|
||||
)
|
||||
```
|
||||
|
||||
## Sponsors
|
||||
<p align="center">
|
||||
<a href="https://github.com/sponsors/privatenumber">
|
||||
<img src="https://cdn.jsdelivr.net/gh/privatenumber/sponsors/sponsorkit/sponsors.svg">
|
||||
</a>
|
||||
</p>
|
||||
2199
node_modules/get-tsconfig/dist/index.d.mts
generated
vendored
Normal file
2199
node_modules/get-tsconfig/dist/index.d.mts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
7
node_modules/get-tsconfig/dist/index.mjs
generated
vendored
Executable file
7
node_modules/get-tsconfig/dist/index.mjs
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
44
node_modules/get-tsconfig/package.json
generated
vendored
Normal file
44
node_modules/get-tsconfig/package.json
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "get-tsconfig",
|
||||
"version": "5.0.0-beta.4",
|
||||
"description": "Find and parse the tsconfig.json file from a directory path",
|
||||
"keywords": [
|
||||
"get-tsconfig",
|
||||
"get",
|
||||
"typescript",
|
||||
"tsconfig",
|
||||
"tsconfig.json"
|
||||
],
|
||||
"license": "MIT",
|
||||
"repository": "privatenumber/get-tsconfig",
|
||||
"funding": "https://github.com/privatenumber/get-tsconfig?sponsor=1",
|
||||
"author": {
|
||||
"name": "Hiroki Osame",
|
||||
"email": "hiroki.osame@gmail.com"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"skills"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"main": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.mts",
|
||||
"exports": {
|
||||
"types": "./dist/index.d.mts",
|
||||
"default": "./dist/index.mjs"
|
||||
},
|
||||
"imports": {
|
||||
"#get-tsconfig": {
|
||||
"types": "./src/index.ts",
|
||||
"development": "./src/index.ts",
|
||||
"default": "./dist/index.mjs"
|
||||
}
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.20.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"resolve-pkg-maps": "^1.0.0"
|
||||
}
|
||||
}
|
||||
146
node_modules/get-tsconfig/skills/get-tsconfig/SKILL.md
generated
vendored
Normal file
146
node_modules/get-tsconfig/skills/get-tsconfig/SKILL.md
generated
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
---
|
||||
name: get-tsconfig
|
||||
description: Find, parse, and query tsconfig.json files — extends resolution, file matching, path alias resolution. Use when reading tsconfig.json, checking if a file belongs to a tsconfig, resolving TypeScript path aliases, or working with tsconfig extends chains.
|
||||
---
|
||||
|
||||
# get-tsconfig
|
||||
|
||||
Lightweight tsconfig.json parser. No TypeScript dependency. Tested against `tsc` for correctness.
|
||||
|
||||
## API
|
||||
|
||||
| Function | Purpose | Returns |
|
||||
|----------|---------|---------|
|
||||
| `getTsconfig(searchPath?, options?)` | Find + parse nearest tsconfig | `TsconfigResult \| undefined` |
|
||||
| `findTsconfig(searchPath?, options?)` | Find nearest tsconfig path only | `string \| undefined` |
|
||||
| `readTsconfig(path, options?)` | Parse tsconfig at known path | `TsconfigResult` |
|
||||
| `isFileIncluded(tsconfig, filePath)` | Check if file is a root file (matches include/exclude/files globs) | `boolean` |
|
||||
| `resolvePathAlias(tsconfig, specifier)` | Resolve `compilerOptions.paths` alias | `string[]` |
|
||||
| `getExtendsChain(path, options?)` | Get raw extends chain before merging | `TsconfigResult<TsconfigJson>[]` |
|
||||
| `resolveExtendsChain(chain)` | Merge a collected chain (pure, no fs) | `TsconfigResult` |
|
||||
|
||||
## Types
|
||||
|
||||
```ts
|
||||
type TsconfigResult<Config = TsconfigJsonResolved> = {
|
||||
path: string
|
||||
config: Config
|
||||
}
|
||||
|
||||
// TsconfigJson = raw tsconfig shape (includes extends field)
|
||||
// TsconfigJsonResolved = TsconfigJson without extends (fully merged)
|
||||
|
||||
type GetTsconfigOptions = {
|
||||
configName?: string // default: 'tsconfig.json' (use 'jsconfig.json' for JS projects)
|
||||
cache?: Map<string, unknown>
|
||||
includes?: boolean // default: false — when true, validates file is a root file before accepting
|
||||
}
|
||||
|
||||
type ReadTsconfigOptions = {
|
||||
cache?: Map<string, unknown>
|
||||
}
|
||||
```
|
||||
|
||||
## Use cases
|
||||
|
||||
### Build tool / loader integration
|
||||
|
||||
```ts
|
||||
import { getTsconfig, isFileIncluded, resolvePathAlias } from 'get-tsconfig'
|
||||
|
||||
const tsconfig = getTsconfig()
|
||||
|
||||
// Check if a file should be transformed with this tsconfig's options
|
||||
if (tsconfig && isFileIncluded(tsconfig, absoluteFilePath)) {
|
||||
const { compilerOptions } = tsconfig.config
|
||||
// Pass to esbuild, SWC, etc. as tsconfigRaw
|
||||
}
|
||||
|
||||
// Resolve path aliases (returns candidate paths — check which exist)
|
||||
const resolved = tsconfig && resolvePathAlias(tsconfig, '@/utils/helper')
|
||||
// → ['/project/src/utils/helper'] or []
|
||||
```
|
||||
|
||||
### Monorepo — per-file tsconfig lookup
|
||||
|
||||
The nearest tsconfig typically applies. Use `getTsconfig` with the file path — it walks up and finds the right one:
|
||||
|
||||
```ts
|
||||
const cache = new Map()
|
||||
|
||||
const getConfigForFile = (filePath: string) =>
|
||||
getTsconfig(filePath, { cache })
|
||||
```
|
||||
|
||||
Cache deduplicates filesystem reads across calls. Create a new `Map()` to invalidate after filesystem changes.
|
||||
|
||||
### Implied compiler options
|
||||
|
||||
Implied options are already normalized — no need to check parent flags:
|
||||
|
||||
```ts
|
||||
const { compilerOptions } = getTsconfig().config
|
||||
|
||||
compilerOptions.noImplicitAny // true (implied by strict: true)
|
||||
compilerOptions.strictNullChecks // true (implied by strict: true)
|
||||
compilerOptions.esModuleInterop // true (implied by module: 'nodenext')
|
||||
compilerOptions.allowJs // true (implied by checkJs: true)
|
||||
```
|
||||
|
||||
Options not set and not implied remain `undefined` (not `false`). Use `?? false` for boolean checks.
|
||||
|
||||
### Watch mode — extends chain files
|
||||
|
||||
```ts
|
||||
import { getExtendsChain } from 'get-tsconfig'
|
||||
|
||||
const chain = getExtendsChain('./tsconfig.json')
|
||||
const filesToWatch = chain.map(entry => entry.path)
|
||||
```
|
||||
|
||||
### Modify config before merging
|
||||
|
||||
```ts
|
||||
import { getExtendsChain, resolveExtendsChain } from 'get-tsconfig'
|
||||
|
||||
const chain = getExtendsChain('./tsconfig.json')
|
||||
chain[0].config.compilerOptions = {
|
||||
...chain[0].config.compilerOptions,
|
||||
sourceMap: true,
|
||||
}
|
||||
const result = resolveExtendsChain(chain)
|
||||
```
|
||||
|
||||
### Language Server behavior
|
||||
|
||||
```ts
|
||||
// Default: nearest tsconfig (tsc CLI behavior)
|
||||
getTsconfig('./src/index.ts')
|
||||
|
||||
// Validates file is a root file before accepting (VS Code behavior)
|
||||
getTsconfig('./src/index.ts', { includes: true })
|
||||
```
|
||||
|
||||
## Understanding `isFileIncluded`
|
||||
|
||||
Checks whether a file matches `include`/`exclude`/`files` globs — whether it's a **root file**. This is NOT the same as "is this file part of the TypeScript program."
|
||||
|
||||
| Source | What it adds | Checked by `isFileIncluded`? |
|
||||
|--------|-------------|-------------------------------|
|
||||
| `include`/`files` globs | Root files | **Yes** |
|
||||
| Transitive imports | Files imported by root files (recursive) | No |
|
||||
| `@types` packages | Auto-discovered from `node_modules/@types/` | No |
|
||||
| Triple-slash directives | `/// <reference path="..." />` | No |
|
||||
|
||||
- **`exclude` only filters glob matching** — if a root file imports an excluded file, that file is still in the program.
|
||||
- **`isFileIncluded` returning `false` doesn't mean the file won't be compiled** — it may be pulled in via imports.
|
||||
- For finding the nearest tsconfig regardless of glob matching, use `getTsconfig(filePath)` without `includes`.
|
||||
|
||||
## Gotchas
|
||||
|
||||
| Issue | Detail |
|
||||
|-------|--------|
|
||||
| Immutable tsconfig objects | `isFileIncluded` and `resolvePathAlias` cache per object identity. Do not mutate after first call. |
|
||||
| `extends` must be resolved | `isFileIncluded` throws if `config.extends` is present. Use `getTsconfig`/`readTsconfig` output. |
|
||||
| `resolvePathAlias` returns candidates | Returns paths from `compilerOptions.paths`, not verified files. Check existence yourself. |
|
||||
| `getExtendsChain` resolves extends | The `extends` field in each entry is an absolute path, not the original string. |
|
||||
Reference in New Issue
Block a user