Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Some libraries from node_modules (or every) do not compiled by babel #707

Open
Natteke opened this issue Feb 28, 2020 · 3 comments
Open

Comments

@Natteke
Copy link

Natteke commented Feb 28, 2020

Environment

"@haul-bundler/babel-preset-react-native": "^0.16.0",
"@haul-bundler/preset-0.60": "^0.17.0",
"@haul-bundler/cli": "^0.17.0",
"@haul-bundler/core": "^0.17.0",
"react": "16.9.0",
"react-native": "0.61.5",

Description

Looks like haul babel presset ignores node_modules, but some libraries which need to be compiled,like rn-viewpager.

Bundle crashes on class static property, which works fine if i write that right in my App.tsx.
image

Maybe it is a not an issue, cause i understand that not every node_module should be compiled,
but what should i do in this case? (except choosing another lib)

To reproduce

  1. react-native init
  2. yarn add haul -> init -> start
    --empty project works fine--
  3. yarn add rn-viewpager
  4. add minimal code
import { IndicatorViewPager, PagerDotIndicator } from 'rn-viewpager';

const App = () => (
    <>
        <IndicatorViewPager
            style={{ height: Dimensions.get('window').height }}
            indicator={(
                <PagerDotIndicator
                    pageCount={3}
                />
            )}
        >
            <Text>TEST</Text>
            <Text>TEST</Text>
            <Text>TEST</Text>
        </IndicatorViewPager>
    </>
);
@Natteke Natteke changed the title s Some libraries from node_modules (or every) do not compiled Feb 28, 2020
@Natteke Natteke changed the title Some libraries from node_modules (or every) do not compiled Some libraries from node_modules (or every) do not compiled by babel Feb 28, 2020
@Natteke
Copy link
Author

Natteke commented Feb 28, 2020

It also solves with custom babel/ts config from recipe.

export default makeConfig({
  bundles: {
    index: {
      entry: withPolyfills('./index.ts'),
      transform({ config }) {
        config.module.rules = [
          {
            test: /\.tsx?$/,
            exclude: '/node_modules/',
            use: [
              {
                loader: 'babel-loader',
              },
              {
                loader: 'ts-loader',
              }
            ]
          },
          ...config.module.rules,
        ];
      },
    },
  },
});

@Natteke
Copy link
Author

Natteke commented Feb 28, 2020

looks like it's happening since issue 220.

if i console.log the passed config in transform function, it does not looks like node_modules were excluded from babel, but behavior suggests otherwise.

I think this could be highlighted in the dock.

@zamotany
Copy link
Contributor

@Natteke not every node_module package is excluded, some are transpiled but the great majority is not.

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

No branches or pull requests

2 participants