bundle-tools icon indicating copy to clipboard operation
bundle-tools copied to clipboard

Weird json external file loading

Open shaan1974 opened this issue 3 years ago • 4 comments

Reporting a bug?

I got a weird behaviour when i add sometime a sub node into my json related to the languages. The weirdest thing is that when i'm working in dev it's ok , this error only append with the build version.

In the screenshot below, if i remove the node "p" with ( v and z inside ) the error disapear.

Module versions (please complete the following information):

  • @intlify/vue-i18n-loader: 2.0.3
  • vue-i18n: 9.0.0
  • vue: ^3.0.11

Screenshots image

End my structure.

Generated code with build

image

The "undefinediundefined" line is created into the build code.

If i remove the node "p" in my json i got this in source code

image

So in the line before $e.render = Me , undefinedundefined is not existing.

By the way thanks for your great work.

Comment.

It's seems that if i put my json file content into "https://jsonformatter.curiousconcept.com/" online tool and after i get the formatted result and i paste it into my json file it's working perfectly. Could be problem of indentation ?

shaan1974 avatar Apr 03 '21 16:04 shaan1974

Thank you for your feedback!

That’s weirdest… my first step, I’ll try to reproduce from your feedback.

kazupon avatar Apr 05 '21 03:04 kazupon

As i'm building a big simple page application it's quite difficult to give you a concrete example ( sorry ).

But as i said before i resolve the problem with an online json "formatting" tool. Now i'v install "Pretty JSON" in my Visual Studio code to avoid this online tool. It's like some tabulations, indentations or spaces are causing this problem.

By the way thanks for all your work.

shaan1974 avatar Apr 05 '21 05:04 shaan1974

Just switched to using vue-i18n-loader (due to CSP) and I'm seeing something similar:

Uncaught ReferenceError: undefinedundefinedundefinedundefinedundefinedundefinedundefined is not defined

I'm using a JSON file and have been trying to see if there are specific keys that are causing the problem. What seems to trigger it (sometimes) are empty lines between each entry. That said, it's not a 100% reliable way to trigger it, for example:

{ "foo": "bar", "more": "cowbell" } The above is fine.

`{ "foo": "bar",

"more": "cowbell" }` This is also fine.

But add two dozen empty lines between the two and you'll get

Uncaught ReferenceError: undefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefined is not defined

For my case the empty lines were not contiguous - the example above is just the fastest way I found to replicate with a nearly empty JSON file. It seems a little like a threshold of empty lines are reached and then it starts to fail (but I'm not certain of that).

bradleydwyer avatar Apr 15 '21 07:04 bradleydwyer

@shaan1974 @bradleydwyer This problem may be caused by the same reason as #32. We now disable the source map of yaml and json file by default to avoid #32 and has released v3.0.0. Can you test this with v3.0.0 and see what happens? Thanks.

PeterAlfredLee avatar Aug 16 '21 08:08 PeterAlfredLee

vue-i18n-loader will be deprecated near the future We can use unplugin-vue-i18n Thanks

kazupon avatar Nov 16 '22 01:11 kazupon