twilio-professional-services / flex-project-template

A starting point for Twilio Flex projects, providing management strategies for various types of artifacts and distributed development
https://twilio-professional-services.github.io/flex-project-template/
Apache License 2.0
63 stars 68 forks source link

Unexpected token on emoji-mart #647

Open pedrolucasfv opened 2 days ago

pedrolucasfv commented 2 days ago

I'm trying to update my flex-project template with the upstream and i getting this error. I was using the command twilio plugins:install @twilio-labs/plugin-flex@7.0.0

Failed to compile plugin plugin-flex-ts-template-v2.
./node_modules/emoji-mart/dist/module.js 2013:23
Module parse failed: Unexpected token (2013:23)
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
|     unregister() {
|         document.removeEventListener("click", this.handleClickOutside);
>         this.darkMedia?.removeEventListener("change", this.darkMediaCallback);
|         this.unobserve();
|     }
cue232s commented 1 day ago

Try adding this to your webpack.config.js and adding "@babel/plugin-proposal-optional-chaining": "^7.21.0", "@babel/preset-typescript": "^7.12.1", to your package.json


{
          test: /\.jsx?$/,
          exclude: /node_modules\/(?!(emoji-mart)\/).*/,  // Include emoji-mart
          use: {
            loader: 'babel-loader',
            options: {
              presets: ['@babel/preset-env', '@babel/preset-react', '@babel/preset-typescript'],
              plugins: ['@babel/plugin-proposal-optional-chaining']  // Handles optional chaining
            }
          }
        }
pedrolucasfv commented 1 day ago

I was able to solve it by fixing the version of emoji-mart at 5.5.2 instead of leaving it with the ^ in package.json, as it seems that this problem occurs in version 5.6.0 of emoji-mart

dremin commented 1 day ago

This should be resolved with the latest version of the CLI plugin (7.0.5).