Skip to content

webpack loader breaking on newer webpack versionsΒ #33

@Traviskn

Description

@Traviskn

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions