-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strange warning stating that export does not exist when it does #7378
Comments
Perhaps it would be awesome if you could create a simple project that would reproduce your bug and upload on github. |
Interfaces no longer exist after transpiling. For webpack the export doesn't exist. |
True, typescript would remove the interfaces but should also remove the imports. I'm not sure where the warning is coming from (maybe not from webpack itself). I'll do some testing and see if I can figure it out. We never had this happen on webpack 3.10 (were trying to upgrade to 4.8.3). |
I guess, it's related to |
@johnnyreilly Can you help us on this? |
Here is a temp solution: |
The temp solution suggested by @rgripper should work. I'd be open to baking this into ts-loader since it seems to have bitten a few people... Would anyone like to submit a PR? |
On the linked thread I've put details, a suggestion for implementation and an offer of help if someone wants to submit a PR. Let's see what happens! ❤️ 🌻 |
We are facing the same issue using babel-loader with https://babeljs.io/docs/en/babel-plugin-transform-typescript |
The same problem here for TS types/interfaces after migrating from WP3 to WP4, multiple warnings:
I don't use const ts = require('typescript')
const tsconfig = require('tsconfig')
const compilerOptions = tsconfig.loadSync(process.cwd()).config.compilerOptions
module.exports = function (source) {
const result = ts.transpile(source, { ...compilerOptions, ...this.query })
return result
} So it is not a problem of |
Hello. I create simple plugin for suppress this error. 👨💻 https://github.com/igorkamyshev/ignore-not-found-export-plugin |
FWIW I only just started seeing this issue today in one of my react/redux/saga projects after refactoring my code layout from:
to
to try to organize the growing project a bit more. Not sure if the duplicate filenames across feature folders could have anything to do with this weird warning display issue. And because more detail doesn't hurt with debugging, in my particular case the exported function names don't match the filenames right now. They currently look like: // feature-A/reducers.js :
export default function featureAReducer(...) {} instead of // feature-A/reducers.js :
export default function reducers(...) {} Hope this helps with the debugging. In the meantime, @igorkamyshev 's plugin looks good. Webpack version info:
|
Update: Some of the files the warnings fired for had both |
@anjunatl, yours seems to be a different issue. This one is about exporting interfaces in typescript and is well understood. There is a comment somewhere explaining it really well, but I currently can not find it. Basically the typescript compiler emits no code for interfaces, so webpack can not find them in the compiled module; except when a module consists of only interfaces. In that case the module will end up completely empty and then webpack will not investigate the exports. You should probably create a new issue for your problem. |
@igorkamyshev somehow, no matter using stats or your plugin, I'm still getting errors :/ |
Sorry, it was deprecated. =( |
Is there currently a way to suppress these errors? I'm not having any luck with Webpack's |
For client at least you can: devServer: { clientLogLevel: 'error' } }
…On Wed, May 8, 2019 at 12:55 PM Elliot Bonneville ***@***.***> wrote:
Is there currently a way to suppress these errors? I'm not having any luck
with Webpack's stat config.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#7378 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAC6RCCN7MRL2BT4JWE3M3PUMV2ZANCNFSM4FBLAUOQ>
.
|
Thanks, @natew. Is there anything more specific? I'd like to leave other warnings intact. |
Maybe this is not a bug, its a feature! (tm) :) When you export your TS interfaces/types in such a style so that it comply with TS's isolatedModules=true, then you won't get these webpack warnings.
|
I think @MarekLacoAXA's comment nails the issue for me. I had this error because I was exporting types the same way I was exporting constants. I then split them and used // ActionNames is a const and ActionTypes is a type
// Before
export { ActionNames, ActionTypes } from "./ActionTypes";
// Above line resulted in warning
// > "export 'ActionPayload' was not found in './ActionTypes'
// Changed the code to the following for the warning to disappear
export { ActionNames } from "./ActionTypes";
export type ActionPayload = ActionPayload;
|
@pcx thank you. This actually fixed some huge problem I was having with barrel files. Basically just need to specify the interface to export rather than |
I have this issue as well. I've doubled checked my exports but I'm using the correct style. |
Have you tried the following?
|
I got this warning once I upgraded to typescript from 3 to 4. Webpack is 4. From a first peak it seems to reproduce only in files that export only types / interfaces and also import some other types / interfaces from elsewhere.
@sokra I am not sure what is going on here. But I was on typescript Since compilation works, I'll probably ignore this issue, unless someone has a solution for this. |
fix: 修复ts interface导出警告 & 规范各个组件导出 主要解决ts编译interface导出不被webpack识别的警告 参考issue:webpack/webpack#7378
@andresesfm |
@andresesfm I have an index.ts file which reexports the types. Using |
Is there any way to treat these warnings as errors? I want my build to fail if it shows up. Currently both build and type check ( |
@elado You can set That still allows mixed imports, consisting of both types & values. If you want to ensure types are only imported via |
Marking interface imports and exports with 'type' prevents them from being exposed after transpilation, thus eliminating ugly warnings of 'name not found'. Refs: webpack/webpack#7378, microsoft/TypeScript#28481
Back. Now updated to webpack 5. So yeah, what about dynamic / start exports? export * from './Service/IApiAuthProvider'; My generated types file. declare namespace api {
interface IApiAuthProvider {}
class ApiAuthProvider {}
}
// other namespaces Imported in webpacked project as. import {api} from 'my-module';
import IApiAuthProvider = api.IApiAuthProvider; How should I handle this? As |
Adding the following will silence the warnings from webpack: module.exports = {
...
module: {
parser: {
javascript: {
reexportExportsPresence: 'false',
},
},
},
...
}; |
In my case I started getting these warnings after restructuring my project. The project is Spring Boot + React and I had previously kept the JS files under the In my webpack config, I initially had:
.. after moving everything in to
.. which resulted in the warnings. I was able to prevent the warnings by updating that to
No idea if this is correct or not but the warnings went away 🤷 |
@mwalkerr |
It should be: |
Is there a reason you would want |
The following works for me:
I was getting this warning on all imports on types in my project after upgrading WebPack 4.41.6 to 5.74.0. It's a large project, so it would not be possible to refactor to type imports everywhere. |
@mpenney99 actually you can use eslint to do it for you https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/consistent-type-imports.md |
This adds a new `client-entry-type.ts` file in order to avoid exporting interfaces from `client-entry.ts` directly, which a) causes warnings at build time (see webpack/webpack#7378) and also makes the exported interfaces appear in the js dist file, which we don't want. The only purpose of this file is to export the type of the init function from `client-entry.ts` and other interfaces that may be useful for consumers. Bug: T342235 Change-Id: I71fb071bcd7dafa817e22ff04d8bfcefcd9a26e1
Try changing from To |
Bug report
What is the current behavior?
Not sure if this is a problem with a loader or webpack itself, but on a project that is using typescript, I'm getting a warning:
However, the file in question _types/IValidation, is imported in numerous other files without any warnings being emitted related to those other files that are also importing IValidation from _types/IValidation.
The contents of the file are simple, and there is an "export interface IValidation" in the file:
We do have our "src" directory set as a module resolution root in the resolve section of our webpack config, but I also tried importing the file with a relative path and still get the warning.
I am kind of wondering if this is related to typescript. We are using ts-loader, but we have it doing type checking only and are doing transpiling with babel.
If the current behavior is a bug, please provide the steps to reproduce.
Not sure since I get the warning due to the import of the file in question in one file but not due to several other files that also import the same interface from the same file.
What is the expected behavior?
It should not issue a warning about a missing export if the export clearly exists.
Other relevant information:
webpack version: 4.8.3
Node.js version: 8.9.1
Operating System: Windows 10
Additional tools: webpack-cli 2.1.3
The text was updated successfully, but these errors were encountered: