Skip to content
Permalink
Browse files

feat(legacyLoader): remove deprecated legacy loader

  • Loading branch information
adamdbradley committed Aug 5, 2020
1 parent c18cb1f commit 7480f9258f6aff17a3035c1531aacc0751d086d8
@@ -67,8 +67,6 @@ export const outputLazy = async (config: d.Config, compilerCtx: d.CompilerCtx, b
generateCjs(config, compilerCtx, buildCtx, rollupBuild, outputTargets),
]);

await generateLegacyLoader(config, compilerCtx, outputTargets);

if (componentBundle != null) {
buildCtx.componentGraph = generateModuleGraph(buildCtx.components, componentBundle);
}
@@ -118,51 +116,3 @@ const getLazyEntry = (isBrowser: boolean) => {

return s.toString();
};

const generateLegacyLoader = (config: d.Config, compilerCtx: d.CompilerCtx, outputTargets: d.OutputTargetDistLazy[]) => {
return Promise.all(
outputTargets.map(async o => {
if (o.legacyLoaderFile) {
const loaderContent = getLegacyLoader(config);
await compilerCtx.fs.writeFile(o.legacyLoaderFile, loaderContent, { outputTargetType: o.type });
}
}),
);
};

const getLegacyLoader = (config: d.Config) => {
const namespace = config.fsNamespace;
return `
(function(doc){
var scriptElm = doc.scripts[doc.scripts.length - 1];
var warn = ['[${namespace}] Deprecated script, please remove: ' + scriptElm.outerHTML];
warn.push('To improve performance it is recommended to set the differential scripts in the head as follows:')
var parts = scriptElm.src.split('/');
parts.pop();
parts.push('${namespace}');
var url = parts.join('/');
var scriptElm = doc.createElement('script');
scriptElm.setAttribute('type', 'module');
scriptElm.src = url + '/${namespace}.esm.js';
warn.push(scriptElm.outerHTML);
scriptElm.setAttribute('data-stencil-namespace', '${namespace}');
doc.head.appendChild(scriptElm);
${
config.buildEs5 &&
`
scriptElm = doc.createElement('script');
scriptElm.setAttribute('nomodule', '');
scriptElm.src = url + '/${namespace}.js';
warn.push(scriptElm.outerHTML);
scriptElm.setAttribute('data-stencil-namespace', '${namespace}');
doc.head.appendChild(scriptElm)
`
}
console.warn(warn.join('\\n'));
})(document);`;
};
@@ -1680,7 +1680,6 @@ export interface OutputTargetDistLazy extends OutputTargetBase {
esmIndexFile?: string;
cjsIndexFile?: string;
systemLoaderFile?: string;
legacyLoaderFile?: string;
empty?: boolean;
}

0 comments on commit 7480f92

Please sign in to comment.
You can’t perform that action at this time.