oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.32k stars 2.78k forks source link

BuildMessage/ResolveMessage should extend `Error` #7531

Open paperdave opened 11 months ago

paperdave commented 11 months ago

What version of Bun is running?

No response

What platform is your computer?

No response

What steps can reproduce the bug?

Side effect of #7526 is we arent printing the error message

image

What is the expected behavior?

error with a stacktrace not undefined

What do you see instead?

No response

Additional information

No response

Electroid commented 7 months ago

Related: #6730

eslint breaks because it is overriding the message property, since it expects the error to extend Error. But BuildMessage and ResolveMessage do not extend Error.

Electroid commented 7 months ago

We have to fix this properly @Jarred-Sumner, same issue as #9989

try {
  const module = await import(
    /* @vite-ignore */
    path
  );
  if (!module.default) {
    throw new Error(`Missing or invalid default export. Please export your Expressive Code config object as the default export.`);
  }
  return module.default;
} catch (error) {
  const msg = error instanceof Error ? error.message : error;
  // Since `error instanceof Error` is false, msg becomes `ResolveMessage`
  const code = error.code;
  if (code === "ERR_MODULE_NOT_FOUND" || code === "ERR_LOAD_URL") {
    if (msg.match(/ec\.config\.mjs.*(imported from|resolved id)/))
    // This line then fails with: `msg.match is not a function`
      continue;
  }
  throw new Error(
    `Your project includes an Expressive Code config file ("ec.config.mjs")
    that could not be loaded due to ${code ? `the error ${code}` : "the following error"}: ${msg}`.replace(/\s+/g, " "),
    error instanceof Error ? { cause: error } : void 0
  );
}
dealmengor commented 4 months ago

Hi are we able to use Bun with Astro starlight?

Frikadellios commented 3 months ago

Hi all, I am use it without any troubles.

You need just to add ec.config.mjs I am use this config:

` import { pluginCollapsibleSections } from '@expressive-code/plugin-collapsible-sections' import { pluginLineNumbers } from '@expressive-code/plugin-line-numbers'

/* @type {import('@astrojs/starlight/expressive-code').StarlightExpressiveCodeOptions} / export default { plugins: [ // Call the plugin initialization function inside the plugins array pluginCollapsibleSections(), pluginLineNumbers(), ], themes: ['material-theme-ocean', 'material-theme-palenight'], } ` Another thing its Cloudflare with bun adapter and SSR.

I cant configurate Pagefind..