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

Unexpected Token error when loading pkmn/sim library? #10

Closed
MattCastellana opened this issue Jul 19, 2021 · 3 comments
Closed

Unexpected Token error when loading pkmn/sim library? #10

MattCastellana opened this issue Jul 19, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@MattCastellana
Copy link

Hi there!

I've been experiencing an issue here with trying to compile a script with specifically @pkmn/sim installed. (Doesn't seem to happen with other @pkmn libraries from what I can see.)

My setup is using Vue+Typescript / webpack.

Here's the specific error I'm getting:

in ./node_modules/@pkmn/sim/build/sim/dex.js

Module parse failed: Unexpected token (102:20)
You may need an additional loader to handle the result of these loaders.
|             return dexes['base'];
|         const modid = exports.toID(mod);
>         if (modData?.Types && !modData.TypeChart)
|             modData.TypeChart = modData.Types;
|         if (modData?.Species && !modData.Pokedex)

It also returns the same error (Unexpected token) in multiple other files (battle-stream.js(163:40), teams.js(31:42), streams.js(340:17), etc.)

In the code itself, I simply have import dex from '@pkmn/sim' at the top of my file. No other code there yet (Besides default vue items), so it's failing on the import for some reason. I've noticed this happens no matter what class I load from sim as well. If I load BattleStreams, RandomPlayerAI, etc. they will all return the same error at the same location.

This doesn't happen when I use import dex from '@pkmn/dex' ironically, so I think it's something specific with the sim library itself.

Any help on this would be greatly appreciated!

Thanks

@MattCastellana MattCastellana added the bug Something isn't working label Jul 19, 2021
@scheibo
Copy link
Contributor

scheibo commented Jul 19, 2021

It seems to be complaining about the optional chaining operator? You may need to update your Node version or configure Webpack with a Babel transform to cross compile that away (though I believe Webpack 5 should already do this by default?)

@scheibo
Copy link
Contributor

scheibo commented Aug 4, 2021

Please reopen with more details if this is still an issue, but I don't think this is an issue with this repository so much as with your project and it's configuration.

@scheibo scheibo closed this as completed Aug 4, 2021
@MattCastellana
Copy link
Author

@scheibo (Sorry for the delayed response!). Yeah, looks like it. I did some testing and it's definitely something on my end, configuration wise. For some reason my webpack is compiling the optional chaining in my files, but not in loaded modules (Like this one). No idea what's causing it, but definitely not an issue with the library.

Thanks for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants