-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable live code inclusion for consuming applications (#2642)
Packages are marked as side effect free or have the files that include side effects listed in package.json. This allows bundlers to discard code not in the direct dependency tree of an import. Adds functions for registering components Moved to generating a single file per react wrpper component and a barrel file Update tests to use registerComponent calls fixing render problem when given and surname are null on personType objects move mgt-components to module type es2020 for dynamic imports refactored to only lazy load the person-card code when opening the flyout update list of components registered by registerMgtComponents move sample app to use lazy + Suspense to chunk up component usage adding documentation for tree shaking support
- Loading branch information
1 parent
d27ffa7
commit c41d719
Showing
115 changed files
with
1,409 additions
and
696 deletions.
There are no files selected for viewing
This file contains 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,37 @@ | ||
import { resolveModuleOrPackageSpecifier } from '@custom-elements-manifest/analyzer/src/utils/index.js'; | ||
export default function mgtTagPlugin() { | ||
function isCustomRegistration(node) { | ||
// this would be better if we tested arg[0] for a string literal | ||
return node?.expression?.getText() === 'registerComponent' && node.arguments.length >= 2; | ||
} | ||
// Write a custom plugin | ||
return { | ||
// Make sure to always give your plugins a name, this helps when debugging | ||
name: 'mgt-tag-plugin', | ||
// Runs for all modules in a project, before continuing to the analyzePhase | ||
collectPhase({ ts, node, context }) {}, | ||
// Runs for each module | ||
analyzePhase({ ts: TS, node, moduleDoc, context }) { | ||
if (isCustomRegistration(node)) { | ||
//do things... | ||
if (context.dev) console.log(node); | ||
|
||
var elementClass = node.arguments[1].text; | ||
var elementTag = node.arguments[0].text; | ||
const definitionDoc = { | ||
kind: 'custom-element-definition', | ||
name: elementTag, | ||
declaration: { | ||
name: elementClass, | ||
...resolveModuleOrPackageSpecifier(moduleDoc, context, elementClass) | ||
} | ||
}; | ||
moduleDoc.exports = [...(moduleDoc.exports || []), definitionDoc]; | ||
} | ||
}, | ||
// Runs for each module, after analyzing, all information about your module should now be available | ||
moduleLinkPhase({ moduleDoc, context }) {}, | ||
// Runs after modules have been parsed and after post-processing | ||
packageLinkPhase({ customElementsManifest, context }) {} | ||
}; | ||
} |
This file contains 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,5 @@ | ||
import mgtTagPlugin from './cem-plugins/mgt-tag-plugin.mjs'; | ||
|
||
export default { | ||
plugins: [mgtTagPlugin()] | ||
}; |
This file contains 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 |
---|---|---|
@@ -1,5 +1,9 @@ | ||
{ | ||
"packages": ["packages/*", "packages/providers/*", "samples/react-contoso"], | ||
"packages": [ | ||
"packages/*", | ||
"packages/providers/*", | ||
"samples/*" | ||
], | ||
"npmClient": "yarn", | ||
"version": "independent" | ||
} | ||
} |
This file contains 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 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 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 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 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 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 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.