question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support new `export * as ns` syntax

See original GitHub issue

Feature request

There is new export syntax: export * as ns (stage 4).

https://github.com/tc39/proposal-export-ns-from

export * as ns from './test';

Currently this will error:

ERROR in ./src/proxy.js 1:9
Module parse failed: Unexpected token (1:9)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> export * as ns from './test';
 @ ./src/index.js 1:0-29 2:12-14

FWIW, TypeScript recently added support for this: https://devblogs.microsoft.com/typescript/announcing-typescript-3-8/#export-star-as-namespace-syntax

What is the expected behavior?

What is motivation or use case for adding/changing the behavior?

How should this be implemented in your opinion?

Are you willing to work on this yourself? yes

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:23
  • Comments:16 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
jun-sheafcommented, Jun 30, 2020

A current workaround is to use Babel and its @babel/plugin-proposal-export-namespace-from plugin. You can set is up like so for bare-minimum babel:

For dependencies,

npm i -D @babel/core babel-loader @babel/plugin-proposal-export-namespace-from

In your webpack.config.js,

...
{
    test: /\.tsx?$/,
    use: [{
         loader: "babel-loader", // This should be the last loader of course
         options: {
              plugins: ["@babel/plugin-proposal-export-namespace-from"]
         }
    }, ...other loaders]
}
...
2reactions
appzukacommented, Jun 6, 2020

Is this the same issue as https://github.com/TypeStrong/ts-loader/issues/1121?

If you use a module target lower than es2020 then typescript will transpile the new export * syntax down to a version webpack can understand.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ECMAScript export ns from
This proposal adds a new form of "export from" which exports another module's namespace exotic object as an exported name of another, filling...
Read more >
export - JavaScript - MDN Web Docs
The export declaration is used to export values from a JavaScript module. Exported values can then be imported into other programs with the ......
Read more >
Documentation - TypeScript 3.8
TypeScript 3.8 adds a new syntax for type-only imports and exports. ts. import type { SomeThing } from "./some-module.js";. export type { SomeThing...
Read more >
Modules • JavaScript for impatient programmers (ES2022 ...
Syntax (how code is written): What is a module? How are imports and exports declared? Etc. Semantics (how code is executed): How are...
Read more >
How To Use Modules in TypeScript
TypeScript offers support for creating and using modules with a unified ... The export {} syntax allows you to export multiple identifiers.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found