antlr4 icon indicating copy to clipboard operation
antlr4 copied to clipboard

Upgrading from 4.13.0 to 4.13.1 causes rollup/build failure

Open kaiyoma opened this issue 2 years ago • 13 comments

Doing a simple upgrade in our project has resulted in this:

00:37:47  [commonjs--resolver] Failed to resolve entry for package "antlr4". The package may have incorrect main/module/exports specified in its package.json.

kaiyoma avatar Sep 12 '23 15:09 kaiyoma

Probably a duplicate of #4411 ? If so it's already fixed.

ericvergnaud avatar Sep 12 '23 15:09 ericvergnaud

Does antlr 4.13.2 have an expected release date to correct this bug? 🙏

ncordon avatar Sep 18 '23 10:09 ncordon

Does antlr 4.13.2 have an expected release date to correct this bug?

du0ngtrunghieu avatar Sep 20 '23 01:09 du0ngtrunghieu

Does antlr 4.13.2 have an expected release date to correct this bug? :-)

jonaskello avatar Oct 26 '23 08:10 jonaskello

Same ? Any fixes?

atfops avatar Nov 09 '23 16:11 atfops

Just published 4.13.1-patch-1.

ericvergnaud avatar Nov 10 '23 08:11 ericvergnaud

The patched version works with a rollup build, thanks @ericvergnaud.

aovcina avatar Nov 27 '23 10:11 aovcina

Was working with patch last week but now not working anymore.

Following error :

23.06 [commonjs--resolver] Failed to resolve entry for package "antlr4". The package may have incorrect main/module/exports specified in its package.json.
23.06 [vite-plugin-sveltekit-compile] Failed to resolve entry for package "antlr4". The package may have incorrect main/module/exports specified in its package.json.
23.06 ✓ built in 20.30s
23.08 error during build:
23.08 Error: Failed to resolve entry for package "antlr4". The package may have incorrect main/module/exports specified in its package.json.
23.08     at packageEntryFailure (file:///app/node_modules/vite/dist/node/chunks/dep-df561101.js:28691:11)
23.08     at resolvePackageEntry (file:///app/node_modules/vite/dist/node/chunks/dep-df561101.js:28688:5)
23.08     at tryNodeResolve (file:///app/node_modules/vite/dist/node/chunks/dep-df561101.js:28419:20)
23.08     at Object.resolveId (file:///app/node_modules/vite/dist/node/chunks/dep-df561101.js:28180:28)
23.08     at file:///app/node_modules/rollup/dist/es/shared/node-entry.js:25544:40
23.08     at async PluginDriver.hookFirstAndGetPlugin (file:///app/node_modules/rollup/dist/es/shared/node-entry.js:25444:28)
23.08     at async resolveId (file:///app/node_modules/rollup/dist/es/shared/node-entry.js:24117:26)
23.08     at async ModuleLoader.resolveId (file:///app/node_modules/rollup/dist/es/shared/node-entry.js:24531:15)
23.08     at async Object.resolveId (file:///app/node_modules/vite/dist/node/chunks/dep-df561101.js:7910:10)
23.08     at async PluginDriver.hookFirstAndGetPlugin (file:///app/node_modules/rollup/dist/es/shared/node-entry.js:25444:28)
------
failed to solve: executor failed running [/bin/sh -c npm run build]: exit code: 1

Any ideas ?

atfops avatar Nov 29 '23 08:11 atfops

@theolurat Latestversion is 4.13.1-patch-1, released 3 weeks ago, so must be at your end

ericvergnaud avatar Nov 29 '23 09:11 ericvergnaud

Yes i'm actually using 4.13.1-patch-1 and got this error.

There is my package.json :

...
 "dependencies": {
		...
		"antlr4": "^4.13.1-patch-1",
		...
 }
...

atfops avatar Nov 29 '23 09:11 atfops

In fact, my bad was the ^ to remove in package files. So it's working with :

...
 "dependencies": {
		...
		"antlr4": "4.13.1-patch-1",
		...
 }
...

Thanks to dev team in my project :) .

atfops avatar Nov 29 '23 09:11 atfops

I couldn't make rollup work not even with the 4.13.1-patch-1 version; I created the minimal repro here: https://github.com/andreagentili/antlr-issue-4.13.1

Anyway what I get when building using rollup is:

$ npm install
$ npm run build

> [email protected] build
> rollup -c --bundleConfigAsCjs


src/index.ts → out...
(!) Plugin node-resolve: Could not resolve import "antlr4" in ./src/index.ts using exports defined in ./node_modules/antlr4/package.json.
(!) Plugin node-resolve: Could not resolve import "antlr4" in ./src/grammar/LanguageParser.ts using exports defined in ./node_modules/antlr4/package.json.
(!) Plugin node-resolve: Could not resolve import "antlr4" in ./src/grammar/LanguageVisitor.ts using exports defined in ./node_modules/antlr4/package.json.
(!) Plugin node-resolve: Could not resolve import "antlr4" in ./src/grammar/LanguageLexer.ts using exports defined in ./node_modules/antlr4/package.json.
(!) Plugin node-resolve: Could not resolve import "antlr4" in ./src/grammar/LanguageListener.ts using exports defined in ./node_modules/antlr4/package.json.
(!) Unresolved dependencies
https://rollupjs.org/troubleshooting/#warning-treating-module-as-external-dependency
antlr4 (imported by "src/index.ts", "src/grammar/LanguageParser.ts", "src/grammar/LanguageVisitor.ts", "src/grammar/LanguageLexer.ts" and "src/grammar/LanguageListener.ts")
created out in 409ms

Really stuck by now...

andreagentili avatar Jul 11 '24 07:07 andreagentili

Fixed! It's incredible how many issues can be solved when you just try explaining the problem to others. In my case I just needed to configure rollup to use node-resolve with exportConditions: ["node"] flag, and it worked correctly.

andreagentili avatar Jul 11 '24 08:07 andreagentili