Esm: export from syntax

Created on 11 Sep 2019  路  2Comments  路  Source: standard-things/esm

export Worker from './class/Worker'
       ^

SyntaxError: Invalid or unexpected token
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)

the below is ok:

import Worker from './class/Worker'
export { Worker }
question

Most helpful comment

hey @cpu100 the syntax you are referring to doesn't exist (yet). there's a proposal for adding it to the language: https://github.com/tc39/proposal-export-default-from , but it seems to be a bit stale right now.

what you can do currently:

// if you want to re-export as default:
export { default } from './class/Worker'

// if you want to re-export as named:
export { default as Worker } from './class/Worker'

All 2 comments

hey @cpu100 the syntax you are referring to doesn't exist (yet). there's a proposal for adding it to the language: https://github.com/tc39/proposal-export-default-from , but it seems to be a bit stale right now.

what you can do currently:

// if you want to re-export as default:
export { default } from './class/Worker'

// if you want to re-export as named:
export { default as Worker } from './class/Worker'

got it, thank you for explaining.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Mensu picture Mensu  路  3Comments

bensampaio picture bensampaio  路  3Comments

mAAdhaTTah picture mAAdhaTTah  路  3Comments

greggb picture greggb  路  3Comments

StphamZ picture StphamZ  路  3Comments