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

Why is rollup creating an additional file of just exports from my entry file? #5400

Open
twilson90 opened this issue Feb 23, 2024 · 4 comments

Comments

@twilson90
Copy link

My entry file 'app.js' contains a lot of code, dynamic imports, exports, etc.

I can't figure out why Rollup decides to create a file with just the exports from my entry file, named 'app-[hash1].js':

System.register(["./app.js"],(function(a){"use strict";var e;return{setters:[function(t){e=t.q,a({$:t.af,AccountAddress:t.aS,AdWhy:t.b8,AdditionalProductPicker:t.b4,AddressFormModal:t.aU,Animation:t.Q,Awards:t.aR,Banner:t.aN,Cart:t.aw,CartModal:t.ao,ColorPickerInput:t.b2,ColorPickerListInput:t.b1,Component:t.ag,ControlsIntroScreen:t.bc,CountryProvinceSelector:t.ar,CurrencySwitcher:t.ak,CustomerAddresses:t.aT,CustomerLogin:t.bb,Drawer:t.aG,Easing:t.s,EventManager:t.a5,FakeInputComponent:t.aC,FormHelper:t.aX,Hammer:t.H,HammerManagerEx:t.ac,HorizontalScroller:t.aD,IMAGE_WIDTHS:t.x,ImageRevealSlider:t.b6,InputWrapper:t.aB,LineItem:t.au,List:t.be,ListItem:t.aL,LoadMoreDummy:t.bd,LoadingOverlay:t.at,MAX_PRODUCT_IMAGE_SIZE:t.M,MediaAndText:t.b7,MediaGrid:t.aQ,MediaPlaceholder:t.aF,Modal:t.aj,Navigation:t.az,NumericInput:t.aA,PARALLAX_MAX:t.P,Pagination:t.av,PaginationAndParameters:t.bf,PendantAd:t.aO,PopupModal:t.am,Price:t.aH,ProductDimensions:t.b5,ProductFormModal:t.aV,ProductImages:t.a_,ProductTestimonial:t.b0,ProductWrapper:t.aZ,RatingInput:t.b3,ResponsiveImage:t.aE,Reviews:t.b9,ReviewsCarousel:t.ba,RichText:t.ax,SIZES:t.w,SVGPreviewer:t.ae,SelectWrapper:t.aq,ShippingCalculator:t.aW,ShopifyBlock:t.ah,ShopifySection:t.ai,ShopifyUtils:t.S,Slideshow:t.aP,StarRating:t.ap,Sticky:t.ay,StorefrontAPI:t.ad,TabContainer:t.aY,Template:t.aJ,ThumbnailScroller:t.a$,TickerTape:t.as,Timer:t.an,Title:t.al,Validation:t.a4,WatermarkContainer:t.aM,Wishlist:t.aI,WishlistModal:t.aK,animate_element:t.O,breakpoints:t.A,convert_dimensions_to_mm:t.a2,escape:t.a6,get_document_offset:t.$,get_nav_height:t.B,get_nearest_sibling:t.X,get_text_nodes:t.a9,get_window_breakpoint:t.D,graphql_query:t.a7,hide:t.N,html_to_elements:t.W,icon_html:t.a0,init_app:t.bi,is_fullscreen:t.E,load_section:t.a3,loader:t.bg,modify_text:t.aa,open_shopify_chat:t.ab,pulse:t.a8,re_escaped_html:t.y,re_unescaped_html:t.z,reflow:t.U,reset_css_animations:t.V,scroll_into_view:t.Y,show:t.K,sprite_html:t.a1,template:t.bh,tinycolor:t.t,toggle_fullscreen:t.F,toggle_loading:t.J,utils:t.u,validate_form:t.Z})}],execute:function(){a("md5",e.md5)}}}));

And it creates another file 'app-[hash2].js' that contains all the code relating to those exported variables and methods.

I would like it to just produce 1 file for 'app.js' and 1 file for each of its dynamic imports.

I try to recreate this behaviour with minimal code and it will always produce 1 app.js file instead of 2. I'm sure there's a good reason, I just can't figure out why it's doing this for one entry file and not another.

@lukastaegert
Copy link
Member

https://rollupjs.org/configuration-options/#preserveentrysignatures will likely provide some help. allow-extension might be the value you need.

@twilson90
Copy link
Author

twilson90 commented Feb 23, 2024

Thanks, I'll check that out.

Before you responded I was in the middle of outlining a minimal example of the issue:

a.js:

import "./b.js";
import("./c.js");
export function a() {}

b.js
console.log("".concat(""));

c.js
console.log([].find(a=>a));

When I compile a.js, I would expect 2 files:
'a.js' - consists of a + b
'c-[hash].js' - consists of c.js

but instead I get:

'a.js' - consists of definitions for a's exported variables
'a-[hash].js - consists of all the code in a.js
'c-[hash].js' - consists of c.js

If I change the contents of b.js to not use String.concat, or c.js to not use Array.find, then it outputs the expected 2 files.

Confusing!

@twilson90
Copy link
Author

twilson90 commented Feb 23, 2024

Well adding preserveEntrySignatures: "allow-extension" appeared to do the trick. Thanks!
Still curious as to the underlying behaviour.

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