Webpack: Throw error on missing member import

后端 未结 2 1193
猫巷女王i
猫巷女王i 2021-02-12 18:08

I have an import something like this:

import { foo } from \'bar\';

Is there a way to get Webpack to throw an error if foo is not d

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-12 18:31

    As Tobias K pointed out in the comments, the other answer is incorrect. Configuring strictModuleExceptionHandling: true will not produce a compile time error if you try to import a module which does not exist.

    The correct configuration is strictExportPresence: true, which is only available in webpack v2.3.0 and later. (Earlier versions can only show a warning, not an error.)

提交回复
热议问题