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

Give access to full file path in the modify callback #53

Closed
epegzz opened this issue Apr 23, 2021 · 5 comments
Closed

Give access to full file path in the modify callback #53

epegzz opened this issue Apr 23, 2021 · 5 comments

Comments

@epegzz
Copy link

epegzz commented Apr 23, 2021

Hey there!

It would be great if you could add an option to pass the full path instead just the basename as value for the filename argument in the modify callback.

WDYT? :)

@artembatura
Copy link
Owner

Hi man.

It's a good idea, I think we can add new argument path and leave filename as exists. It's will be more handy, because you will don't need to pass an extra option.

module.exports = {
  plugins: [
    new ModifySourcePlugin({
      rules: [
        {
          test: /my-file\.js$/,
          modify: (src, filename, path) => src + `...`
        }
      ]
    })
  ]
};

What do you think?

@epegzz
Copy link
Author

epegzz commented Apr 24, 2021

If it was my lib then I'd replace the filename with path and simply bump to a new major version to signal breaking API changes.

Because having both path AND filename is unnecessary as one can be derived easily from the other.

But I'd be absolutely fine with going the route of adding a third argument as well, since from a usage perspective it does not make a big difference 👍 :)

@artembatura
Copy link
Owner

Yeah it's a better idea. And bumping new major version it's a good point. I just don't know how to deal with version for webpack 4 because we have two versions - 1.1.0-beta.3 for webpack 4 and 2.0.0-beta.7 for webpack 5. If we planned to support two versions we should update 1.1.0-beta.3 too and it's will be failed semver (already, lol).

Probably we can move support for webpack 4 and webpack 5 in a single version (3.0.0, for example). But there was a problem why I changed to 2 separated versions - we cannot hold two webpack versions in one package.json. So tests also will be only for one version. And working TypeScript types too.

I'm ready to ship this breaking improvement if we will solve this issue with versions. Let me know if you have ideas, it's will be great help for this project 😉👍

@artembatura
Copy link
Owner

@epegzz Should be fixed in #55. You can test before it's got released by installing modify-source-webpack-plugin@next. Version 3.0.0-rc.0.

Now we will have single version of plugin for webpack 5 and 4 🥳

@epegzz
Copy link
Author

epegzz commented Jun 22, 2021

Thank you!! Works like a charm 👏 😃

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