Importing the package with NPM and Webpack causes build warnings
See original GitHub issueHi, first of all thanks for this awesome package! It is really useful and allows to use full power of TypeScript without much hassle. 👍
Unfortunately, there are some build warnings when you import the package via NPM and load it with Webpack. This is related to #24 . After following the steps there I’ve managed to hide most of the errors and warnings by excluding the /tests/ folder from Webpack. This is not a big problem. But there are two errors that are left after doing so:
[0] WARNING in ./~/typedjson/js/index.js
[0] Critical dependencies:
[0] 25:24-31 require function is used in a way in which dependencies cannot be statically extracted
[0] @ ./~/typedjson/js/index.js 25:24-31
[0]
[0] WARNING in ./~/typedjson/js/index.d.ts
[0] Module parse failed: C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\typedjson\js\index.d.ts The keyword 'interface' is reserved (23:0)
[0] You may need an appropriate loader to handle this file type.
[0] SyntaxError: The keyword 'interface' is reserved (23:0)
[0] at Parser.pp$4.raise (C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\acorn\dist\acorn.js:2221:15)
[0] at Parser.pp$3.parseIdent (C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\acorn\dist\acorn.js:2182:14)
[0] at Parser.pp$3.parseExprAtom (C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\acorn\dist\acorn.js:1774:21)
[0] at Parser.pp$3.parseExprSubscripts (C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\acorn\dist\acorn.js:1715:21)
[0] at Parser.pp$3.parseMaybeUnary (C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\acorn\dist\acorn.js:1692:19)
[0] at Parser.pp$3.parseExprOps (C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\acorn\dist\acorn.js:1637:21)
[0] at Parser.pp$3.parseMaybeConditional (C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\acorn\dist\acorn.js:1620:21)
[0] at Parser.pp$3.parseMaybeAssign (C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\acorn\dist\acorn.js:1597:21)
[0] at Parser.pp$3.parseExpression (C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\acorn\dist\acorn.js:1573:21)
[0] at Parser.pp$1.parseStatement (C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\acorn\dist\acorn.js:727:47)
[0] at Parser.pp$1.parseTopLevel (C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\acorn\dist\acorn.js:638:25)
[0] at Parser.parse (C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\acorn\dist\acorn.js:516:17)
[0] at Object.parse (C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\acorn\dist\acorn.js:3098:39)
[0] at Parser.parse (C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\webpack\lib\Parser.js:902:15)
[0] at DependenciesBlock.<anonymous> (C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\webpack\lib\NormalModule.js:104:16)
[0] at DependenciesBlock.onModuleBuild (C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\webpack-core\lib\NormalModuleMixin.js:310:10)
[0] at nextLoader (C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\webpack-core\lib\NormalModuleMixin.js:275:25)
[0] at C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\webpack-core\lib\NormalModuleMixin.js:259:5
[0] at Storage.provide (C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:52:20)
[0] at CachedInputFileSystem.readFile (C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:140:24)
[0] at DependenciesBlock.onLoadPitchDone (C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\webpack-core\lib\NormalModuleMixin.js:255:7)
[0] at DependenciesBlock.loadPitch (C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\webpack-core\lib\NormalModuleMixin.js:182:27)
[0] at DependenciesBlock.doBuild (C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\webpack-core\lib\NormalModuleMixin.js:241:4)
[0] at DependenciesBlock.build (C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\webpack\lib\NormalModule.js:84:14)
[0] at Compilation.buildModule (C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\webpack\lib\Compilation.js:126:9)
[0] at C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\webpack\lib\Compilation.js:309:10
[0] at C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\webpack\lib\NormalModuleFactory.js:58:13
[0] at NormalModuleFactory.applyPluginsAsyncWaterfall (C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\tapable\lib\Tapable.js:75:69)
[0] at onDoneResolving (C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\webpack\lib\NormalModuleFactory.js:38:11)
[0] at onDoneResolving (C:\Code\aft\aft-seed-integration\accsoft-aft-server\src\resources\node_modules\webpack\lib\NormalModuleFactory.js:121:6)
[0] @ ./~/typedjson/js ^\.\/.*$
Later I found out that I should import directly TS files instead of JS. I’ve tried to change the imports to proper ones, but there is one problem. You are allowing the usage of implicit any, whereas we don’t. Therefore including TS code instead of JS code causes to show even more errors in the console. AFAIK so far there is no other solution than to switch off the ‘implicit any’ check for our TSC.
I’d like to ask - are you planning to do something about this? It would be very nice to have a way to include this package without having warnings and without having to turn off ‘implicit any’ check for the whole project. The easiest solution would be I guess to modify the code and switch on the ‘implicit any’ check in your package. However you’re the only one that can do it if we want to import this package via NPM. Are you willing to fix that or maybe accept a pull request? I’d be happy to help if you don’t have time to do so. 👍 If anyone has some other solution, please let me know here.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
You don’t need to apologize, I’m grateful for creating this package! 👍
Are you willing to accept pull requests? I see that you have limited resources to work on this and I could spend some time this week on it. 👍
Hi @mc-suchecki
I appreciate you taking time for such a detailed issue. I will soon have time to work on TypedJSON again (a week maybe), and among other things I will address these warnings which arise quite frequently when using webpack. You are spot on about what the error is, and indeed, I did mean TypedJSON to be compiled with other typescript source – the npm files were added later by a generous contributor.
Either way, I apologize about the inconvenience, it will be resolved ASAP.