0

Why does the following throw a syntax error when importing an ES2015 module?

// foo.js
export const FOOS = {
  A: '/a',
  B: '/b',
};

// bar.js
import { FOOS: { A } } from './foo'; // Syntax Error

How can I expose constants from a module such that they are available individually (eg. import { A } from 'foo') and collectively as an iterable (eg. import * from './foo')?

Ben Aston
  • 53,718
  • 65
  • 205
  • 331

0 Answers0