Skip to content

Commit

Permalink
Introduce build step to generate .js | .min.js from .mjs
Browse files Browse the repository at this point in the history
By making the main source code an ES module placed in `mustache.mjs`,
what used to be in `mustache.js` is now built based off of the ES module
source inside `mustache.mjs`.

This is done primarily to avoid breaking existing projects already using
mustache.js, by keeping the UMD-version in `mustache.js` part of the git
repository in addition to the minified version in `mustache.min.js`.

After experiment with several compilers;

- Babel
- TypeScript
- Rollup

and examining their build output, [Rollup](https://rollupjs.org/) was chosen
because of the UMD output it creates which closely resembles what we've
historically had in the previous `mustache.js` source code.

The contents of `.js | .min.js` files has been generated by running
the following npm script:

```
$ npm run build
```

Also change linting w/eslint to target the `.mjs` file, since the output
of rollup that ends up in the old `mustache.js` file is not sensible to
do linting on.
  • Loading branch information
phillipj committed Dec 18, 2019
1 parent b523b16 commit f25abbe
Show file tree
Hide file tree
Showing 5 changed files with 769 additions and 33 deletions.
11 changes: 10 additions & 1 deletion .eslintrc
Expand Up @@ -16,5 +16,14 @@
"no-use-before-define": 0,
"no-process-exit": 0,
"strict": 0
}
},
"overrides": [
{
"files": ["mustache.mjs"],
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2015
}
}
]
}

0 comments on commit f25abbe

Please sign in to comment.