Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to export namespaces #7

Closed
Swatinem opened this issue Feb 13, 2019 · 2 comments
Closed

Make it possible to export namespaces #7

Swatinem opened this issue Feb 13, 2019 · 2 comments
Assignees

Comments

@Swatinem
Copy link
Owner

Currently re-exporting namespaces creates invalid code, because of the way that rollup handles these things.

It would be good to research if it is even possible at all to solve this usecase.

import * as ns from "./namespace";

export { ns };
@Swatinem
Copy link
Owner Author

Other things that don’t work correctly which are related to namespace imports:

export type T = typeof import("./bar")

@Swatinem
Copy link
Owner Author

I think the only way to solve this is to do some post-processing of the bundle that rollup generates…

This is the code that rollup generates:

interface A {
}
declare function b(): void;
declare class C {
}
var namespace = /*#__PURE__*/Object.freeze({
	A: A,
	b: b,
	C: C
});
export { namespace as ns };

I think something like this should work as the final result:

interface _A {}
declare function _fn(): void

declare namespace ns {
  export { _A as A, _fn as fn }
}

export { _A as A, _fn as fn, ns }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant