Skip to content

Commit 0ee15e6

Browse files
committed
fix cross components imports
Right now compositions cannot import from other components because public-api.ts is missing from the bundle. Also if someone uses a different hierarchy without a src folder it would fail. We now include everything in the compilation to make sure that it works.
1 parent 6b5f330 commit 0ee15e6

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

packages/angular/angular.webpack.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export abstract class AngularWebpack {
8181
/**
8282
* Add the list of files to include into the typescript compilation as absolute paths
8383
*/
84-
private generateTsConfig(appPath: string, includePaths: string[]): string {
84+
private generateTsConfig(appPath: string, includePaths: string[], excludePaths: string[]): string {
8585
const tsconfigPath = join(appPath, 'tsconfig.app.json');
8686
const tsconfigJSON = readConfigFile(tsconfigPath, sys.readFile);
8787
const pAppPath = pathNormalizeToLinux(appPath);
@@ -94,6 +94,7 @@ export abstract class AngularWebpack {
9494
];
9595
tsconfigJSON.config.exclude = [
9696
posix.join(pAppPath, '**/*.spec.ts'),
97+
...excludePaths,
9798
...includePaths.map((path) => posix.join(path, '**/*.spec.ts')),
9899
];
99100

@@ -108,7 +109,8 @@ export abstract class AngularWebpack {
108109
* write a link to load custom modules dynamically.
109110
*/
110111
writeTsconfig(context: DevServerContext | BundlerContext, rootSpace: string): string {
111-
const componentsFilePaths = new Set<string>();
112+
const includePaths = new Set<string>();
113+
const excludePaths = new Set<string>();
112114
const dirPath = join(this.tempFolder, context.id);
113115
if (!existsSync(dirPath)) {
114116
mkdirSync(dirPath, { recursive: true });
@@ -124,15 +126,17 @@ export abstract class AngularWebpack {
124126
if (!capsule) {
125127
throw new Error(`No capsule found for ${component.id} in network graph`);
126128
}
127-
outputPath = join(capsule.path, 'src');
129+
outputPath = capsule.path;
128130
} else {
129-
outputPath = join(this.workspace?.getComponentPackagePath(component) || '', 'src');
131+
outputPath = this.workspace?.getComponentPackagePath(component) || '';
130132
}
131133

132-
componentsFilePaths.add(pathNormalizeToLinux(outputPath));
134+
includePaths.add(pathNormalizeToLinux(outputPath));
135+
excludePaths.add(pathNormalizeToLinux(join(outputPath, 'dist')));
136+
excludePaths.add(pathNormalizeToLinux(join(outputPath, '_src')));
133137
});
134138

135-
const content = this.generateTsConfig(rootSpace, Array.from(componentsFilePaths));
139+
const content = this.generateTsConfig(rootSpace, Array.from(includePaths), Array.from(excludePaths));
136140
const hash = objectHash(content);
137141
const targetPath = join(dirPath, `__tsconfig-${this.timestamp}.json`);
138142

packages/angular/preview/src/docs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export type DocsFile = {
99
window.onDocsLoad$ = window.onDocsLoad$ || new ReplaySubject<any>();
1010

1111
export default function docsRoot(
12-
Provider: Type<any> | undefined,
12+
provider: Type<any> | undefined,
1313
componentId: string,
1414
docs: DocsFile | undefined,
1515
compositionsMap: { [name: string]: Type<any> },

packages/angular/preview/tsconfig.app.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"allowJs": true,
1919
"target": "es5",
2020
"module": "esnext",
21+
"preserveSymlinks": true,
2122
"lib": [
2223
"es2018",
2324
"dom"

0 commit comments

Comments
 (0)