Skip to content

Commit

Permalink
feat(legacyLoader): remove deprecated legacy loader
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Aug 5, 2020
1 parent c18cb1f commit 7480f92
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 51 deletions.
50 changes: 0 additions & 50 deletions src/compiler/output-targets/dist-lazy/lazy-output.ts
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);`;
};
1 change: 0 additions & 1 deletion src/declarations/stencil-public-compiler.ts
Expand Up @@ -1680,7 +1680,6 @@ export interface OutputTargetDistLazy extends OutputTargetBase {
esmIndexFile?: string;
cjsIndexFile?: string;
systemLoaderFile?: string;
legacyLoaderFile?: string;
empty?: boolean;
}

Expand Down

0 comments on commit 7480f92

Please sign in to comment.