From 21b0c73a2ac31614e4a2a8da7b73971856cbbfe5 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Tue, 8 Jun 2021 09:45:15 -0400 Subject: [PATCH] Remove warnings coming from snowpack (#329) * Remove warnings coming from snowpack This removes a few warnings coming from snowpack that we can't really do anything about. * Adds changeset --- .changeset/clever-balloons-learn.md | 5 +++++ packages/astro/src/snowpack-logger.ts | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 .changeset/clever-balloons-learn.md diff --git a/.changeset/clever-balloons-learn.md b/.changeset/clever-balloons-learn.md new file mode 100644 index 000000000..37153ad16 --- /dev/null +++ b/.changeset/clever-balloons-learn.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Removes some warnings that are internal to Astro diff --git a/packages/astro/src/snowpack-logger.ts b/packages/astro/src/snowpack-logger.ts index 0bc791446..a3dc2b534 100644 --- a/packages/astro/src/snowpack-logger.ts +++ b/packages/astro/src/snowpack-logger.ts @@ -3,6 +3,14 @@ import { defaultLogLevel } from './logger.js'; const onceMessages = ['Ready!', 'watching for file changes'].map((str) => new RegExp(`\\[snowpack\\](.*?)${str}`)); +const neverWarn = new RegExp('(' + + /(run "snowpack init" to create a project config file.)|/.source + + /(astro\/dist\/internal\/__astro_component.js: Unscannable package import found.)|/.source + + /(Cannot call a namespace \('loadLanguages'\))|/.source + + /('default' is imported from external module 'node-fetch' but never used)/.source + + ')' +); + export function configureSnowpackLogger(logger: typeof snowpackLogger) { const messageCache = new Set(); @@ -12,7 +20,7 @@ export function configureSnowpackLogger(logger: typeof snowpackLogger) { logger.on('warn', (message) => { // Silence this output message, since it doesn't make sense for Astro. - if (message.includes(`run "snowpack init" to create a project config file.`)) { + if (neverWarn.test(message)) { return; } console.error(message);