callstack / haul

Haul is a command line tool for developing React Native apps, powered by Webpack
MIT License
3.64k stars 194 forks source link

Improvements to documentation #133

Open satya164 opened 7 years ago

satya164 commented 7 years ago

Here are some thoughts on things we need to cover in the docs

If you have more ideas, please comment below/edit this post if you have access.

migueloller commented 7 years ago

Hey @satya164, just wanted to chime in and say that it's also possible to avoid long relative requires by using Webpack. Here's a Haul config I've been using that allows .jsx in React Native and allows to require anything inside src (e.g., require('components/MyButton')).

const path = require('path')

module.exports = ({ platform }, defaults) => ({
  entry: `./index.${platform}.js`,
  module: {
    ...defaults.module,
    rules: [
      ...defaults.module.rules,
      // Support .jsx
      {
        test: /\.jsx$/,
        use: {
          loader: require.resolve('happypack/loader'),
          query: { id: 'babel' },
        },
        include: path.resolve(__dirname, 'src'),
      },
    ],
  },
  resolve: {
    ...defaults.resolve,
    // Support .jsx
    extensions: [...defaults.resolve.extensions, '.jsx'],
    // Avoid extremely long relative imports
    modules: [path.resolve(__dirname, 'src'), 'node_modules'],
  },
})

More fine-grained control like babel-plugin-module-resolver can also be achieved using the resolve.alias option in Webpack but just using resolve.modules worked for my use case.

I'm also planning on adding react-hot-loader to support HMR for functional stateless components in React Native (currently unsupported). I wouldn't mind contributing to the docs adding a couple of recipes.

GeeWee commented 7 years ago

I'd be willing to create a PR with a typescript recipe if there's interest.

skellock commented 7 years ago

@GeeWee I'm very interested!

pyrossh commented 7 years ago

Me too. I'm using reactxp and it needs to compile the .tsx files to a dist folder and I want that removed. Plus reactxp already has a webpack config I can just reuse that for haul.

ericketts commented 6 years ago

@satya164 I would also say that some documentation on migrating from Haul back to the vanilla RN packager would be useful (since the process of integrating Haul is automated but there is no option or documented process for accomplishing the inverse).

satya164 commented 6 years ago

@ericketts if you use got for version control, git revert commit-hash will do the job!

ericketts commented 6 years ago

@satya164 for sure and that's the current plan if I want to undo the integration, just nice to have it documented is all 🙂 (also any manual integration docs, which you have as step 5 in root comment, serve the purpose just as well)