ClojureScript

deftype/defrecord should not emit goog.provides

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

When compiling with optimizations :none a project referring to some external ClojureScript dependency (garden at least), executing goog.require("YOUR-ENTRY-POINT"); will throw an exception.

Find a project demoing the issue here.

Activity

Hide
David Nolen added a comment -

Yes that's correct.

Show
David Nolen added a comment - Yes that's correct.
Hide
Julien Eluard added a comment -

Would the following be the right syntax to use types defined by deftype:

(ns ...
  (:require [some.ns :as sns])

(extend-protocol IBlah

  sns/MyType
  ()
)
Show
Julien Eluard added a comment - Would the following be the right syntax to use types defined by deftype:
(ns ...
  (:require [some.ns :as sns])

(extend-protocol IBlah

  sns/MyType
  ()
)
Hide
David Nolen added a comment -

Support for :import was added in CLJS-312, supporting deftype/defrecord :import is fundamentally broken and should be backed out, :import should only be for Google Closure and Google Closure style libraries written in JavaScript.

Show
David Nolen added a comment - Support for :import was added in CLJS-312, supporting deftype/defrecord :import is fundamentally broken and should be backed out, :import should only be for Google Closure and Google Closure style libraries written in JavaScript.
Hide
David Nolen added a comment -

The problem here is that deftype/records emit goog.provides, Closure does not like multiple provides in a single source file - this problem crops up when not using file concatenating Closure optimizations - resolution of a namespace will be broken.

We need to remove the goog.provides around deftype/record and instead we should support something like (:import [goog.string StringBuffer]), will do something special, it will emit a goog.require("goog.string.StringBuffer") and it will alias StringBuffer to goog.string.StringBuffer.

Show
David Nolen added a comment - The problem here is that deftype/records emit goog.provides, Closure does not like multiple provides in a single source file - this problem crops up when not using file concatenating Closure optimizations - resolution of a namespace will be broken. We need to remove the goog.provides around deftype/record and instead we should support something like (:import [goog.string StringBuffer]), will do something special, it will emit a goog.require("goog.string.StringBuffer") and it will alias StringBuffer to goog.string.StringBuffer.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: