Skip to content

Commit

Permalink
fix: INCONSISTENT_IMPORT_ASSERTIONS warning
Browse files Browse the repository at this point in the history
Rollup v3 has introduced some support of import assertions in
rollup/rollup#4646. In particular, it uses
an `{ assertions: { type: <xxx> } }` object to track the assertions
linked to a module. However, this does not seem to be set in preload,
whereas it _is_ set afterwards. This results in a warning.

In order to silence the warning, we need to explicitly tell rollup
about the assertions type, so that this piece of information is
available even at preload time.

Note: this also makes the test 'handles garbage' pass. Without this
rollup issues 2 warnings instead of 1 expected (resulting in test failure).
  • Loading branch information
swiing committed May 12, 2023
1 parent d8560bd commit 8fc677b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/index.js
Expand Up @@ -140,7 +140,9 @@ export default sheet;`;
// case where the module has not been loaded yet.
if (!moduleInfo) {
self
.load({ id: resolvedId.id, meta })
// {meta} is used by this plugin to track the assertion type
// {assertions} is used by rollup v3 for the same purpose
.load({ id: resolvedId.id, meta, assertions: { type } })
// errors parsing the file are already captured, so don't repeat error
// https://github.com/rollup/rollup/blob/275dc2fa34e1aaad37a29360570dc85b1ba019a6/src/Module.ts#L837
// Question: could it be though that load() rejects for an error type
Expand Down

0 comments on commit 8fc677b

Please sign in to comment.