Skip to content
This repository has been archived by the owner on May 19, 2022. It is now read-only.

Use tsconfig package to parse tsconfig files #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,8 @@
"eslint --fix",
"git add"
]
},
"dependencies": {
"tsconfig": "^7.0.0"
}
}
5 changes: 3 additions & 2 deletions plugin/extract-aliases/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const fs = require('fs')
const path = require('path')
const { parse } = require('tsconfig')
const normalizePluginOptions = require('../normalize-plugin-options')
const normalizeAliases = require('./normalize-aliases')

const extractAliasesFromConfig = ({ configPath, absoluteBaseUrl }) => {
const configFileContents = fs.readFileSync(configPath)
const config = JSON.parse(configFileContents)
const configFileContents = fs.readFileSync(configPath).toString()
const config = parse(configFileContents, configPath)

const { compilerOptions } = config

Expand Down
4 changes: 3 additions & 1 deletion plugin/pre-check/check-config-contents.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const { parse } = require('tsconfig')

const checkConfigContents = ({
unparsedConfig,
configFileName,
Expand All @@ -6,7 +8,7 @@ const checkConfigContents = ({
let config

try {
config = JSON.parse(unparsedConfig)
config = parse(unparsedConfig.toString(), configFileName)
} catch (error) {
return handleError(
`Cannot parse ${configFileName}. Please validate it on https://jsonformatter.curiousconcept.com.`
Expand Down
25 changes: 25 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,16 @@
resolved "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-1.0.1.tgz"
integrity sha512-l42BggppR6zLmpfU6fq9HEa2oGPEI8yrSPL3GITjfRInppYFahObbIQOQK3UGxEnyQpltZLaPe75046NOZQikw==

"@types/strip-bom@^3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@types/strip-bom/-/strip-bom-3.0.0.tgz#14a8ec3956c2e81edb7520790aecf21c290aebd2"
integrity sha1-FKjsOVbC6B7bdSB5CuzyHCkK69I=

"@types/[email protected]":
version "0.0.30"
resolved "https://registry.yarnpkg.com/@types/strip-json-comments/-/strip-json-comments-0.0.30.tgz#9aa30c04db212a9a0649d6ae6fd50accc40748a1"
integrity sha512-7NQmHra/JILCd1QqpSzl8+mJRc8ZHz3uDm8YV1Ks9IhK0epEiTw8aIErbvH9PI+6XbqhyIQy3462nEsn7UVzjQ==

"@types/yargs-parser@*":
version "20.2.0"
resolved "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-20.2.0.tgz"
Expand Down Expand Up @@ -4283,6 +4293,11 @@ strip-final-newline@^2.0.0:
resolved "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz"
integrity sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==

strip-json-comments@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"
integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo=

strip-json-comments@^3.1.0, strip-json-comments@^3.1.1:
version "3.1.1"
resolved "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz"
Expand Down Expand Up @@ -4416,6 +4431,16 @@ tsconfig-paths@^3.9.0:
minimist "^1.2.0"
strip-bom "^3.0.0"

tsconfig@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/tsconfig/-/tsconfig-7.0.0.tgz#84538875a4dc216e5c4a5432b3a4dec3d54e91b7"
integrity sha512-vZXmzPrL+EmC4T/4rVlT2jNVMWCi/O4DIiSj3UHg1OE5kCKbk4mfrXc6dZksLgRM/TZlKnousKH9bbTazUWRRw==
dependencies:
"@types/strip-bom" "^3.0.0"
"@types/strip-json-comments" "0.0.30"
strip-bom "^3.0.0"
strip-json-comments "^2.0.0"

tslib@^1.9.0:
version "1.14.1"
resolved "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz"
Expand Down