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

RN 0.66.5 + npm SES 0.18.1: Babel fails to ignore ses.cjs #10

Closed
leotm opened this issue Feb 28, 2023 · 1 comment
Closed

RN 0.66.5 + npm SES 0.18.1: Babel fails to ignore ses.cjs #10

leotm opened this issue Feb 28, 2023 · 1 comment

Comments

@leotm
Copy link
Member

leotm commented Feb 28, 2023

npx react-native@0.66.5 init RN0665 --version 0.66.5

yarn add ses

// index.js

import 'ses'; // added
import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';

lockdown({consoleTaming: 'unsafe'}); // added

AppRegistry.registerComponent(appName, () => App);
// metro.config.js

const {getDefaultConfig} = require('metro-config');

module.exports = (async () => {
  const {
    resolver: {sourceExts},
  } = await getDefaultConfig();
  return {
    transformer: {
      getTransformOptions: async () => ({
        transform: {
          experimentalImportSupport: false,
          inlineRequires: true,
        },
      }),
    },
    resolver: {
      sourceExts: [...sourceExts, 'cjs'],
    },
  };
})();

echo 'ses.cjs' > .babelignore

npx browserslist@latest --update-db (recommended)

yarn start --reset-cache

yarn start ios

Result: endojs/endo#659

Expectation: Same result as

  • curl -O https://npmfs.com/download/ses/0.18.1/dist/lockdown.umd.js
  • echo 'lockdown.umd.js' > .babelignore
  • import './lockdown.umd.js'; instead of ses npm pkg
  • leading to ERROR TypeError: undefined is not a function (near '...globalThis.process.on...') to tackle next (with e.g. rn-nodeify)
@leotm
Copy link
Member Author

leotm commented Feb 28, 2023

SES installed via a pkg manager like npm or yarn won't be ignored by Babel in .babelignore

Solution:

// babel.config.js

module.exports = {
  ignore: [/ses\.cjs/], // added
  presets: ['module:metro-react-native-babel-preset'],
};

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

No branches or pull requests

1 participant