-
Notifications
You must be signed in to change notification settings - Fork 815
feat(runtime): allow class extending #6362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
10a1102
feat(runtime): allow class extending
062301c
chore: fix tests
de9c45d
feat: extend Stencil decorated classes!
4f7e3be
chore: assign / reuse `foundSuper`
29a53ec
Merge branch 'main' into feat-extend-class
johnjenkins b90abc2
chore: fix test
678ae84
chore: format
ab914e4
chore: fix test
2d8bab7
chore: read all the extended tree class methods
be7d1e3
chore: added some unit tests
2ecafeb
chore: more unit tests
0e6bbe6
chore: wdio tests and bundleid fixing
cb6e944
chore: get tests to pass
fe46605
Merge branch 'main' into feat-extend-class
johnjenkins b2ea352
chore: fix tests?
971ca10
Merge branch 'feat-extend-class' of github.com:stenciljs/core into fe…
1aac7f6
chore: try this
79f3abb
chore: silly me
eda7cd0
chore: test 2 layer extends
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
src/compiler/output-targets/dist-lazy/lazy-bundleid-plugin.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import MagicString from 'magic-string'; | ||
|
||
import type { OutputChunk, Plugin } from 'rollup'; | ||
import type * as d from '../../../declarations'; | ||
|
||
/** | ||
* A Rollup plugin to generate unique bundle IDs for lazy-loaded modules. | ||
* @param buildCtx The build context | ||
* @param config The validated configuration | ||
* @param shouldHash Whether to hash the bundle ID | ||
* @param suffix The suffix to append to the bundle ID | ||
* @returns A Rollup plugin | ||
*/ | ||
export const lazyBundleIdPlugin = ( | ||
buildCtx: d.BuildCtx, | ||
config: d.ValidatedConfig, | ||
shouldHash: boolean, | ||
suffix: string, | ||
): Plugin => { | ||
const getBundleId = async (entryKey: string, code: string, suffix: string): Promise<string> => { | ||
if (shouldHash && config.sys?.generateContentHash) { | ||
const hash = await config.sys.generateContentHash(code, config.hashedFileNameLength); | ||
return `p-${hash}${suffix}`; | ||
} | ||
|
||
const components = entryKey.split('.'); | ||
let bundleId = components[0]; | ||
if (components.length > 2) { | ||
bundleId = `${bundleId}_${components.length - 1}`; | ||
} | ||
|
||
return bundleId + suffix; | ||
}; | ||
|
||
return { | ||
name: 'lazyBundleIdPlugin', | ||
async generateBundle(_, bundle) { | ||
const files = Object.entries<OutputChunk>(bundle as any); | ||
const map = new Map<string, string>(); | ||
|
||
for (const [_key, file] of files) { | ||
if (!file.isEntry) continue; | ||
|
||
const entryModule = buildCtx.entryModules.find((em) => em.entryKey === file.name); | ||
if (!entryModule) continue; | ||
|
||
map.set(file.fileName, (await getBundleId(file.name, file.code, suffix)) + '.entry.js'); | ||
} | ||
|
||
if (!map.size) return; | ||
|
||
for (const [_key, file] of files) { | ||
if (!file.isEntry) continue; | ||
|
||
file.facadeModuleId = map.get(file.fileName) || file.facadeModuleId; | ||
file.fileName = map.get(file.fileName) || file.fileName; | ||
|
||
const magicString = new MagicString(file.code); | ||
|
||
file.imports.forEach((imported: string, i) => { | ||
const replaced = map.get(imported); | ||
if (replaced) { | ||
magicString.replaceAll(imported, replaced); | ||
file.imports[i] = replaced; | ||
} | ||
}); | ||
file.code = magicString.toString(); | ||
|
||
if (config.sourceMap) { | ||
file.map = magicString.generateMap(); | ||
} | ||
} | ||
}, | ||
}; | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.