Closed wbotelhos closed 9 months ago
what bundler tool are you currently using?
browser export doesn't have module support, which makes sense. Looks like whatever you're using should be picking up import/require rather than browser.
I'm using esbuild
0.20.0
.
Here is my config:
import { I18n } from 'i18n-js';
const locale = document.documentElement.lang;
import en from '@/translations/en.json';
import ptBR from '@/translations/pt-BR.json';
import ru from '@/translations/ru.json';
const i18n = new I18n();
i18n.store(
{
'en': en,
'pt-BR': ptBR,
'ru': ru,
}[locale]
);
i18n.enableFallback = true;
i18n.defaultLocale = document.documentElement.dataset.defaultLocale;
i18n.locale = locale;
export default i18n;
oh, this has been covered on the readme. Go to the troubleshooting section. :)
It fixed and another lib @glidejs/glide
didn't like it. Maybe I need understand better how all those configs works before upgrade. Any tip here?
19:12:07 js.1 | ✘ [ERROR] No matching export in "../../node_modules/@glidejs/glide/dist/glide.js" for import "default"
19:12:07 js.1 |
19:12:07 js.1 | pages/events/views/events/tickets.js:3:7:
19:12:07 js.1 | 3 │ import Glide from '@glidejs/glide';
19:12:07 js.1 | ╵ ~~~~~
I'll take a look at this tonight.
Ah, looks like we can't assume all packages will export main
as a module export. Try moving main
further down the list on --main-fields
, like --main-fields=module,main,browser
Yep, was able to reproduce this locally. I updated the readme with this new info.
It worked, Nando. Thanks! ❤️
@fnando Unfortunately I got another error, this time it comes from Tippy.js. It's not recognizing the var process
.
ReferenceError: process is not defined
at event.debug-b5100f8117412a9eab692445c8a1940819c880ee47994a770182f1836e8a0846.js:56946:1
(anonymous) @ event.debug-b5100f8117412a9eab692445c8a1940819c880ee47994a770182f1836e8a0846.js:56946
It happens during the import:
import tippy from 'tippy.js';
It's on this part of the code:
var visitedMessages;
if (process.env.NODE_ENV !== "production") { <<<
resetVisitedMessages();
}
I tried the configs:
mainFields: ['module', 'main', 'browser'],
And the:
mainFields: ['import', 'require', 'module', 'main', 'browser'],
Oh, i got this one before. I think you can use something like this: --define:process.env.NODE_ENV="development"
(or production) on the esbuild command.
It worked, Nando. Again, thank you!
Hey, @fnando
I'm no sure if I should keep bringing it to this issue, since it can be outside this lib scope. Let me know if it does not make sense from now on.
I found another problem with tippyjs:
RangeError: Maximum call stack size exceeded
at getWindow (system.debug-faf277173fc11b1de6a001ffccc0787d888b747577cb92cdc1b2d61e49d22bb3.js:26806:19)
at getComputedStyle (system.debug-faf277173fc11b1de6a001ffccc0787d888b747577cb92cdc1b2d61e49d22bb3.js:26999:10)
Looks like there is an issue related to it. For now I'll rollback and wait for a better time to upgrade just it.
I'm thinking about reverting the package.json change because it broke too many projects, unfortunately. 🫠
Just released v4.4.3-beta.0. Can you please give it a try and report back? Thanks!
Now It's working correctly. Hope you can find a full supported solution in the future. Thanks!
just released v4.4.3
Description
Missing export in
browser/index.js
How to reproduce
What do you expect
Import the
I18n
.What happened instead
It's returning void.
Software:
Full backtrace