We're updating the issue view to help you get more done. 

Node REPL can't load converted JS modules

Description

I've been trying the CommonJS support and have been failing to get it to work in Node, and likewise so has Maria Neise. This is in the case of invoking build prior to launching the REPL as well as trying a new suggestion in CLJS-1313.

I cranked up the verbosity to see what is going on and ultimately hit upon the idea that

1 goog.require('module$libs$german');

isn't going to work in Node and instead needs the same alternative logic that is employed for :foreign-libs in cljs.compiler/load-libs, in particular this needs to be emitted.

1 cljs.core.load_file("out/german.js");

I hacked the code a bit and got the "german" CommonJS module to load in Node and be useable:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 To quit, type: :cljs/quit cljs.user=> (require '[german :refer [hello]]) Compiling out/cljs/core.cljs Using cached cljs.core out/cljs/core.cljs Compiling out/cljs/core.cljs Using cached cljs.core out/cljs/core.cljs goog.provide('cljs.user'); goog.require('cljs.core'); goog.require('cljs.repl'); goog.require('cljs.pprint'); cljs.core.load_file("out/german.js"); nil cljs.user=> (hello) module$libs$german.hello.call(null) "Hallo"

The attached patch illustrates the hack to get the above to work. The real fix would be a generalization of this.

Environment

Node REPL with the latest CommonJS loading impl

Status

Assignee

Maria Geller

Reporter

Mike Fikes

Labels

None

Approval

None

Patch

None

Priority

Major