Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

207
Views
Javascript how to use modules to Import/Export all from file?

With this code I am able to successfully import / access variables and functions when they are individually exported, but I want to be able to export the entire file in a single declaration. I've tried a number of variations from here but cannot achieve this.

script.js

import * as testImport from './test.js';

console.log( testImport.testVar ); // Returns 'Test Variable'
console.log( testImport.testFunc() ); // Returns 'Test Function'

test.js

export let testVar = 'Test Variable';

export function testFunc() {
    return 'Test Function';
}

desired ( without individual 'exports' )

let testVar = 'Test Variable';

function testFunc() {
    return 'Test Function';
}

export * // ?
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

There is no such thing like you ask for, because it conflicts diametrically with the intention behind modules.

The whole point of modules is to keep all variables private to the module with the exception of making those explicitly exported available for importing.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!