Skip to content

Improve message of EMPTY_IMPORT_META warning #6754

@hyf0

Description

@hyf0

Thought about this when reviewing #6747.

## warnings

### EMPTY_IMPORT_META

\```text
[EMPTY_IMPORT_META] Warning: `import.meta` is not available with the `iife` output format and will be empty.
   ╭─[ main.js:1:13 ]
   │
 1 │ console.log(import.meta.hello);
   │             ─────┬─────  
   │                  ╰─────── You need to set the output format to `esm` for `import.meta` to work correctly.
───╯

\```
  • "import.meta is not available with the iife output format " is bit of confusing. Should be something like: "Your output format. iife might run into errors when having import.mets". Also point out that import.meta will be replaced with {} due to so.
  • iife format will enable inlineDynamicImports by default, while esm doesn't. Helper message should point out how to achieve the same result.
  • If users want to continue on iffe format, help message doesn't provide workaround solution for solving this warning. Should point out that, to remove the warning, users could use transform.define to replace import.meta with {} explicitly if they want to continue using iife format

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions