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

klona/full seems discarding prototype properties from class #24

Closed
otakustay opened this issue Sep 12, 2020 · 4 comments
Closed

klona/full seems discarding prototype properties from class #24

otakustay opened this issue Sep 12, 2020 · 4 comments

Comments

@otakustay
Copy link

const clone = require('clone');
const {klona} = require('klona');
const {klona: klonaFull} = require('klona/full');

function MyPlugin() {
}

MyPlugin.prototype = {
    install: function() {
        console.log('install');
    }
}

const options = {
    plugin: new MyPlugin(),
};

console.log('oringinal', options.plugin.install);
console.log('clone', clone(options).plugin.install);
console.log('klona', klona(options).plugin.install);
console.log('klona/full', klonaFull(options).plugin.install);

Output:

oringinal [Function: install]
clone [Function: install]
klona [Function: install]
klona/full undefined

Wondering its a bug or is by design, this issue makes less-loader lost less plugin methods.

@lukeed
Copy link
Owner

lukeed commented Sep 15, 2020

Hey, thanks for this. Good catch!

Started looking at this tonight and will hopefully have it done tomorrow. The fix is easy but trying to prevent much performance degradation

@lukeed lukeed closed this as completed in d8720a3 Sep 15, 2020
@lukeed
Copy link
Owner

lukeed commented Sep 15, 2020

If you're around, I'd appreciate it if you could check out the klona/full changes and verify that it works for you before I publish a new version. I think it covers this issue, but doesn't hurt to verify :D

Thanks!

@otakustay
Copy link
Author

Worked in my case (less-loader with less-plugin-functions), great!

@lukeed
Copy link
Owner

lukeed commented Sep 16, 2020

Cool, publishing now then

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