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

webpack loader breaking on newer webpack versions #33

Open
Traviskn opened this issue Nov 1, 2017 · 0 comments
Open

webpack loader breaking on newer webpack versions #33

Traviskn opened this issue Nov 1, 2017 · 0 comments

Comments

@Traviskn
Copy link

Traviskn commented Nov 1, 2017

Hi John! 👋

I ran into an error cannot read property 'noParse' of undefined after upgrading to webpack 3. It seems that this.options.module is now undefined 😢 . Looking over the docs on webpack loaders (https://webpack.js.org/contribute/writing-a-loader/) it seems they discourage accessing the options directly, and they even go so far as to say that options is read-only.

I was able to get things working by explicitly adding the noParse rule to my config:

noParse: /i18nliner\/dist\/lib\/i18nliner/,

and creating a simpler version of your webpack loader that doesn't set the noParse config anymore:

const I18nliner = require('i18nliner').default;
const hasTranslatableText = require('react-i18nliner/hasTranslatableText')(I18nliner.config);
const preprocess = require('react-i18nliner/preprocess');

module.exports = function i18nloader(source) {
  this.cacheable();

  if (hasTranslatableText(source)) {
    return preprocess(source, I18nliner.config);
  }
  return source;
};

I'm not sure if there's still a way to automatically set the noParse config from within the loader.

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

No branches or pull requests

1 participant