60 lines
1.1 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
Before ECMAScript 2015, module management had to be ad-hoc or provided by 3rd-party libraries such as Node.js, Webpack, or RequireJS. Fortunately, ES2015, provides language-standard mechanisms for module management, ``++import++`` and ``++export++``, and older usages should be converted.
=== Noncompliant code example
2022-02-04 17:28:24 +01:00
[source,javascript]
----
// circle.js
exports.area = function (r) {
return PI * r * r;
};
// foo.js
define(["./cart", "./horse"], function(cart, horse) { // Noncompliant
// ...
});
// bar.js
const circle = require('./circle.js'); // Noncompliant
----
=== Compliant solution
2022-02-04 17:28:24 +01:00
[source,javascript]
----
// circle.js
let area = function (r) {
return PI * r * r;
}
export default area;
// foo.js
import cart from "./cart.js";
import horse from "./horse.js";
// bar.js
import circle from "./circle.js"
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
include::highlighting.adoc[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]