Re: Intent to ship: Dynamic module imports (JS 'import()' syntax)

2019-03-07 Thread Martin Thomson
Thanks.  (And ugh, but that's how these things go.)

On Fri, Mar 8, 2019 at 2:40 PM Boris Zbarsky  wrote:

> On 3/7/19 10:27 PM, Martin Thomson wrote:
> > Is there a way that doesn't rely on eval or eval-like mechanisms?
>
> I suspect the only detectable thing here (and Jon might wake up tomorrow
> and tell me I'm wrong!) is that import('stuff') is a syntax error
> without the support but is not a syntax error otherwise.
>
> That means you need to trigger at least a new parse of some JS that you
> control to run the detection.
>
> Now you could probably manage this with something like (using non-inline
> scripts for all this stuff):
>
>
>  var oldError = window.onerror;
>  window.onerror = function(...args) {
>/* check for syntax error */
>  }
>
>function() { import(''); }
>window.onerror = oldError;
>
> or so.
>
> -Boris
> ___
> dev-platform mailing list
> dev-platform@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-platform
>
___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


Re: Intent to ship: Dynamic module imports (JS 'import()' syntax)

2019-03-07 Thread Boris Zbarsky

On 3/7/19 10:27 PM, Martin Thomson wrote:

Is there a way that doesn't rely on eval or eval-like mechanisms?


I suspect the only detectable thing here (and Jon might wake up tomorrow 
and tell me I'm wrong!) is that import('stuff') is a syntax error 
without the support but is not a syntax error otherwise.


That means you need to trigger at least a new parse of some JS that you 
control to run the detection.


Now you could probably manage this with something like (using non-inline 
scripts for all this stuff):


  
var oldError = window.onerror;
window.onerror = function(...args) {
  /* check for syntax error */
}
  
  function() { import(''); }
  window.onerror = oldError;

or so.

-Boris
___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


Re: Intent to ship: Dynamic module imports (JS 'import()' syntax)

2019-03-07 Thread Martin Thomson
Is there a way that doesn't rely on eval or eval-like mechanisms?

On Fri, Mar 8, 2019 at 1:55 PM Boris Zbarsky  wrote:

> On 3/7/19 6:14 PM, rekt...@gmail.com wrote:
> > Is there any way to feature detect support for import() syntax?
>
> In Firefox, yes, as far as I can tell:
>
>try {
>  new Function("import('')");
>  // supported
>} catch (e) {
>  // not supported
>}
>
> -Boris
> ___
> dev-platform mailing list
> dev-platform@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-platform
>
___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


Re: Intent to ship: Dynamic module imports (JS 'import()' syntax)

2019-03-07 Thread Boris Zbarsky

On 3/7/19 6:14 PM, rekt...@gmail.com wrote:

Is there any way to feature detect support for import() syntax?


In Firefox, yes, as far as I can tell:

  try {
new Function("import('')");
// supported
  } catch (e) {
// not supported
  }

-Boris
___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


Re: Intent to ship: Dynamic module imports (JS 'import()' syntax)

2019-03-07 Thread rektide
Is there any way to feature detect support for import() syntax?
___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform