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

Error with newer versions of node/webpack #2

Open
osotnikov opened this issue Oct 30, 2022 · 0 comments
Open

Error with newer versions of node/webpack #2

osotnikov opened this issue Oct 30, 2022 · 0 comments

Comments

@osotnikov
Copy link

Recently I've upgraded my angular, typescript, webpack and node. I assume the issue is node but I'm not sure. Something broke this plugin so I'm getting this error:

An unhandled exception occurred: Cannot add property main.js, object is not extensible

the fix is to make a copy of "assets" array because the original object is not extensible:

`module.exports = class Rename {
constructor(options) {
this.options = { ...options };
}

apply(compiler) {
compiler.hooks.emit.tap('Rename.emit', compilation => {
const { assets } = compilation;
const { originNameReg, targetName } = this.options;
const originFiles = Object.keys(assets).filter(fileName =>
new RegExp(originNameReg).test(fileName)
);

  originFiles.forEach(fileName => {
    let assetsCopy = Object.assign([], assets);
    assetsCopy[fileName.replace(originNameReg, targetName)] = assetsCopy[fileName];
    delete assetsCopy[fileName];
  });
});

}
};`

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