Skip to content

Commit

Permalink
fix(workspace-tools): Resolved bad tsconfig path issue in tsup patch
Browse files Browse the repository at this point in the history
  • Loading branch information
sullivanpj committed Nov 20, 2023
1 parent 2a18056 commit 564b0b5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
37 changes: 22 additions & 15 deletions patches/tsup@8.0.0.patch
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ index 36191e8e511f9cc413d70403ac86c989890f8d65..90904ee10b884a1e35ddd637e0be4313
interface NormalizedExperimentalDtsConfig {
entry: {
diff --git a/dist/index.js b/dist/index.js
index 2c8ba016932710c259e84a7a070271eb4f73da5b..fac2dca94b8bf46f3edc0d2cc6a8cd086b548a7f 100644
index 2c8ba016932710c259e84a7a070271eb4f73da5b..d40ce8d8cdb6b9788f15e554f738fa41abe59fba 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -1603,6 +1603,36 @@ var generateExternal = async (external) => {
Expand Down Expand Up @@ -67,16 +67,21 @@ index 2c8ba016932710c259e84a7a070271eb4f73da5b..fac2dca94b8bf46f3edc0d2cc6a8cd08
const external = [
// Exclude dependencies, e.g. `lodash`, `lodash/get`
...deps.map((dep) => new RegExp(`^${dep}($|\\/|\\\\)`)),
@@ -1683,7 +1717,7 @@ async function runEsbuild(options, {
@@ -1683,7 +1717,12 @@ async function runEsbuild(options, {
target: options.target,
banner,
footer,
- tsconfig: options.tsconfig,
+ tsconfig: options.projectRoot ? _path2.default.join(options.projectRoot, options.tsconfig) : options.tsconfig,
+ tsconfig: options.tsconfig
+ ? options.tsconfig
+ : options.projectRoot
+ ? _path2.default.join(options.projectRoot,
+ "tsconfig.json")
+ : "tsconfig.json",
loader: {
".aac": "file",
".css": "file",
@@ -1724,15 +1758,16 @@ async function runEsbuild(options, {
@@ -1724,15 +1763,16 @@ async function runEsbuild(options, {
}, {})
},
inject: [
Expand All @@ -96,24 +101,26 @@ index 2c8ba016932710c259e84a7a070271eb4f73da5b..fac2dca94b8bf46f3edc0d2cc6a8cd08
minify: options.minify === "terser" ? false : options.minify,
minifyWhitespace: options.minifyWhitespace,
minifyIdentifiers: options.minifyIdentifiers,
@@ -2287,11 +2322,12 @@ function emitDtsFiles(program, host) {
@@ -2287,11 +2327,14 @@ function emitDtsFiles(program, host) {
}
return fileMapping;
}
-function emit(compilerOptions, tsconfig) {
- let cwd = process.cwd();
- let rawTsconfig = _bundlerequire.loadTsConfig.call(void 0, cwd, tsconfig);
+function emit(options, compilerOptions, tsconfig) {
+ logger.info("tsc", `Trying to find ${tsconfig || "tsconfig.json"} in ${options.projectRoot}`);
+ logger.info("tsc", `Trying to find ${tsconfig || "./tsconfig.json"}`);
+
+ let rawTsconfig = _bundlerequire.loadTsConfig.call(void 0, options.projectRoot, tsconfig);
+ let rawTsconfig = _bundlerequire.loadTsConfig.call(void 0,
+ _path.dirname.call(void 0, tsconfig),
+ _path.basename.call(void 0, tsconfig));
if (!rawTsconfig) {
- throw new Error(`Unable to find ${tsconfig || "tsconfig.json"} in ${cwd}`);
+ throw new Error(`Unable to find ${tsconfig || "tsconfig.json"} in ${options.projectRoot}`);
+ throw new Error(`Unable to find ${tsconfig || "tsconfig.json"}`);
}
let declarationDir = _chunkGQ77QZBOjs.ensureTempDeclarationDir.call(void 0, );
let parsedTsconfig = _typescript2.default.parseJsonConfigFileContent(
@@ -2299,6 +2335,8 @@ function emit(compilerOptions, tsconfig) {
@@ -2299,6 +2342,8 @@ function emit(compilerOptions, tsconfig) {
...rawTsconfig.data,
compilerOptions: {
..._optionalChain([rawTsconfig, 'access', _16 => _16.data, 'optionalAccess', _17 => _17.compilerOptions]),
Expand All @@ -122,12 +129,12 @@ index 2c8ba016932710c259e84a7a070271eb4f73da5b..fac2dca94b8bf46f3edc0d2cc6a8cd08
// Enable declaration emit and disable javascript emit
noEmit: false,
declaration: true,
@@ -2308,13 +2346,13 @@ function emit(compilerOptions, tsconfig) {
@@ -2308,13 +2353,13 @@ function emit(compilerOptions, tsconfig) {
}
},
_typescript2.default.sys,
- tsconfig ? _path.dirname.call(void 0, tsconfig) : "./"
+ tsconfig ?_path.join(options.projectRoot, _path.dirname.call(void 0, tsconfig)) : options.projectRoot
+ tsconfig ? _path.dirname.call(void 0, tsconfig) : options.projectRoot
);
- let options = parsedTsconfig.options;
- let host = _typescript2.default.createCompilerHost(options);
Expand All @@ -140,7 +147,7 @@ index 2c8ba016932710c259e84a7a070271eb4f73da5b..fac2dca94b8bf46f3edc0d2cc6a8cd08
host
);
let fileMapping = emitDtsFiles(program, host);
@@ -2328,7 +2366,7 @@ function runTypeScriptCompiler(options) {
@@ -2328,7 +2373,7 @@ function runTypeScriptCompiler(options) {
};
logger.info("tsc", "Build start");
const dtsOptions = options.experimentalDts;
Expand All @@ -149,7 +156,7 @@ index 2c8ba016932710c259e84a7a070271eb4f73da5b..fac2dca94b8bf46f3edc0d2cc6a8cd08
logger.success("tsc", `\u26A1\uFE0F Build success in ${getDuration()}`);
return exports;
} catch (error) {
@@ -2429,8 +2467,10 @@ function formatDistributionExport(declaration, dest) {
@@ -2429,8 +2474,10 @@ function formatDistributionExport(declaration, dest) {
// src/api-extractor.ts
var logger2 = _chunk7G76EW2Rjs.createLogger.call(void 0, );
function rollupDtsFile(inputFilePath, outputFilePath, tsconfigFilePath) {
Expand All @@ -162,7 +169,7 @@ index 2c8ba016932710c259e84a7a070271eb4f73da5b..fac2dca94b8bf46f3edc0d2cc6a8cd08
let configObject = {
mainEntryPointFilePath: inputFilePath,
apiReport: {
@@ -2447,7 +2487,7 @@ function rollupDtsFile(inputFilePath, outputFilePath, tsconfigFilePath) {
@@ -2447,7 +2494,7 @@ function rollupDtsFile(inputFilePath, outputFilePath, tsconfigFilePath) {
compiler: {
tsconfigFilePath
},
Expand All @@ -171,7 +178,7 @@ index 2c8ba016932710c259e84a7a070271eb4f73da5b..fac2dca94b8bf46f3edc0d2cc6a8cd08
};
const prepareOptions = {
configObject,
@@ -2477,7 +2517,11 @@ function rollupDtsFile(inputFilePath, outputFilePath, tsconfigFilePath) {
@@ -2477,7 +2524,11 @@ function rollupDtsFile(inputFilePath, outputFilePath, tsconfigFilePath) {
async function rollupDtsFiles(options, exports, format) {
let declarationDir = _chunkGQ77QZBOjs.ensureTempDeclarationDir.call(void 0, );
let outDir = options.outDir || "dist";
Expand Down
6 changes: 3 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 564b0b5

Please sign in to comment.