-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(web): reduce bundle size and add regression checks when packaging
CLOUDP-278538 (#6452) * chore(schema): replace moment usage with Date * chore(webpack-config): make sure lg testing tools are not bundled with the app * chore(web): add a local polyfill for tr46; add bundle size checks
- Loading branch information
1 parent
69ac5e8
commit f173a4e
Showing
8 changed files
with
80 additions
and
11 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
'use strict'; | ||
module.exports = require('@mongodb-js/mocha-config-compass/compass-plugin'); | ||
const config = require('@mongodb-js/mocha-config-compass/compass-plugin'); | ||
|
||
module.exports = { | ||
...config, | ||
spec: [...config.spec, 'polyfills/**/*.spec.*', 'polyfills/**/*.test.*'], | ||
}; |
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,27 @@ | ||
import { expect } from 'chai'; | ||
import { toASCII } from './index'; | ||
|
||
// Keep in sync with https://github.com/jsdom/tr46/blob/main/scripts/getLatestTests.js when updating whatwg-url | ||
const wptSHA = '72b915d4b3754f081ef5899bf6a777efe71b2fc5'; | ||
|
||
describe('tr46 polyfill', function () { | ||
describe('toASCII', function () { | ||
let tests: { input: string; output: string }[] = []; | ||
|
||
before(async function () { | ||
tests = await fetch( | ||
`https://raw.githubusercontent.com/web-platform-tests/wpt/${wptSHA}/url/resources/toascii.json` | ||
).then((res) => res.json()); | ||
}); | ||
|
||
it('should pass wpt specs', function () { | ||
for (const test of tests) { | ||
// String items are just comments in the test data | ||
if (typeof test === 'string') { | ||
return; | ||
} | ||
expect(toASCII(test.input)).to.eq(test.output); | ||
} | ||
}); | ||
}); | ||
}); |
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,17 @@ | ||
/** | ||
* This is a dependency of whatwg-url package, we can't fully replace it with | ||
* the globalThis.URL due to subtle differences in packages behavior, but we can | ||
* substitue one of the biggest chunks of the package (tr46) with a browser | ||
* implementation. | ||
*/ | ||
export function toASCII(domain: string) { | ||
try { | ||
return new window.URL(`http://${domain}`).hostname; | ||
} catch { | ||
return null; | ||
} | ||
} | ||
|
||
export function toUnicode() { | ||
throw new Error('Not implemented'); | ||
} |
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