Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Make mustache.mjs work with Deno #1

Merged
merged 1 commit into from
Oct 17, 2019
Merged

Make mustache.mjs work with Deno #1

merged 1 commit into from
Oct 17, 2019

Conversation

zekth
Copy link

@zekth zekth commented Oct 12, 2019

Here is the working changes.
The first import had to be changed due to this: denoland/deno#1065

Also just done what we discussed and it's working :)

@phillipj
Copy link
Owner

Hoorray great work! Tried deno for the first time now, and it surely is pretty sweet having the TypeScript compiler built-in 👍

The CI failures seems to be related to eslint is still targeting mustache.js which is now actually the build output. It should be changed to target mustache.mjs instead. I'll fix that in my branch.

@phillipj
Copy link
Owner

Took the liberty of pushing back to your branch with some minor whitespace changes -- CI is now green 🎉

Thanks a lot for looking into making this deno-friendly!

I'll merge your changes into my branch now, before taking a step back and double checking a few things before opening the PR to upstream mustache.js.

@phillipj phillipj changed the title Update mustache.mjs to work with Deno Make mustache.mjs work with Deno Oct 17, 2019
@phillipj phillipj merged commit 0647792 into phillipj:esm-ify Oct 17, 2019
@zekth zekth deleted the zekth-patch-1 branch October 17, 2019 20:52
@zekth
Copy link
Author

zekth commented Oct 17, 2019

Great!

@phillipj
Copy link
Owner

@zekth I really want to ensure deno works with mustache going forward by having a CI job run a trivial test. Ideally I'd like deno to exit with status > 0 to signal a test failure, but my tests locally always exist with status 0. Got any protips up your sleeve?

import { test } from "https://deno.land/std/testing/mod.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
import mustache from "../../mustache.mjs";

const view = {
  title: "Joe",
  calc: function() {
    return 2 + 4;
  }
};

test(function canUseMustache() {
  assertEquals(
    mustache.render("{{title}} spends {{calc}}", view),
    "Joe spends 6"
  );
});

I've introduced a bug locally to trigger TypeScript compile error:

$ deno test deno-test.ts
Compile file:///..../test/module-systems/deno-test.ts
error TS2552: Cannot find name 'object'. Did you mean 'Object'?

► file:///..../mustache.mjs:11:30

11   return objectToString.call(object) === '[object Array]';
                                ~~~~~~

  'Object' is declared here.

    ► $asset$/lib.es5.d.ts:267:13

    267 declare var Object: ObjectConstructor;
                    ~~~~~~


$ echo $!
0

Sadly that won't do much good in CI :/ At first glance there's no deno CLI argument that will make it explode on TS errors / test failures?

@phillipj
Copy link
Owner

phillipj commented Oct 21, 2019

Nevermind, found the blooper; should have checked the exit code with echo $? instead of echo $!. Luckily it works as I was hoping for with that sorted out.

@phillipj
Copy link
Owner

@zekth
Copy link
Author

zekth commented Oct 21, 2019

Also there is a Deno Github action if you want : https://github.com/denolib/deno-action

@phillipj
Copy link
Owner

Ahh cool! Google suggested https://github.com/denolib/setup-deno, but that deno-action alternative might be better for all I know 🤷‍♂

@zekth
Copy link
Author

zekth commented Oct 28, 2019

There is an improvement on the exposure of properties on importing json files : denoland/deno#3210

@phillipj
Copy link
Owner

Oh cool! Will give that a shot before opening the PR to the upstream mustache.js repo.

phillipj pushed a commit that referenced this pull request Nov 5, 2019
Minor adjustments needed to make the TypeScript compiler
that is built into Deno, be happy with how mustache.js'
ES module source looks in terms of function parameters
passed and object mutability.

Refs #1
phillipj pushed a commit that referenced this pull request Nov 6, 2019
Minor adjustments needed to make the TypeScript compiler
that is built into Deno, be happy with how mustache.js'
ES module source looks in terms of function parameters
passed and object mutability.

Refs #1
phillipj pushed a commit that referenced this pull request Nov 6, 2019
Minor adjustments needed to make the TypeScript compiler
that is built into Deno, be happy with how mustache.js'
ES module source looks in terms of function parameters
passed and object mutability.

Refs #1
phillipj pushed a commit that referenced this pull request Nov 6, 2019
Minor adjustments needed to make the TypeScript compiler
that is built into Deno, be happy with how mustache.js'
ES module source looks in terms of function parameters
passed and object mutability.

Refs #1
phillipj pushed a commit that referenced this pull request Nov 6, 2019
Minor adjustments needed to make the TypeScript compiler
that is built into Deno, be happy with how mustache.js'
ES module source looks in terms of function parameters
passed and object mutability.

Refs #1
phillipj pushed a commit that referenced this pull request Nov 6, 2019
Minor adjustments needed to make the TypeScript compiler
that is built into Deno, be happy with how mustache.js'
ES module source looks in terms of function parameters
passed and object mutability.

Refs #1
phillipj pushed a commit that referenced this pull request Nov 6, 2019
Minor adjustments needed to make the TypeScript compiler
that is built into Deno, be happy with how mustache.js'
ES module source looks in terms of function parameters
passed and object mutability.

Refs #1
phillipj pushed a commit that referenced this pull request Nov 6, 2019
Minor adjustments needed to make the TypeScript compiler
that is built into Deno, be happy with how mustache.js'
ES module source looks in terms of function parameters
passed and object mutability.

Refs #1
phillipj pushed a commit that referenced this pull request Dec 4, 2019
Minor adjustments needed to make the TypeScript compiler
that is built into Deno, be happy with how mustache.js'
ES module source looks in terms of function parameters
passed and object mutability.

Refs #1
phillipj pushed a commit to janl/mustache.js that referenced this pull request Dec 18, 2019
Minor adjustments needed to make the TypeScript compiler
that is built into Deno, be happy with how mustache.js'
ES module source looks in terms of function parameters
passed and object mutability.

Refs phillipj#1
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants