-
Notifications
You must be signed in to change notification settings - Fork 3
About the Build Process
By virtue of being an interpreted language, JavaScript code is able to simply be executed "as-is" by a JavaScript interpreter such as the ones in hackmud, Node.js, and in your web-browser. On the other hand, languages such as the C family must first be translated into machine code by a compiler before they can be executed. So if JavaScript doesn't need to be compiled, why then does hackshell have have a "build process"?
The short answer is that it doesn't - the hackshell source files can actually be used as-is in environments that support the latest JavaScript feature set. But most JavaScript environments don't support all of the language features that hackshell utilizes, so through a process called "transpilation" the hackshell source files are turned into files which nearly any JavaScript interpreter can understand.
This removes a lot of the requirements necessary to run hackshell, and additionally ensures it can be used in Node.js and web-browsers alike.
For those interested, two of the files in dist
are hackshell.js
and hackshell.mjs
- these are the actual "bundles" which contain all of hackmud's functionality in different formats. These bundles are necessary since hackshell is written using relatively new JavaScript features which aren't available in older versions of JavaScript, not to mention some which web-browsers have no idea how to interpret. Since hackshell is intended to run on a fairly large selection of Node versions and different web browsers, the hackshell source files are "transpiled" to earlier versions of JavaScript with "polyfills" which emulate new features, and then concatenated together into one big file that's easy to reference.
Specifically,
-
hackshell.js
is made to run on what is more or less the lowest common denominator when it comes to JavaScript features. It's packaged as a Universal Module
The remaining files are "sourcemaps" that improve the debugging experience by describing how code in the bundles related to the source files in lib