@@ -31,55 +31,6 @@ don't need to be managed collectively otherwise.
31
31
there was intent to migrate this repo's tests to WTR, so it still contains its
32
32
own tests. These should eventually be moved here too.
33
33
34
- ## Why are two imports required to set up the test environment in WTR tests?
35
-
36
- The test environment is _ intentionally_ imported into the test pages through two
37
- separate entrypoints: one for polyfills that the test runner depends on and
38
- another for the test runner itself.
39
-
40
- ` @web/test-runner-mocha ` depends on a module that is _ dynamically-generated_ by
41
- the test server, so this compilation step must occur as server middleware.
42
- Particularly, this compilation step can't happen partially at build time because
43
- all modules in the same dependency graph need to be visible to the same
44
- compilation tool to be linked correctly but the dynamically-generated module
45
- does not exist on disk.
46
-
47
- This dynamic module requires support for ` fetch ` as well as ` URL ` with both a
48
- user-callable constructor and a ` searchParams ` property (implying
49
- ` URLSearchParams ` support). Some of the browsers these packages are tested in do
50
- not natively support these features so polyfills are required: ` whatwg-fetch `
51
- for ` fetch ` and ` core-js ` for ` URL ` (` core-js ` was the only suitable candidate
52
- found at the time for ` URL ` ).
53
-
54
- The required ` core-js ` polyfills are only available in Common JS format.
55
- However, the server middleware used for module compilation does not support
56
- Common JS, so ` core-js ` must be bundled in an earlier step by a tool that _ is_
57
- capable of compiling Common JS.
58
-
59
- If ` @web/test-runner-mocha ` were included in the same bundle as ` core-js ` and
60
- the bundler were instructed to output a single standard module that still
61
- contains the import statement pointing to the dynamically-generated module
62
- (because that module does not exist as a file on disk that the bundler could
63
- read to include in the bundle), then the bundler would be forced to emit a
64
- module that implicitly describes the entirety of that bundle executing only
65
- _ after_ the imported module. ** This would cause the dynamically-generated module
66
- that depends on the ` core-js ` polyfills to run before those polyfills are
67
- installed, making this an unviable option.**
68
-
69
- So, to work around this ordering problem and guarantee that the ` core-js `
70
- polyfills are (a) able to be bundled, (b) run before the dynamically-generated
71
- module dependency of ` @web/test-runner-mocha ` , and (c) linked properly with
72
- other modules in the dependency graph by use of a single compilation tool, the
73
- test environment is split into two separately bundled standard modules.
74
-
75
- The first module bundle contains polyfills required by ` @web/test-runner-mocha `
76
- and the second contains the modules that depend on those polyfills. These
77
- polyfills are then included as separate import statements in each test file,
78
- which guarantees that the server middleware is the one step where all modules
79
- are compiled out. This gives that middleware full control of the loading order
80
- of all modules, allowing it to properly delay the dynamically-generated module
81
- from running until the polyfills it requires have loaded.
82
-
83
34
## Why does the ` webcomponentsjs_ ` directory name end with a ` _ ` ?
84
35
85
36
` polyserve ` , the server used internally by ` web-component-tester ` (WCT), will
0 commit comments