webpack-contrib/expose-loader

Expose without libraryName

crazyfx1 opened this issue · 3 comments

Is it possible to export all namespaces of a file without a libraryName?

Consider this example:
_Public.ts
import { MyClass } from 'MyClass'; export namespace MyNamespace { export const Class = MyClass; }

And this expose-loader:
require("expose-loader?!xxx./_Public"); // what to use here?

How can I export the MyNamespace to the global scope without specifying an additional libraryName? So I can use MyNamespace.Class from global.

I know I could remove the namespace declaration and expose MyNamespace as libraryName, but that's no use for me.

Yeah. Exactly. There are dozens of suggestions all over the web for how to author a file that exports a manually written out list of modules such that they can be consumed from the console.

I'd really really appreciate a way to interface with the webpack bundle in a general, rather than special case kind of way.

We're running with the same problems. Is there a simple way expose directly on the window object instead of defining a hardwritten libraryName?

We can't expose library without name, because it will rewrite global object (this, self, global) and it is invalid. But you can using require("expose-loader?expose=libraryName.MyClass!./src/index.ts"); and loader expose only class, I will update docs in near future