Skip to content

Commit

Permalink
fix(ilc): remove polyfills
Browse files Browse the repository at this point in the history
  • Loading branch information
stas-nc committed Aug 9, 2024
1 parent 0512dd3 commit 8d5b75b
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 89 deletions.
32 changes: 0 additions & 32 deletions ilc/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions ilc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
"test:client": "npm run build:systemjs && cross-env NODE_ENV=test karma start",
"test:client:watch": "npm run test:client -- --single-run=false --auto-watch=true",
"start": "node --max-http-header-size 30000 dist/server/index.js",
"dev": "npm run build:polyfills && cross-env NODE_ENV=development nodemon -w server -w common -e ts,js,json --exec \"npm run build:server && npm run start | pino-pretty\" ",
"build": "rimraf public && npm run build:server && npm run build:systemjs && npm run build:client && npm run build:polyfills",
"dev": "cross-env NODE_ENV=development nodemon -w server -w common -e ts,js,json --exec \"npm run build:server && npm run start | pino-pretty\" ",
"build": "rimraf public && npm run build:server && npm run build:systemjs && npm run build:client",
"build:server": "rimraf ./dist && tsc --project ./tsconfig.server.json && copyfiles ./config/* ./server/assets/* ./dist/",
"build:client": "webpack --config build/webpack.js --progress",
"build:systemjs": "node ./systemjs/build.js",
"build:polyfills": "mkdir public || true && nwget https://polyfill.io/v3/polyfill.min.js?features=URL%2CObject.entries%2CDocumentFragment.prototype.append%2CElement.prototype.append%2CElement.prototype.remove%2CObject.assign%2CElement.prototype.closest%2CCustomEvent%2CObject.values%2CArray.from -O ./public/polyfill.min.js"
"build:systemjs": "node ./systemjs/build.js"
},
"author": "",
"license": "Apache-2.0",
Expand Down Expand Up @@ -97,7 +96,6 @@
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4",
"webpack-dev-middleware": "^6.1.1",
"wget-improved": "3.3.1",
"wrapper-webpack-plugin": "^2.2.2"
},
"engines": {
Expand Down
24 changes: 0 additions & 24 deletions ilc/server/tailor/configs-injector.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ module.exports = class ConfigsInjector {
this.#getIlcState(request),
this.#getSPAConfig(registryConfig),
`<script>window.ilcApps = [];</script>`,
this.#getPolyfill(),
this.#wrapWithAsyncScriptTag(this.#getClientjsUrl()),
this.#getNewRelicScript(),
hrefLangHtml,
Expand Down Expand Up @@ -167,30 +166,7 @@ module.exports = class ConfigsInjector {
};
};

#getPolyfill = () => {
const url = this.#getPolyfillUrl();

return (
`<script type="text/javascript">` +
`if (!(` +
`typeof window.URL === 'function' && ` +
`Object.entries && ` +
`Object.assign && ` +
`DocumentFragment.prototype.append && ` +
`Element.prototype.append && ` +
`Element.prototype.remove` +
`)) {` +
`document.write('<script src="${url}" type="text/javascript" ${this.#getCrossoriginAttribute(
url,
)}></scr' + 'ipt>');` +
`}` +
`</script>`
);
};

#getClientjsUrl = () => (this.#cdnUrl === null ? '/_ilc/client.js' : urljoin(this.#cdnUrl, '/client.js'));
#getPolyfillUrl = () =>
this.#cdnUrl === null ? '/_ilc/polyfill.min.js' : urljoin(this.#cdnUrl, '/polyfill.min.js');

#getSPAConfig = (registryConfig) => {
const apps = _.mapValues(registryConfig.apps, (v) =>
Expand Down
28 changes: 1 addition & 27 deletions ilc/server/tailor/configs-injector.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,20 +283,6 @@ describe('configs injector', () => {
`<script type="ilc-state">${JSON.stringify(request.ilcState)}</script>` +
`<script type="ilc-config">${getSpaConfig()}</script>` +
'<script>window.ilcApps = [];</script>' +
`<script type="text/javascript">` +
`if (!(` +
`typeof window.URL === 'function' && ` +
`Object.entries && ` +
`Object.assign && ` +
`DocumentFragment.prototype.append && ` +
`Element.prototype.append && ` +
`Element.prototype.remove` +
`)) {` +
`document.write('<script src="${
cdnUrl + '/polyfill.min.js'
}" type="text/javascript" crossorigin></scr' + 'ipt>');` +
`}` +
`</script>` +
`<script src="${
cdnUrl + '/client.js'
}" type="text/javascript" crossorigin async></script>` +
Expand Down Expand Up @@ -325,7 +311,7 @@ describe('configs injector', () => {
);
});

it('should inject ILC config, omit ILC state, polyfills, client js and new relic <script>, route assets style sheets links into a placeholder when a document has one', () => {
it('should inject ILC config, omit ILC state, client js and new relic <script>, route assets style sheets links into a placeholder when a document has one', () => {
context.run(
{
request: {
Expand Down Expand Up @@ -374,18 +360,6 @@ describe('configs injector', () => {
'<!-- TailorX: Ignore during parsing START -->' +
`<script type="ilc-config">${getSpaConfig()}</script>` +
'<script>window.ilcApps = [];</script>' +
`<script type="text/javascript">` +
`if (!(` +
`typeof window.URL === 'function' && ` +
`Object.entries && ` +
`Object.assign && ` +
`DocumentFragment.prototype.append && ` +
`Element.prototype.append && ` +
`Element.prototype.remove` +
`)) {` +
`document.write('<script src="/_ilc/polyfill.min.js" type="text/javascript" ></scr' + 'ipt>');` +
`}` +
`</script>` +
`<script src="/_ilc/client.js" type="text/javascript" async></script>` +
browserTimingHeader +
`<link rel="alternate" hreflang="en-us" href="https://test.com/test/route/" data-ilc="1" />` +
Expand Down
2 changes: 1 addition & 1 deletion install_all.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ commands.forEach((cmd) => {
console.log('');
console.log(`Installing packages for "${cmd.name}"... Calling: ${cmd.command}`);
console.log('');
const res = spawnSync(cmd.command, { shell: true, timeout: 120000, killSignal: 'SIGKILL', stdio: 'inherit' });
const res = spawnSync(cmd.command, { shell: true, killSignal: 'SIGKILL', stdio: 'inherit' });
if (res.status !== 0) {
throw new Error(
`Error during packages installation for "${cmd.name}". Command "${cmd.command}" exited with code "${res.status}".`,
Expand Down

0 comments on commit 8d5b75b

Please sign in to comment.