developit / nextjs-preact-demo

Next.js 9.3 + Preact = 21kB
https://nextjs-preact.now.sh
384 stars 25 forks source link

Errors in dynamic imports are silenced #14

Open onlyfortesting opened 4 years ago

onlyfortesting commented 4 years ago

Current Behavior

no page error, no console output, no term output.

Steps to Reproduce (for bugs)

// pages/index.js
import dynamic from 'next/dynamic'
const TestLoader = dynamic(import('../components/Test'), { ssr: false})
export default () => <TestLoader />

// components/Test.js
throw new Error('test')
export default () => <div>hello</div>
developit commented 4 years ago

seems like an aliasing bug where next/dynamic is getting a copy of react. I haven't tried this yet, will have to in order to see what's going on.

barelyhuman commented 3 years ago

@developit @onlyfortesting You're better off reporting that to the next team since it doesn't work on the official next template either.

As for why it works on the default import is as the file is executed as a node module before reading the component , thus breaking on the normal.

Changing it to this

const error = ()=>{
  throw new Error("test");
}

const Test = () => {
  error();
  return <div>hello</div>;
};

export default Test;

Gave me the requested error.

Though if you are seeing this happen in a project, please create a similar snippet, would help in debugging