import "mod" in api_esm.mjs leads to crash if bundling with webpack
See original GitHub issueHi, I am bundling Chevrotain with Webpack in my Argdown language-server. This currently creates a lot of the following warnings:
WARNING in ../argdown-core/node_modules/chevrotain/lib_esm/api_esm.mjs 11:27-42
export 'default' (imported as 'mod') was not found in '../lib/src/api.js' (possible exports: Alternation, Alternative, CstParser, EMPTY_ALT, EOF, EarlyExitException, EmbeddedActionsParser, GAstVisitor, Lexer, LexerDefinitionErrorType, MismatchedTokenException, NoViableAltException, NonTerminal, NotAllInputParsedException, Option, Parser, ParserDefinitionErrorType, Repetition, RepetitionMandatory, RepetitionMandatoryWithSeparator, RepetitionWithSeparator, Rule, Terminal, VERSION, __esModule, clearCache, createSyntaxDiagramsCode, createToken, createTokenInstance, defaultLexerErrorProvider, defaultParserErrorProvider, isRecognitionException, serializeGrammar, serializeProduction, tokenLabel, tokenMatcher, tokenName)
So Webpack uses the ESM Version for bundling and does not find the default export from lib/src/api.js
that is imported in api_esm.mjs
. Ignoring the warnings and testing the language-server by starting the Argdown VSCode extension leads to an immediate crash.
If I make the following change in the first line of api_esm.mjs
, the warnings during the build process disappear and the language server no longer crashes:
import * as mod from "../lib/src/api.js";
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Webpack-bundled code crashes when both `import` and ...
Our Webpack bundle contains placeholders for the dynamic import of icons. An example dynamic import is as follows:
Read more >Externals - webpack
Prevent bundling of certain import ed packages and instead retrieve these external dependencies at runtime. For example, to include jQuery from a CDN ......
Read more >Introduction to Webpack. Module bundling, Loaders, Plugins…
Webpack is a module bundler for modern JavaScript applications. The import and export statements have been standardized in ES2015. They are not supported...
Read more >Bundlers | SheetJS Community Edition
SheetJS predates ECMAScript modules and bundler tools like Webpack. ... The xlsx.mjs source file are written in a subset of ES6 that esbuild...
Read more >webpack on twitter.com
If you have 15 minutes, this “Webpack from First Principles” screencast ... For loading and bundling JS files, we used two libraries: loadrunner...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi again, I finally solved my webpack issues today and quickly wanted to report my findings. The problem was caused by my
webpack.config.js
. For some reason (unknown to me) it contained the following problematic module rule:Removing this rule or changing the type to
javascript/esm
fixed the bundling issues with chevrotain.I will close this for now. Feel free to re-open if needed