Skip to content

Commit

Permalink
revert: "fix: dependency submodules may not be discovered (#3151)" (#…
Browse files Browse the repository at this point in the history
…3170)

This reverts commit 5768bb9.

The commit breaks the build of CDKv2 alpha modules.
see aws/aws-cdk#17502



---

By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license].

[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
  • Loading branch information
Niranjan Jayakar authored Nov 16, 2021
1 parent 18ddfba commit 0449dd9
Show file tree
Hide file tree
Showing 14 changed files with 8 additions and 140 deletions.
3 changes: 1 addition & 2 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"npmClient": "yarn",
"useWorkspaces": true,
"packages": [
"packages/*",
"regression-tests/@*/*"
"packages/*"
],
"command": {
"bootstrap": {
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"packages/*",
"packages/@jsii/*",
"packages/@scope/*",
"regression-tests/@*/*",
"tools/*"
],
"nohoist": [
Expand Down
8 changes: 1 addition & 7 deletions packages/jsii/lib/assembler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3213,13 +3213,7 @@ function inferRootDir(program: ts.Program): string | undefined {
.map((fileName) =>
path.relative(program.getCurrentDirectory(), path.dirname(fileName)),
)
.map(segmentPath)
// Dependency entry points are in this path, and they MAY resolve from the
// same mono-repo, in which case they won't appear to be external libraries,
// as there may not be a `/node_modules/` segment in their canonical path.
// They well however come from a parent directory, so their path segments
// will start with "..".
.filter(([head]) => head !== '..');
.map(segmentPath);

const maxPrefix = Math.min(
...directories.map((segments) => segments.length - 1),
Expand Down
41 changes: 6 additions & 35 deletions packages/jsii/lib/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,11 @@ export class Compiler implements Emitter {
const pi = this.options.projectInfo;
const projectRoot = pi.projectRoot;
const host = ts.createWatchCompilerHost(
this.rootFiles,
this.configPath,
{
...pi.tsc,
...BASE_COMPILER_OPTIONS,
noEmitOnError: false,
tsBuildInfoFile: path.join(
pi.tsc?.outDir ?? pi.tsc?.rootDir ?? pi.projectRoot,
'tsconfig.tsbuildinfo',
),
},
{
...ts.sys,
Expand All @@ -152,7 +148,6 @@ export class Compiler implements Emitter {
ts.createEmitAndSemanticDiagnosticsBuilderProgram,
opts?.reportDiagnostics,
opts?.reportWatchStatus,
this.typescriptConfig?.references,
);
if (!host.getDefaultLibLocation) {
throw new Error(
Expand Down Expand Up @@ -500,47 +495,23 @@ export class Compiler implements Emitter {
* This makes it so that running 'tsc' and running 'jsii' has the same behavior.
*/
private determineSources(files: string[]): string[] {
const ret = new Set<string>();
const ret = new Array<string>();

if (files.length > 0) {
for (const file of files) {
ret.add(path.resolve(this.options.projectInfo.projectRoot, file));
}
ret.push(...files);
} else {
const parseConfigHost = parseConfigHostFromCompilerHost(
this.compilerHost,
);
// Note: the fileNames here are resolved by the parseConfigHost.
const { fileNames } = ts.parseJsonConfigFileContent(
const parsed = ts.parseJsonConfigFileContent(
this.typescriptConfig,
parseConfigHost,
this.options.projectInfo.projectRoot,
);
for (const file of fileNames) {
ret.add(file);
}
ret.push(...parsed.fileNames);
}

// Bonus: ensure all dependencies' entry points are included in the compiler
// input path. This guarantees we have symbols for all types, from the
// module root, which is necessary in order to properly detect submodules.
for (const assm of this.options.projectInfo.dependencyClosure) {
const { resolvedModule } = ts.resolveModuleName(
assm.name,
path.join(
this.options.projectInfo.projectRoot,
this.options.projectInfo.types,
),
this.typescriptConfig?.compilerOptions ?? {},
ts.sys,
);
if (!resolvedModule) {
continue;
}
ret.add(resolvedModule.resolvedFileName);
}

return Array.from(ret);
return ret;
}

/**
Expand Down
4 changes: 0 additions & 4 deletions regression-tests/@barrelimports/consumer/.gitignore

This file was deleted.

6 changes: 0 additions & 6 deletions regression-tests/@barrelimports/consumer/README.md

This file was deleted.

6 changes: 0 additions & 6 deletions regression-tests/@barrelimports/consumer/lib/index.ts

This file was deleted.

30 changes: 0 additions & 30 deletions regression-tests/@barrelimports/consumer/package.json

This file was deleted.

4 changes: 0 additions & 4 deletions regression-tests/@barrelimports/provider/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions regression-tests/@barrelimports/provider/README.md

This file was deleted.

1 change: 0 additions & 1 deletion regression-tests/@barrelimports/provider/lib/index.ts

This file was deleted.

3 changes: 0 additions & 3 deletions regression-tests/@barrelimports/provider/lib/namespaced.ts

This file was deleted.

26 changes: 0 additions & 26 deletions regression-tests/@barrelimports/provider/package.json

This file was deleted.

10 changes: 0 additions & 10 deletions regression-tests/README.md

This file was deleted.

0 comments on commit 0449dd9

Please sign in to comment.