- 
                Notifications
    
You must be signed in to change notification settings  - Fork 2.3k
 
[@mapbox/static-apis] [feature] Provide modules with reference without docs and examples #11628
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
base: main
Are you sure you want to change the base?
Conversation
ed80542    to
    f47b20d      
    Compare
  
    7fdd2d5    to
    4173dbb      
    Compare
  
    | 
           This is now ready for review.  | 
    
4173dbb    to
    1d7d5a4      
    Compare
  
    1d7d5a4    to
    34a173e      
    Compare
  
    
          
 Sorry for a delay with response. If this is the root of the issue, perhaps a more reliable solution would be to fix it directly — e.g. by exporting both minified and full v8 references in the ESM bundle? Or is that difficult due to the way minification happens in Rollup?  | 
    
| 
           Thanks for the feedback, @mourner. The goal of the removal of the  It would be easy to export both minified and full v8 references in the ESM bundle, but would it meet the goal to reduce the build size of applications or libraries that depend on  Another solution I could think of is to include both minified and full spec as modules, but continue letting modules import the minified one. The full spec could be added e.g. as  What exactly are your concerns regarding reliability of my proposed solution?  | 
    
          
 I don't think that's the case — the whole point of tree shaking is to only include what's used and discard the rest, module boundary or not. The only case when it's limited to module boundary is when the bundler pulls in CJS, or when ESM exports an object rather than a set of named exports, but it shouldn't be the case here. So to sum up, let's explore adding a minified spec in the ESM exports.  | 
    
| 
           Ok, let's try that. Looking at the code, I would assume that all code which depends on the reference works without docs and examples. Only the   | 
    
| 
           @mourner I created #11661 implementing what you suggested. It was a bit more complicated because i did not want to modify the build process of   | 
    
This pull request adds the flow-stripped source code of the
@mapbox/mapbox-gl-style-specpackage to thedist/folder and adds them asexportstopackage.json. Thelatestreference imports a minified version of thev8reference, without docs and examples.The goal of the separate modules is to allow third-party applications to create smaller builds, and the motivation was that the ol-mapbox-style library currently has a full build with a size of 638 kB. When using the modules and minified reference from this pull request, the build size can be reduced to 534 kB.
The
@mapbox/mapbox-gl-style-specpackage now exports separate modules in addition to the ESM and CJS bundles. The difference between the bundles and the modules is that the latter use a minified version of thelateststyle refererence, which does not contain anydocandexamplefields. See theexportssection ofpackage.jsonfor available modules.Launch Checklist
@mapbox/map-design-team@mapbox/static-apisif this PR includes style spec API or visual changes@mapbox/gl-nativeif this PR includes shader changes or needs a native port (none)mapbox-gl-jschangelog:<changelog></changelog>