Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[infra] Something broken for testing in recent @web/dev-server #3091

Closed
aomarks opened this issue Jun 25, 2022 · 0 comments · Fixed by #3132
Closed

[infra] Something broken for testing in recent @web/dev-server #3091

aomarks opened this issue Jun 25, 2022 · 0 comments · Fixed by #3132
Assignees

Comments

@aomarks
Copy link
Member

aomarks commented Jun 25, 2022

When upgrading from @web/dev-server 0.1.30 to 0.1.31, something breaks in our tests. The tests never start. The HTTP requests for JS modules served by the test server timeout, but there are no error messages.

The main change from this release are (https://github.com/modernweb-dev/web/blob/master/packages/dev-server/CHANGELOG.md#0131):

- e10b680d: Support node entry points (export map) containing stars.
- Updated dependencies [e10b680d]
  -@web/dev-server-rollup@0.3.16

So the issue may be related to export maps.

aomarks added a commit that referenced this issue Jun 27, 2022
This upgrades all package locks. `npm run upgrade` should be stable as of this PR.

There were a few issues resulting from new dependencies that needed these fixes:

- Pinned TypeScript versions in a couple of packages. We should be using `~` in general for TypeScript anyway, because TypeScript doesn't follow semver.

- Pinned `ts-clone-node` version because of an unknown breaking change.

- Changed import style for `rollup-plugin-summary` due to a presumed change in its export style.

- Pinned `@web/dev-server` and other `@web/test-*` libraries in the tests package, because something has broken in a recent version. Filed #3091 to track.
aomarks added a commit that referenced this issue Jul 15, 2022
)

Switches from a custom web test runner plugin to the now built-in export conditions configuration, in order to switch between dev and prod builds in our browser tests.

### Background

Some of our packages contain 2 separate builds: dev and prod. Dev is the raw output from TypeScript and includes extra debugging features. Prod is the minified build that users will get in production, and excludes those debugging features.

The two modes are described in our `package.json` files using [export conditions](https://nodejs.org/api/packages.html#conditional-exports). By default, users get the prod build. If they set the `development` export condition in tools like rollup, webpack, node, they will get the dev build.

We run all of our tests against both builds to get full coverage. Previously, we did this with a custom plugin for web test runner which rewrote `development/` paths to production paths when needed. We did this because web test runner did not, at the time, have support for export conditions.

Now, web test runner does have support for export conditions.

### Changes

- Switches all tests to import their respective libraries using *package self-references*, instead of relative paths. This allows export conditions to take effect *even from within the same package*.

- Switches to the `NodeNext` mode for the `module` and `moduleResolution` settings in our `tsconfig.json` files. This is needed for package self-references.

- Adds `types` entries to the export conditions in our `package.json` files. This is needed when using `NodeNext`, and is how TypeScript discovers the typings for each specific package export. (Side note, in the future, this feature will allow us to remove the `.d.ts` files that we currently duplicate into the top-level of the package, but we can't do that until our users are also using `NodeNext`).

- Added a new web test runner middleware that enforces that we only import dev sources in dev mode, and prod sources in prod mode. It serves a 403 forbidden when this is violated, which fails the test. This should prevent us from accidentally using relative imports in tests in the future.

- Deleted the old path-rewriting web test runner plugin, which is no longer needed.

- Upgraded all `@web/test-runner` and `@web/dev-server` packages, and consolidated them where possible into the top-level `package.json` for easier upgrades.

Fixes #2844
Fixes #3091
@aomarks aomarks self-assigned this Jul 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant