Skip to content

webpack.js regex problems (linux and windows) #8

@ofbeaton

Description

@ofbeaton

The test line in webpack.js is incorrect for all systems and has 2 issues and 1 possible source of problems for users building on the tutorial.

 module: {
    loaders: [
      {
        test: /src\/.+.js$/,
        exclude: /node_modules/,
        loader: 'babel'
      }
    ]
  }

Please note the 2nd . is not escaped, it should read /src\/.+\.js$/. This was undetected because the regex still works even if it does not match properly.

However real problems begin on windows, the \/ slash doesn't work, producing a Unexpected reserved word You may need an appropriate loader to handle this file type. error.

This can be fixed by accepting either slash, with the regex /src(\/|\\).+\.js$/.

Finally, a specific user may expand and convert the client.js into a client.jsx and change their entry line, but find things stop working. Or they may use this as a learning project and copy it to another project where their entry is a jsx. You could help them out by giving them a reg ex that handles this case, in the form of: /src(\\|\/).+\.jsx?$/ which takes js or jsx.

I imagine this improvement can be made your flux tutorial as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions