logseq / logseq/mldoc

JS output should not use `this` in strict mode

Open
#109 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
OCaml
Stars
281
Forks
30
Avg merge
5h 30m
Merged PRs (30d)
4

Description

When I try to use this repo in the browser, I see an error related to the output that it uses `this` instead of `globalThis` or `window`.

See the last line of https://unpkg.com/mldoc@1.1.8/index.js
The whole js is an IIFE like this:

```js
(function(joo_global_object)
(function(){return this}()));
```

This may be related to https://github.com/ocsigen/js_of_ocaml/issues/699

There is a potential fix to add `wrap-with-fun` flag or command, but I do not understand OCaml or its tools. In the [test](https://github.com/pengx17/mldoc-test/blob/main/patches/mldoc%2B1.1.8.patch) I do a manual patch to `mldoc` instead. Not sure if the issue will fixed by logseq team or not?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the last line of the generated index.js from mldoc@1.1.8 and compare it with the manual change in the linked mldoc+1.1.8.patch. Trace the OCaml or js_of_ocaml build entry point that produces this wrapper, then verify the browser output no longer relies on this in strict mode.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, ocaml
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.