admin管理员组文章数量:1391937
I'm creating a es6 module which extends the RegExp object. I'm using the Object.defineProperties
to do it:
Object.defineProperties(RegExp.prototoype, {
...
});
I'm not returning anything in this file, because I don't need it since RegExp is global in Node.js
, but in the same way I need to import something to run the code that will extend the RegExp.prototype. Do you see the problem?
What is the work around in this case? Just return a export default {}
? Isn't this a bad thing? I was thinking about returning the RegExp and overwriting in the import:
import RegExp from '@scope/regexp';
Thank you.
I'm creating a es6 module which extends the RegExp object. I'm using the Object.defineProperties
to do it:
Object.defineProperties(RegExp.prototoype, {
...
});
I'm not returning anything in this file, because I don't need it since RegExp is global in Node.js
, but in the same way I need to import something to run the code that will extend the RegExp.prototype. Do you see the problem?
What is the work around in this case? Just return a export default {}
? Isn't this a bad thing? I was thinking about returning the RegExp and overwriting in the import:
import RegExp from '@scope/regexp';
Thank you.
Share Improve this question asked Jan 20, 2018 at 14:24 FXuxFXux 4357 silver badges16 bronze badges 1-
Why not
class CustomRegExp extends RegExp
? – Jonas Wilms Commented Jan 20, 2018 at 14:50
1 Answer
Reset to default 9You can use
import '@scope/regex';
This will just run the code in the module, without importing anything.
本文标签: javascriptHow to run a module without importing itStack Overflow
版权声明:本文标题:javascript - How to run a module without importing it? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744724966a2621908.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论