Skip to content

Explicitly import index.js #5

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

Closed

Conversation

i-am-the-slime
Copy link
Member

Because in my tests node cries around (heult rum):
code: 'ERR_UNSUPPORTED_DIR_IMPORT',

Because in my tests node cries around:
`  code: 'ERR_UNSUPPORTED_DIR_IMPORT',`
@andys8
Copy link
Member

andys8 commented Feb 22, 2023

Oha, I'm a bit surprised /index.js would be necessary and make a difference, but probably can do. Not how I would expect it to import.

Screenshot_2023-02-22-17-21-43-96_4d38fce200f96aeac5e860e739312e76

Have to take a look why everything gets resorted. Probably missing in the script to have determinism in the order if icons.

@andys8
Copy link
Member

andys8 commented Feb 22, 2023

Still looking into this, since fixing it to index.js would exclude index.esm.js. I'm wondering if this could lead to new issues. Or if it is fixed, if it should actually be the index.esm.js version.

The other way would be --experimental-specifier-resolution=node as argument for node, but if appending the specific file is a fix, I would merge do it (because it's easier to use).

@i-am-the-slime Could you double check if index.esm.js would also work for your project?

@i-am-the-slime
Copy link
Member Author

Just looking at this. Didn't see the notification, sorry.
--experimental-specifier-resolution=node is unfortunately already deprecated again.
I think yes, we should try with index.esm.js and I will try that in my branch now.

@i-am-the-slime
Copy link
Member Author

I don't know anymore:

SyntaxError: Named export 'BsAlarm' not found. The requested module 'react-icons/bs/index.esm.js' is a CommonJS module, which may not support all module.exports as named exports.

@i-am-the-slime
Copy link
Member Author

i-am-the-slime commented Mar 23, 2023

I could work around it something like this in package.json:

    "test": "spago build && esbuild test.mjs --platform=node --bundle > test.js && node test.js",

And test.mjs is just the stupid:

import { main } from "./output/Test.Main/index.js"

main()

@i-am-the-slime
Copy link
Member Author

image

And then I get this

@andys8
Copy link
Member

andys8 commented Mar 23, 2023

So, index.esm.js didn't work? Can you share details about the test runner / setup?

I mean we can go for commonjs. I'm just a bit afraid there is chance it will break regular projects.

@i-am-the-slime
Copy link
Member Author

I think I'm hitting this:
vercel/next.js#39375

@i-am-the-slime
Copy link
Member Author

@andys8 I think the best "solution" is to use the folder imports as on main. None of the other things work properly in one environment or another.

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

Successfully merging this pull request may close these issues.

2 participants