proposal-asset-references icon indicating copy to clipboard operation
proposal-asset-references copied to clipboard

AssetReferences in ImportDeclarations

Open AlicanC opened this issue 7 years ago • 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';?

AlicanC avatar Nov 17 '18 04:11 AlicanC

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 https://github.com/sebmarkbage/ecmascript-asset-references/issues/6 is trying to ensure.

bmeck avatar Nov 19 '18 14:11 bmeck