Skip to content
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

Build fails with "Attempted import error" after updating @neutrolinojs/lib to 5.1.0 #110

Open
jeffwtm opened this issue Apr 27, 2024 · 3 comments

Comments

@jeffwtm
Copy link

jeffwtm commented Apr 27, 2024

I'm experiencing a build failure after updating @neutrolinojs/lib to 5.1.0:

Failed to compile.

Attempted import error: 'filesystem' is not exported from '@neutralinojs/lib' (imported as 'filesystem').

Steps to repro:

  1. Create new app using neu create myapp --template codezri/neutralinojs-react (as specified here: https://neutralino.js.org/docs/getting-started/using-frontend-libraries)
  2. cd to myapp/react-src
  3. Update @neutrolinjs/lib by running npm install @neutralinojs/[email protected] (as specified here: https://github.com/neutralinojs/neutralino.js/releases/tag/v5.1.0)
  4. Attempt to build: npm run build from react-src or neu build from myapp directory

I've also tried this in a pre-existing project with TypeScript and gotten the same result. Strangely, running tsc directly compiles without errors in that project, but running the build script fails with the same "Attempted import error".

Let me know if there's any other info I can provide, and thank you!

Neu cli v 11.0.1
macOS 14.0
Node 18.20.2

@calebmpeterson
Copy link

calebmpeterson commented May 5, 2024

Seems to work okay when I downgrade to @neutralinojs/[email protected]

@calebmpeterson
Copy link

Seems to work okay when I downgrade to @neutralinojs/[email protected]

Or maybe not... I don't get the typescript-related error, but I'm seeing errors in the devtools console of the running app.

@m4uz
Copy link

m4uz commented May 17, 2024

I faced the same issue while following the Using any frontend library guide and decided to do some digging.

I'm using neutralino version 5.1.0, and was able to get rid of the problem by explicitly importing the function as the following:
import { filesystem } from "@neutralinojs/lib/dist/neutralino"
Of course, if you follow the guide, you'll eventually encounter the same issue with the init function. Again, I was able to get it working by explicitly importing the function as:
import { init } from "@neutralinojs/lib/dist/neutralino";
So that is a quick fix.

Now, my knowledge is not particularly strong in the Javascript ecosystem mess, so I'm putting here my findings. Hopefully somebody could provide some expertise on what could be the actual issue. As a use-case, I'll be talking in the context of the init function.
Looking into the neutralino package sources, it's @neutralinojs/lib/package.json specifies the main entry to be @neutralinojs/lib/dist/index.js:

{
  ...some stuff...
  "main": "./dist/index.js",
  ...other stuff...
}

The init function is exported in CommonJS format there:

exports.init=function(t={}){if(t=Object.assign({exportCustomMethods:!0}, ..etc...

As oposed to @neutralinojs/lib/dist/neutralino.d.mts (or @neutralinojs/lib/dist/neutralino.mjs), where the function is exported in the ESM format:

export { ...some stuff..., init, ...other stuff... }

So, it seems like letting npm to explicitly use EMS-exported functions works, although to my knowledge it should work either way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants