standard-things / esm

Tomorrow's ECMAScript modules today!
Other
5.26k stars 146 forks source link

export from syntax #837

Closed marxangels closed 4 years ago

marxangels commented 4 years ago
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 }
dnalborczyk commented 4 years ago

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'
marxangels commented 4 years ago

got it, thank you for explaining.