chore(core): monorepo, esm targeting, improved management (#8707)

This commit is contained in:
Nathan Walker
2020-08-25 20:00:59 -07:00
committed by GitHub
parent 6f15334934
commit 020ad4da37
4271 changed files with 148599 additions and 149734 deletions

View File

@ -0,0 +1,30 @@
const { safeGet } = require("./projectHelpers");
const LAZY_RESOURCE_CONTEXT = "$$_lazy_route_resource";
const HOT_SELF_ACCEPT = "module.hot.accept();";
const HOT_DISPOSE = `
module.hot.dispose(() => {
// Currently the context is needed only for application style modules.
const moduleContext = {};
global.hmrRefresh(moduleContext);
});`;
const HMR_HANDLER = `
if (module.hot) {
${HOT_SELF_ACCEPT}${HOT_DISPOSE}
}
`;
const isLazyLoadedNgModule = resource => {
const issuer = safeGet(resource, "issuer");
const issuerContext = safeGet(issuer, "context");
return issuerContext && issuerContext.endsWith(LAZY_RESOURCE_CONTEXT);
};
module.exports = function (source, map) {
const modifiedSource = isLazyLoadedNgModule(this._module) ?
`${source};${HMR_HANDLER}`:
source;
this.callback(null, modifiedSource, map);
};