Force modern bundle in web.cordova

Hello!

There has already been such a question, though with no answer (1.7.0 build web.cordova to match web.browser).

Currently I am looking for a way to force a modern bundle into the web.cordora build and get rid of the legacy bundle at all. Can anybody point out if it is possible?

My app target only iOS 11+ and Android 9+, so most of the ES6+ features are already supported by built-in browsers…

1 Like

Did you ever get a solution for this? Currently wanting to do the same…

There is an argument for meteor run: --exclude-archs web.browser.legacy

You can use modern-browsers - Packosphere to set your modern browser expectations but I believe Cordova is modern by default and it is a separate bundle (from the web one). I believe you could also remove the web platform all together and only bundle for Cordova.
Ok, that is a good question … I personally believe Cordova is modern by default… I will need to check whether the code level can be changed.

Example:

startup/server/your_some_imported_file.js

import { setMinimumBrowserVersions } from 'meteor/modern-browsers'

setMinimumBrowserVersions({
  chrome: 100,
  facebook: 325,
  firefox: 90,
  edge: 95,
  ie: Infinity,
  mobileSafari: 12,
  opera: 53,
  safari: 13,
  samsungBrowser: 12
}, 'minimum versions for ECMAScript 2015 classes')

setMinimumBrowserVersions({
  chrome: 90,
  firefox: 90,
  edge: 95,
  ie: Infinity,
  mobileSafari: 12,
  opera: 53,
  safari: 13,
  samsung_browser: 12,
  samsungBrowser: 12
}, 'service workers')
1 Like

Thanks for the info - I found the --exlude-archs option but discovered Cordova builds it’s own architecture - web.cordova so excluding web.browser.legacy has no effect. I then tried excluding web.cordova and web.browser.legacy but probably as expected, this causes a build error (I’m assuming because Cordova requires web.cordova).

From what I can determine so far web.cordova is a legacy build ( found some test code in the modern-browsers package to log the browser name and whether is is legacy or not on the server). Triggering an update from the cordova app reports legacy mode. What seems to confirm this is that I’m building a mobile app using angular 12 with material 12 for the UI. Material contains some pre-built .umd files in a bundle folder that seem to be buggy (the reason I’m currently going down this rabbit hole) and causing the mobile versions of my app to fail in odd ways (I debugged this down to what looks like bad code generation in the .umd files for the ES5 implementation of the spread operator for example).

I can’t find any option/mechanism to make web.cordova generate modern browser code. There is a stale PR for this I came across for this issue with no hints of anything planned to address this.

My initial workaround was to fix the broken code. However, I’m coming across more and more instances of broken code in the .umd files. I tried the suggestion in the Changelog for v1.7 when the modern browser feature was introduced of copying the pachage into the import folder to cause it to be rebuilt. However, I got a load of build errors so abandoned that and have instead simply deleted the bad bundle source files from within node_module/@angular/material/bundle which causes Meteor to build it’s own ES5 version for the Cordova app and the odd issues now seem to have gone.

Would still be nice to run modern code version under Cordova though…

1 Like

Hi @fredmaiaarantes ,

could someone clarify this, please. Cordova client returns false for isModern, which is probably normal since (possibly) isModern is an atribute of a browser.
How can we know/check the JS code level that goes into Cordova bundle and how can we influence that?
Tx.

@mrwild I’ve lately been working on issues with the legacy client and recompiling npm packages. If you create a reproduction, I can look into it.


Cordova uses the legacy client, and there currently isn’t a way to configure that. If I remember correctly, this was originally because Meteor doesn’t know what browser versions will be used to run the cordova app, so it uses the client that should work anywhere.

3 Likes

@zoderrn I was following these instructions from the v1.7 release note (though I am using the latest 2.7.2 Meteor release):

Although Meteor does not recompile packages installed in node_modules by default, compilation of specific npm packages (for example, to support older browsers that the package author neglected) can now be enabled in one of two ways:

  • Clone the package repository into your application’s imports directory, make any modifications necessary, then use npm install to link the-package into node_modules :
  meteor npm install imports/the-package

Meteor will compile the contents of the package exposed via imports/the-package , and this compiled code will be used when you import the-package in any of the usual ways:

  import stuff from "the-package"
  require("the-package") === require("/imports/the-package")
  import("the-package").then(...)

This reuse of compiled code is the critical new feature that was added in Meteor 1.7.

I was attempting to build the @angular/material@12.2.13 and @angular/cdk@12.2.13 packages.