Closed luis-pato closed 2 years ago
@luis-pato thanks for the detailed issue report here, unfortunately I'm still not able to replicate the issue locally.
I'm trying a test with the following code:
const { parse } = require('es-module-lexer');
parse(`
export function getRandomEmoji() {
const emojis = ['๐', '๐ฆ', '๐งช'];
return emojis[Math.floor(Math.random() * emojis.length)];
}
`).then(([imports, exports]) => {
console.log(imports);
console.log(exports)
console.log('Parse Ok');
}, (err) => {
console.error(err);
console.error('Parse Error');
});
The line number of the error stack wasn't for the 0.7.1 version either so I wasn't able to verify where the error was being thrown from that stack.
If you have more information or a replication and I can look into this further.
oh, i'm sorry, that screenshot was from before i added the 0.7.1 version to the project. Here is a new screenshot
i'm not sure how i can create a working example of the problem, but i could add you as contributor to the project where i have the problem, so you could try it on your own.
It may be that the problem comes from somewhere else along the stack, but i am not experienced enough to determine that.
@luis-pato it sounds to me like the issue is that dev-server-core
is not passing a string to es-module-lexer. I'd suggest following it up further there.
thanks, i'll try that
This is definitely an encoding issue not a bug, but please post back if I'm wrong.
Also add <meta charset=utf-8>
to your HTML!
I have used the open-wc project generator to create a project using lit (with
npm init @open-wc
). Everything was woking great, until i created a function that returns a random emoji from an emojis array. When i had this function on the component file, it worked well. I moved this function to an extra file, where i export it, and now when i runnpm run start
i get aTypeError: A.charCodeAt is not a function
Error.Expected behavior
I expected moving the function to an extra file wouldn't break starting up the server
Actual Behavior
After i moved the function to its own file and import it on my component i get a
TypeError: A.charCodeAt is not a function
Error:Additional context
this is the function i have on the
getRandomEmoji.js
file:i import it on my component like this:
and then i use it like this:
Packages and dependencies
and
Things i have tried
If i change the emojis array into a strings array (for instance
const emojis = ['a', 'b', 'b'];
) then it works. So i wonder if this is some kind of encoding problem, and if i can change something on the server config to fix the problem...?!The open-wc project creator used an older lexer version (0.4.1). I have updated it on my local project to version 0.7.1 but that didn't fix the problem