Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

bug(plunker): fix plunkers not working with dialogs #5899 #228

Closed
wants to merge 2 commits into from
Closed
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
20 changes: 18 additions & 2 deletions src/app/shared/plunker/plunker-writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,25 @@ export class PlunkerWriter {
fileContent = fileContent.replace(/material-docs-example/g, data.selectorName);
} else if (fileName == 'main.ts') {
// Replace the component name in `main.ts`.
// For example, `import {MaterialDocsExample} from 'material-docs-example'`

// Replace `import {MaterialDocsExample} from 'material-docs-example'`
// will be replaced as `import {ButtonDemo} from './button-demo'`
fileContent = fileContent.replace(/MaterialDocsExample/g, data.componentName);
fileContent = fileContent.replace(/{MaterialDocsExample}/g, `{${data.componentName}}`);

// Replace `declarations: [MaterialDocsExample]`
// will be replaced as `declarations: [ButtonDemo]`
fileContent = fileContent.
replace(/declarations: \[MaterialDocsExample\]/g,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also replace entryComponents?

Add entryComponents: [MaterialDocsExample] to main.ts.

I tested on plunker and found out it doesn't work without entryComponents.

`declarations: [${data.componentName}]`);

// Replace `bootstrap: [MaterialDocsExample]`
// will be replaced as `bootstrap: [ButtonDemo]`
// This assumes the first component listed in the main component
const bootstrapComponent = data.componentName.split(',')[0];
fileContent = fileContent.
replace(/bootstrap: \[MaterialDocsExample\]/g,
`bootstrap: [${bootstrapComponent}]`);

fileContent = fileContent.replace(/material-docs-example/g, data.indexFilename);
}
return fileContent;
Expand Down