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

rollup hang up when running with this plugin in node.js #16

Open
Aqours opened this issue Mar 15, 2019 · 10 comments
Open

rollup hang up when running with this plugin in node.js #16

Aqours opened this issue Mar 15, 2019 · 10 comments

Comments

@Aqours
Copy link

Aqours commented Mar 15, 2019

(async function build() {
    let b = await rollup.rollup({
        input: 'absolute_path_entry.js',
        plugins: [rollupCleanup()],
    }); // hang up here

    let out = {
        format: 'esm',
        sourcemap: true,
        file: path.resolve(__dirname, "dist/test.js"),
    };

    await b.generate(out);
    await b.write(out);
})();
@aMarCruz
Copy link
Owner

@Aqours I will check it asap. Thanks.

@gevalo1
Copy link

gevalo1 commented May 2, 2019

@aMarCruz were you able to look into this? I bumped into this issue today as well.

@aMarCruz
Copy link
Owner

aMarCruz commented May 3, 2019

I'll look at this issue until this week-end.

@xania
Copy link

xania commented Nov 29, 2019

Same issue here!
I was able to narrow it down to this line in skip-regex.js. For context the stacktrace is included.

image

R_JS_REGEX:
"^/(?=[^*\/])[^[/\](?:(?:\.|[(?:\.|[^\]\\])])[^[\/])?/[gimuys]"
match[0]
"/element.height;var pathData=pathMap.getScaledPath('DATA_OBJECT_COLLECTION_PATH',{xScaleFactor:1,yScaleFactor:1,containerWidth:element.width,containerHeight:element.height,position:{mx:0.451,my:yPosition}});drawPath(parentGfx,pathData,{strokeWidth:2});}this._drawPath=drawPath;}inherits(BpmnRenderer,BaseRenderer);BpmnRenderer.$inject=['config.bpmnRenderer','eventBus','styles','pathMap','canvas','textRenderer'];BpmnRenderer.prototype.canRender=function(element){return is(element,'bpmn:BaseElement');};BpmnRenderer.prototype.drawShape=function(parentGfx,element){var type=element.type;var h=this.handlers[type];return h(parentGfx,element);};BpmnRenderer.prototype.drawConnection=function(parentGfx,element){var type=element.type;var h=this.handlers[type];return h(parentGfx,element);};BpmnRenderer.prototype.getShapePath=function(element){if(is(element,'bpmn:Event')){return getCirclePath(element);}if(is(element,'bpmn:Activity')){return getRoundRectPath(element,TASK_BORDER_RADIUS);}if(is(element,'bpmn:Gateway')){return getDiamondPath(element);}return getRectPath(element);};"

@bwindels
Copy link

bwindels commented Sep 17, 2020

I think I am encountering the same issue, rollup hangs forever with this plugin enabled on this particular statement. Removing the statement, or this plugin from my rollup config makes rollup not hang anymore. Let me know if I can provide any further details.

I tried reproducing the problem by passing the same code through js-cleanup but wasn't able to reproduce that way.

@aMarCruz
Copy link
Owner

aMarCruz commented Sep 23, 2020

@Aqours, @gevalo1, @xania, @bwindels , please try cleanup v3.2.1, it is already in npm.

@bwindels
Copy link

bwindels commented Sep 25, 2020

@Aqours, @gevalo1, @xania, @bwindels , please try cleanup v3.2.1, it is already in npm.

Still hangs for me with cat node_modules/rollup-plugin-cleanup/package.json | jq ".version":
"3.2.1"

@aMarCruz
Copy link
Owner

@bwindels thanks, I will check it asap.

@ssivov
Copy link

ssivov commented Nov 20, 2020

Same issue here!
I was able to narrow it down to this line in skip-regex.js. For context the stacktrace is included.

image

