Haul: Improvements to documentation

Created on 20 Apr 2017  路  7Comments  路  Source: callstack/haul

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.

Most helpful comment

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

All 7 comments

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.

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

@GeeWee I'm very interested!

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.

@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).

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

@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)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chaseholland picture chaseholland  路  5Comments

jukben picture jukben  路  6Comments

MichelDiz picture MichelDiz  路  3Comments

rtomchinsky picture rtomchinsky  路  7Comments

jurajkrivda picture jurajkrivda  路  4Comments