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

NextJS incompatibility #332

Closed
rqbazan opened this issue Oct 31, 2021 · 8 comments
Closed

NextJS incompatibility #332

rqbazan opened this issue Oct 31, 2021 · 8 comments

Comments

@rqbazan
Copy link
Contributor

rqbazan commented Oct 31, 2021

Hey @angus-c 👋

Seems like the latest version of all the packages has introduced an incompatibility with NextJS apps.

Reproduce

  1. Clone https://github.com/rqbazan/just-and-nextjs-esm-issue
  2. Install all dependencies with yarn
  3. Run the build process: yarn build
  4. Profit!
./node_modules/just-map-values/index.esm.js
Module parse failed: 'import' and 'export' may appear only with 'sourceType: module' (22:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| }
|
> export { objectMapValues as default };
|

Possible solution

  • Change "commonjs" to "module" in package.json

After the change to "type": "module" you can run yarn build ✅:

rm -rf .next && yarn build
@nosovk
Copy link
Contributor

nosovk commented Oct 31, 2021

yep, svelte-kit builds also broke on latest update (and they are "module" from start)

broken build one:
https://github.com/NodeArt/nodeartio/pull/454

accidentally merged broken version
MailCheck-co/mailcheck.site#601
and reverting it restored build
MailCheck-co/mailcheck.site@c8af869

it seems that ESM build isn't correct for now (or it's declaration in package.json)

nosovk added a commit to nosovk/just that referenced this issue Oct 31, 2021
angus-c#332
removing that line will allow autodetect to work correctly.
todo: more build targets available, see: https://github.com/pngwn/MDsveX/blob/master/packages/mdsvex/rollup.config.js
@nosovk
Copy link
Contributor

nosovk commented Oct 31, 2021

#328
that one also should be merged (I was wrong, real problem fixed in that PR) by @PuruVJ

@angus-c
Copy link
Owner

angus-c commented Oct 31, 2021

#328 merged.
Considering other issue now (cc @raulfdm)

angus-c added a commit that referenced this issue Oct 31, 2021
* fix module type detection

#332
removing that line will allow autodetect to work correctly.
todo: more build targets available, see: https://github.com/pngwn/MDsveX/blob/master/packages/mdsvex/rollup.config.js

* replace-all

Co-authored-by: angus croll <anguscroll@gmail.com>
@angus-c
Copy link
Owner

angus-c commented Nov 1, 2021

Should be fixed now #334

@angus-c angus-c closed this as completed Nov 1, 2021
@raulfdm
Copy link
Contributor

raulfdm commented Nov 1, 2021

@angus-c Sorry my absence, I had to stay offline yesterday the whole day...

Curious to understand why nextjs was picking up ESM if the main type was specified to to commonjs.

Anyhow, I'm glad it's fixed. I should've tested in all biggest frameworks (nuxt, next, vite, angular, node, etc) to ensure it's all working perfectly everything. My bad

@angus-c
Copy link
Owner

angus-c commented Nov 9, 2021

yep, svelte-kit builds also broke on latest update (and they are "module" from start)

Hi @nosovk can you check with latest major build? It now uses .mjs suffix for esm module which should be more universally recognized

@PuruVJ
Copy link
Contributor

PuruVJ commented Nov 10, 2021

@angus-c I checked just-shuffle, and it is working in sveltekit, so assumption is that all of em are working. Even I had the same problem with submodules, and renaming ESM outputs to .mjs helped, so all of just packages should also work

@angus-c
Copy link
Owner

angus-c commented Nov 10, 2021

Cool, thanks for confirming @PuruVJ. @nosovk said it also now works for him.

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 a pull request may close this issue.

5 participants