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

Facing issue with integrating it with react-native-web and rollup #2276

Open
vaibhav-neosoft opened this issue Jul 9, 2023 · 3 comments
Open

Comments

@vaibhav-neosoft
Copy link

**Failed to compile.

Module parse failed: Unexpected token (2:7)
File was processed with these loaders:

  • ./node_modules/source-map-loader/dist/cjs.js
    You may need an additional loader to handle the result of these loaders.
    | export {default as Calendar} from './calendar';

export type {CalendarProps} from './calendar';
| export {default as CalendarList} from './calendar-list';
| export {default as NewCalendarList} from './calendar-list/new';**

My babel.config.js
const path = require('path');


module.exports = {
  presets: [
    '@babel/preset-env',
    '@babel/preset-react',
    '@babel/preset-typescript'
  ],
  plugins: [
    ['module-resolver', {
      alias: {
        '^react-native$': 'react-native-web',
        'react-native/Libraries/Image/AssetRegistry$': 'react-native-web/dist/modules/AssetRegistry',
      },
    }],
    ['@babel/plugin-syntax-jsx'],
    ['@babel/plugin-proposal-class-properties'],
  ]
};

My rollup.config

import alias from '@rollup/plugin-alias';
import jsx from 'acorn-jsx';
import url from '@rollup/plugin-url';
import path, { resolve } from 'path';
import typescript from 'rollup-plugin-typescript2';
import json from '@rollup/plugin-json';
import pkg from './package.json';
import nodeResolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import babel from '@rollup/plugin-babel';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';

export default {
  input: 'src/index.ts',
  output: [
    {
      file: pkg.main,
      format: 'cjs',
      sourcemap: true,
    },
    {
      file: pkg.module,
      format: 'esm',
      sourcemap: true,
    },
  ],
  external: [
    ...Object.keys(pkg.dependencies || {}),
    ...Object.keys(pkg.peerDependencies || {}),
    'react-native-web',
    'react-dom','react','react-native-calendars'
    ],
  plugins: [
    json(),
    nodeResolve({
      include: ['node_modules/react-native/**', 'node_modules/react/**','node_modules/react-native-svg/**',
      'node_modules/react-native-web/**',
      path.resolve(__dirname, './node_modules/react-native-calendars')
    ],
      jsnext: true,
      extensions: ['.ts','.tsx', '.jsx', '.js']
  }),
 
    typescript({ tsconfig: "./tsconfig.json" }),

    babel({
      test: [/\.js$/, /\.jsx$/, /\.ts$/],
      extensions: [".js", ".ts", ".jsx", ".tsx"],
      include: [
        path.resolve(__dirname, './node_modules/react-native-calendars'),
      ],

  }
  ),
  commonjs({ include: /node_modules/}),
  ]
 
};

Please help here

Thanks

@AlexSirenko
Copy link

Same for me

@jhspaybar
Copy link

Did either of you end up finding a solution? I’m running into this as well.

@AhmedAbuelenin
Copy link

Same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants