This repository has been archived by the owner on Aug 23, 2018. It is now read-only.
This repository has been archived by the owner on Aug 23, 2018. It is now read-only.
Closed
Description
See elm/compiler#1029 for discussion that led to this.
The following should be incorporated into the output JS of compiled Elm files.
(function() {
var Elm = ... // current emitted code goes here
if (typeof define === "function" && define.amd) {
define([], function() {
return Elm;
});
} else if (typeof module === "object") {
module.exports = Elm;
} else {
if (typeof this.Elm === "undefined") {
this.Elm = Elm;
} else {
throw new Error("This page is trying to import multiple compiled Elm programs using the same `Elm` global object, which would cause conflicts. This can be resolved by using a module loader like RequireJS to import the compiled Elm programs into different objects.")
}
}
}).call(this);
PREVIOUS VERSION:
This version is more "stock" and will silently overwrite any previous Elm
globals defined on the page...which seems far less desirable than crashing early with a helpful message.
(function() {
var Elm = ... // current emitted code goes here
if (typeof define === "function" && define.amd) {
define([], function() {
return Elm;
});
} else if (typeof module === "object") {
module.exports = Elm;
} else {
this.Elm = Elm;
}
}).call(this);
Metadata
Assignees
Labels
No labels