jj101k / eximport Goto Github PK
View Code? Open in Web Editor NEWThis project forked from macmee/import-export
This project forked from macmee/import-export
The current eximport export datum is an object which has ns
as a member containing all the namespace definitions. That works fine, but code like this:
require("foo").ns.Foo
export const Foo = "bar"
...looks bad to some systems which support both require()
and import
because, somewhat sensibly, they expect exports to be at the top level of the returned object.
TL;DR: require("foo").ns.Foo
produces red wigglies in VS code, don't want that
TypeError: Class extends value undefined is not a constructor or null
(Edited to correct bad report)
a.js:
import { B } from "./b"
export class A {}
b.js:
import { C } from "./c"
export class B {}
c.js:
import { A } from "./a"
export class C extends A {}
The class extension fails on C
Where require()
can return immediately, it should. However, currently if there's a need to defer, promises are used which most likely means it's never immediate. If it can be avoided, it should be.
The specific use-case is broadly:
export class Foo extends Error {}
class Baz {
boz() {
throw new Foo("foo")
}
}
Producing "ReferenceError: Foo is not defined"
The following pattern works fine:
class Foo extends Error {}
class Baz {
boz() {
throw new Foo("foo")
}
}
export {Foo}
Returning something more nuanced than {ns: {}, importer(f)}
will make it clearer when this has unexpectedly been used, as well as answering questions about how to use it.
If you load a module which has an explicit module.exports =
, this presumes that an export is in effect and returns a bridge, which breaks the original export.
Seriously I keep using it so why not publish it
bar.js:
import {foo} from "./foo"
export var bar = foo + 1
foo.js:
import "./bar" // for whatever reason
export var foo = 41
My suspicion is that this does not work at all. In most patterns this isn't a large problem because evaluation of deferred import is at runtime not load time.
These are currently untested but MAY be used by callers
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.