-
Notifications
You must be signed in to change notification settings - Fork 124
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
Babili on server.js #411
Babili on server.js #411
Conversation
@@ -43,6 +44,7 @@ module.exports = function webpackConfigGenerator(params){ | |||
] | |||
}, | |||
plugins: [ | |||
new BabiliPlugin(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
simple integration atm
'const sayHello = (name) => {' + | ||
' if(name!=="John Doe") infiniteLoops();' + | ||
' return `Hello ${name}`;' + | ||
'};' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to trick babili and its treeshaking as the previous test was just removing the infiniteLoops() function as it had no calls (and therefore not making the infinite loops replacements).
expect(compiledContent).to.contain('var __ITER = 1000000000;do { if(__ITER <=0){ throw new Error' + | ||
'("Loop exceeded maximum allowed iterations"); } \n' + | ||
' z = 342;\n __ITER--; } while (true);'); | ||
expect(compiledContent.match(/Loop exceeded maximum allowed iterations/g).length).to.equal(3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here it became complicated to test the exact replacement as it gets minified after that. In any case, I test that there are 3 replacements containing that string, which is the number of loops I expect. Good enough, I guess 🤣
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This doesn't include (yet) the sourcemaps for server.js.
/cc @nickbalestra