From b3497ba4912ce26b647f06f524bb98fdc2de43ab Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Tue, 26 Dec 2023 05:28:58 -0800 Subject: [PATCH] fix: improve warning when encountering import.meta.env (#11440) --- .changeset/silly-panthers-talk.md | 5 +++++ packages/package/src/validate.js | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/silly-panthers-talk.md diff --git a/.changeset/silly-panthers-talk.md b/.changeset/silly-panthers-talk.md new file mode 100644 index 000000000000..0b0d19355926 --- /dev/null +++ b/.changeset/silly-panthers-talk.md @@ -0,0 +1,5 @@ +--- +"@sveltejs/package": patch +--- + +fix: improve warning when encountering import.meta.env diff --git a/packages/package/src/validate.js b/packages/package/src/validate.js index 808e99c01fdd..31d2d285bba3 100644 --- a/packages/package/src/validate.js +++ b/packages/package/src/validate.js @@ -87,8 +87,8 @@ export function _create_validator(options) { if (uses_import_meta) { warnings.push( - 'Avoid usage of `import.meta.env` in your code. It requires a bundler to work. ' + - 'Consider using packages like `esm-env` instead which provide cross-bundler-compatible environment variables.' + 'Avoid usage of `import.meta.env` in your code. It only works in apps bundled with Vite. ' + + 'Consider using packages like `esm-env` instead which works with all bundlers or without bundling.' ); }