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

options object is not refreshed upon multiple calls #1

Closed
rodrigommv1987 opened this issue Apr 13, 2020 · 2 comments
Closed

options object is not refreshed upon multiple calls #1

rodrigommv1987 opened this issue Apr 13, 2020 · 2 comments

Comments

@rodrigommv1987
Copy link

Hi, I'm trying to get compiled different versions depending on some runtime values and I found this plugin very usefull, but I think I have found a bug.
When using this plugin on several webpack config objects, the output bundles always match the first of the passed objects.

For example this config object was always creating bundles matching the first of the objects in the array (page1):

module.exports = [
  {
    entry: {
      page1: "./src/index.js",
    },
    ...
    module: {
      rules: [       
        {
          loader: "js-conditional-compile-loader",
          options: {
            gallery: false,
            hero: true,
            slider: false,
          },
        },
      ],
    },
  },
  {
    entry: {
      page2: "./src/index.js",
    },
    ...
    module: {
      rules: [
        {
          loader: "js-conditional-compile-loader",
          options: {
            gallery: false,
            hero: true,
            slider: true,
          },
        },
      ],
    },
  },
  {
    entry: {
      page3: "./src/index.js",
    },
    ...
    module: {
      rules: [
        {
          loader: "js-conditional-compile-loader",
          options: {
            gallery: true,
            hero: false,
            slider: false,
          },
        },
      ],
    },
  },
];

After debugging a little the code of the loader, I found that in the index.js file, the options variable is defined outside of the exported function, it's always taking the value of the first call done to it, and not taking the passed config on succesive executions. This gets solved by removing the if on line #7.

Hope you find this useful.

Cheers!

@hzsrc
Copy link
Owner

hzsrc commented Apr 13, 2020

Hi ,
I have fixed this problem, by this version:
js-conditional-compile-loader@1.0.14

Thanks a lot!

@rodrigommv1987
Copy link
Author

Working fine now!!

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

2 participants