tc39/proposal-asset-references

AssetReferences in ImportDeclarations

AlicanC opened this issue · 1 comments

Should these work?

// Example 1
asset reactRef from 'react';
import React, { Component } from reactRef;

// Example 2
import { reactRef } from './myRefs';
import React, { Component } from reactRef;

If they should, would they work any differently than just import React, { Component } from 'react';?

bmeck commented

given that

asset reactRef from 'react';
import(reactRef);

acts the same as:

import('react');

at the very minimum it should act the same if allowed to be turned into

// Example 1
asset reactRef from 'react';
import React, { Component } from reactRef;

However, for the 2nd example it would need to ensure that the binding pointed to by reactRef is to an asset binding rather than to something like a string if we are wanting to keep static graph guarantees. This leads me to think that import() should be used in the second example instead of import...from:

import { reactRef } from './myRefs';
import(reactRef);

A notable thing here is that in order for assets to be allowed to GC they must have some level of mutation in order to remove them from the VM like #6 is trying to ensure.