[remix] Fix config file dynamic import#9249
Conversation
They get run by the integration tests instead, and currently Jest
segfaults with `eval('import(...)')` so we can't really unit test
anymore :(
| "@types/node": "14.18.33", | ||
| "@vercel/build-utils": "5.9.0", | ||
| "typescript": "4.6.4" | ||
| "typescript": "4.9.4" |
There was a problem hiding this comment.
Thought this was necessary at first. This isn't the case, but doesn't hurt either.
| "build": "node build.js", | ||
| "test-integration-once": "pnpm test test/test.js", | ||
| "test": "jest --env node --verbose --bail --runInBand", | ||
| "test-unit": "pnpm test test/build.test.ts" |
There was a problem hiding this comment.
The unit tests were deleted since they test basically the same as the integration tests. However, await import() breaks Jest currently, so they needed to be removed.
| const remixConfigModule = await import( | ||
| pathToFileURL(remixConfigFile).href | ||
| ); | ||
| const remixConfigModule = await eval('import(remixConfigFile)'); |
There was a problem hiding this comment.
eval is required to prevent TypeScript from compiling the import into require.
There was a problem hiding this comment.
I would be surprised if this works since I didn’t think eval works for ESM
There was a problem hiding this comment.
A better solution is to update tsconfig.json with module: nodenext
|
The existing integration test should already be testing for this. I don't really understand how it was passing before, but possibly just a caching issue 😕 |
Follow-up to #8793, which breaks dynamic import of the config file, causing some issues for remix users: https://github.com/orgs/vercel/discussions/1282
The underlying error is
MODULE_NOT_FOUND.import()should work withfile://URIs, however, since it's using typescript, theimportgets compiled torequire(), which does not supportfile://protocol scheme.Supersedes #9248.