R_JS_REGEX:
"^/(?=[^_/])[^[/](?:(?:.|[(?:.|[^]])])[^[/])_?/[gimuys]*"
match[0]
"/element.height;var pathData=pathMap.getScaledPath('DATA_OBJECT_COLLECTION_PATH',{xScaleFactor:1,yScaleFactor:1,containerWidth:element.width,containerHeight:element.height,position:{mx:0.451,my:yPosition}});drawPath(parentGfx,pathData,{strokeWidth:2});}this._drawPath=drawPath;}inherits(BpmnRenderer,BaseRenderer);BpmnRenderer.$inject=['config.bpmnRenderer','eventBus','styles','pathMap','canvas','textRenderer'];BpmnRenderer.prototype.canRender=function(element){return is(element,'bpmn:BaseElement');};BpmnRenderer.prototype.drawShape=function(parentGfx,element){var type=element.type;var h=this.handlers[type];return h(parentGfx,element);};BpmnRenderer.prototype.drawConnection=function(parentGfx,element){var type=element.type;var h=this.handlers[type];return h(parentGfx,element);};BpmnRenderer.prototype.getShapePath=function(element){if(is(element,'bpmn:Event')){return getCirclePath(element);}if(is(element,'bpmn:Activity')){return getRoundRectPath(element,TASK_BORDER_RADIUS);}if(is(element,'bpmn:Gateway')){return getDiamondPath(element);}return getRectPath(element);};"

Confirmed, i'm running into the same issue! This might be a problem for a lot of people because this fails to cleanup Google Web Vitals distribution (node_modules/web-vitals/dist/web-vitals.es5.min.js)

Regex used by skip-regex

/^\/(?=[^*/])[^[/\\]*(?:(?:\\.|\[(?:\\.|[^\]\\]*)*\])[^[\\/]*)*?\/[gimuys]*/

String that kills it

/0,c((function(n){var e=n.timeStamp;return t=e}),!0)),{get timeStamp(){return t}}},v=function(t){var n,e=i("FCP"),r=d(),o=a("paint",(function(t){"first-contentful-paint"===t.name&&t.startTime<r.timeStamp&&(e.value=t.startTime,e.isFinal=!0,e.entries.push(t),n())}));o&&(n=l(t,e,o))},f=function(t){var n=i("FID"),e=d(),r=function(t){t.startTime<e.timeStamp&&(n.value=t.processingStart-t.startTime,n.entries.push(t),n.isFinal=!0,s())},o=a("first-input",r),s=l(t,n,o);o?c((function(){o.takeRecords().map(r),o.disconnect()}),!0):window.perfMetrics&&window.perfMetrics.onFirstInputDelay&&window.perfMetrics.onFirstInputDelay((function(t,i){i.timeStamp<e.timeStamp&&(n.value=t,n.isFinal=!0,n.entries=[{entryType:"first-input",name:i.type,target:i.target,cancelable:i.cancelable,startTime:i.timeStamp,processingStart:i.timeStamp+t}],s())}))},m=function(){return n||(n=new Promise((function(t){return["scroll","keydown","pointerdown"].map((function(n){addEventListener(n,t,{once:!0,passive:!0,capture:!0})}))}))),n},g=function(t){var n,e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=i("LCP"),o=d(),s=function(t){var e=t.startTime;e<o.timeStamp?(r.value=e,r.entries.push(t)):r.isFinal=!0,n()},u=a("largest-contentful-paint",s);if(u){n=l(t,r,u,e);var p=function(){r.isFinal||(u.takeRecords().map(s),r.isFinal=!0,n())};m().then(p),c(p,!0)}},h=function(t){var n,e=i("TTFB");n=function(){try{var n=performance.getEntriesByType("navigation")[0]||function(){var t=performance.timing,n={entryType:"navigation",startTime:0};for(var e in t)"navigationStart"!==e&&"toJSON"!==e&&(n[e]=Math.max(t[e]-t.navigationStart,0));return n}();e.value=e.delta=n.responseStart,e.entries=[n],e.isFinal=!0,t(e)}catch(t){}},"complete"===document.readyState?setTimeout(n,0):addEventListener("pageshow",n)};export{p as getCLS,v as getFCP,f as getFID,g as getLCP,h as getTTFB};

@aMarCruz I tried using a different regex found on stackoverflow - it solves the performance problem and works fine for my code, however it fails 6 of your test cases. Do you think this performance issue could be resolved any time soon?

@smashah
Copy link

smashah commented Nov 26, 2020

I can also confirm that the issue is with using this with web-vitals package

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

7 participants