You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And the solution is to add {sourceType: 'module'} to babel-template options:
// src/typescript/fable-utils/babel-plugins.js:75
var builtMacro = babelTemplate(macro,{sourceType: 'module', plugins:["dynamicImport"]})(buildArgs);
note dynamicImport plugin is added there as it seems when babel-template is used here it ignores all bable plugins, and to support dynamic import I've copied what babel-plugin-syntax-dynamic-import is doing, without this compilation fails as '(' is not expected after 'import'
It's probably better to deal with this in Fable.Core so I've added importDynamic (I also took the chance to add importSideEffects). According to my tests, it should work when bundling with JS.
Description
Webpack provides feature to create multiple bundle chunks and load them dynamically when needed (docs)
Through
import('foo')
can not be achieved withEmit
currently because compiler will fail with:Similar issue was reported for babylon: babylon/issues/220
And the solution is to add
{sourceType: 'module'}
tobabel-template
options:note dynamicImport plugin is added there as it seems when babel-template is used here it ignores all bable plugins, and to support dynamic import I've copied what babel-plugin-syntax-dynamic-import is doing, without this compilation fails as '(' is not expected after 'import'
Repro code
Existing workarounds
Atm it's possible to use
System.import($0)
which is deprecated in Webpack 2 or userequire.ensure
:Related information
dotnet fable --version
: 1.0.0-narumi-914The text was updated successfully, but these errors were encountered: