2

Is there a way to get a warning/error message when imports are undefined, i.e. not declared in a file that I am importing from?

// file1.js export const var1 = 'var1' // file2.js import { var2 } from './file1' var2() // this will throw an error 

How to solve this issue?

I am using webpack in version 3.11.0

4
  • First, what is your scenario? Because this is a perfect example of the "compiler" helping you out. Commented Aug 6, 2018 at 11:21
  • I've moved like ~300files and want to make sure every import works correctly Commented Aug 6, 2018 at 12:49
  • Would this really makes sense? If you are trying to import something that does not exists, it would break when the code tries to get required anyways. Commented Aug 6, 2018 at 13:47
  • It doesn't break when the code tries to get required. It breakes when the code gets executed - unfortunately Commented Aug 6, 2018 at 16:34

1 Answer 1

2

Yes, you can use module.strictExportPresence:

{ module: { strictExportPresence: true } }

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.