react-native-multi-slider icon indicating copy to clipboard operation
react-native-multi-slider copied to clipboard

Crashes web build for expo

Open bjornarhagen opened this issue 5 years ago • 9 comments

Expo cannot build web version when using this module. This is the error I get:

.../node_modules/@ptomasroos/react-native-multi-slider/MultiSlider.js 18:22
Module parse failed: Unexpected token (18:22)
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
| 
| export default class MultiSlider extends React.Component {
>   static defaultProps = {
|     values: [0],
|     onValuesChangeStart: () => {},

bjornarhagen avatar Aug 06 '20 09:08 bjornarhagen

For some weird reason, if I download the ZIP of the same release version and put it in my project folder it works. But when I use the node_modules version, it doesn't work. So this works great as a temporary workaround, but should probably still be fixed.

bjornarhagen avatar Aug 19 '20 07:08 bjornarhagen

Ah thanks!

I will make sure to do a release then if its sorted out in the latest version of the code base?

ptomasroos avatar Aug 19 '20 07:08 ptomasroos

This seems to be similar, are you sure you're not missing on a babel plugin? https://github.com/styleguidist/react-styleguidist/issues/1513

ptomasroos avatar Aug 19 '20 07:08 ptomasroos

That does indeed seem like the same issue. I installed metro-react-native-babel-preset and replaced babel-preset-expo with it in babel.config.js, but the error prevails. I also tried to add @babel/plugin-proposal-class-properties, but it still fails.

bjornarhagen avatar Aug 19 '20 09:08 bjornarhagen

I'm running into the same issue. I'm using expo 39.0.2. Using the downloaded ZIP works in the expo web build, but throws the error below when trying to load on an Android emulator.

Unable to resolve "../../components/react-native-multi-slider/MultiSlider" from "src\screens\find-wizard-screens\find-wizard-prices.js"

nsbingham avatar Nov 09 '20 12:11 nsbingham

@bjornarhagen I was able to get the NPM package running the expo web build by following the steps in this similar issue - https://github.com/akveo/react-native-ui-kitten/issues/996#issuecomment-645448007.

My webpack.config.js ended up looking like this:

const createExpoWebpackConfigAsync = require("@expo/webpack-config");

module.exports = async function (env, argv) {
  const config = await createExpoWebpackConfigAsync(
    {
      ...env,
      babel: {
        dangerouslyAddModulePathsToTranspile: [
          "@ptomasroos/react-native-multi-slider",
        ],
      },
    },
    argv
  );
  return config;
};

nsbingham avatar Nov 09 '20 13:11 nsbingham

@bjornarhagen I was able to get the NPM package running the expo web build by following the steps in this similar issue - akveo/react-native-ui-kitten#996 (comment).

My webpack.config.js ended up looking like this:

const createExpoWebpackConfigAsync = require("@expo/webpack-config");

module.exports = async function (env, argv) {
  const config = await createExpoWebpackConfigAsync(
    {
      ...env,
      babel: {
        dangerouslyAddModulePathsToTranspile: [
          "@ptomasroos/react-native-multi-slider",
        ],
      },
    },
    argv
  );
  return config;
};

This worked for me 😅

brunokiafuka avatar Jan 28 '21 14:01 brunokiafuka

I do have the exact same issue but the webpack.config changes did not work for me.

Is there a workaround for this issue?

fabianschwarzfritz avatar Jul 31 '22 16:07 fabianschwarzfritz

@bjornarhagen I was able to get the NPM package running the expo web build by following the steps in this similar issue - akveo/react-native-ui-kitten#996 (comment).

My webpack.config.js ended up looking like this:

const createExpoWebpackConfigAsync = require("@expo/webpack-config");

module.exports = async function (env, argv) {
  const config = await createExpoWebpackConfigAsync(
    {
      ...env,
      babel: {
        dangerouslyAddModulePathsToTranspile: [
          "@ptomasroos/react-native-multi-slider",
        ],
      },
    },
    argv
  );
  return config;
};

This works for me too! Thanks!

bananemo avatar Dec 13 '22 14:12 bananemo