n6g7 / redux-saga-firebase

A redux saga integration for firebase.
https://redux-saga-firebase.js.org/
MIT License
284 stars 57 forks source link

Webpack aliases may be counter intuitive #172

Open webbertakken opened 5 years ago

webbertakken commented 5 years ago

Firstly, thank you so much for creating this great project!

I would argue that aliases that are defined in webpack.config.js in /example like below are counter-intuitive when you're new to this package and as such isn't so useful to have in the example, as it requires refactoring or configuration to get to work.

module.exports = {

  ...

  resolve: {
    alias: {
      '@actions': path.resolve(__dirname, 'src/redux/actions'),
      '@assets': path.resolve(__dirname, 'src/assets'),
      '@atoms': path.resolve(__dirname, 'src/components/atoms'),
      '@molecules': path.resolve(__dirname, 'src/components/molecules'),
      '@organisms': path.resolve(__dirname, 'src/components/organisms')
    }
  },

  ...

While i like the syntax of importing actions using @actions, it got me puzzled there for a moment. Is it really worth the custom Webpack configuration, differing from any app created with create-react-app

# Current
import {  types } from '@actions/login'

# Arguably much easier to learn and integrate
import {  types } from '../actions/login'

As a final thought, I think most Firebase apps (which are very quick to setup) don't have the complexity to have nested folders within the sagas folder.

n6g7 commented 5 years ago

Hey Dick,

Thanks a lot for the feedback!

That's interesting because my reasoning when adding the @actions aliases was also that it would make those example files easier to read. By reducing the cognitive load on implementation details ("what is this thing we're importing here?"), my thought was that it'd be easier to focus on the library-specific stuff ("how do you call a firebase function from a saga?" for example).

Maybe that's not he case though, and your point about not being able to copy/paste without refactoring/updating the webpack config is very valid (although you wouldn't have the same actions in a real project anyway, so you will have to change those imports anyway).

I'll keep this issue open for the time being and will try to get to it at some point. In the meantime feel free to send a PR. :)