如何使用在ClosureScript中导入具有相对路径的模块的ES6模块?

时间:2017-10-01 04:48:00

标签: clojurescript

我正在尝试在ClojureScript应用中使用Twitter的Bootstrap 4(测试版)。由于CLJS-2369,使用:npm-deps编译器选项不起作用。所以我的下一次尝试是使用:foreign-libs编译器选项(参见github.com/au-phiware/cljsbuild-bootstrap4):

:foreign-libs [{:file "node_modules/bootstrap/js/src/util.js"
                :provides ["bootstrap.util"]
                :module-type :es6}
               {:file "node_modules/bootstrap/js/src/alert.js"
                :provides ["bootstrap.alert"]
                :requires ["bootstrap.util"]
                :module-type :es6}]})

在代码中,我要求模块为:

(ns cljsbuild-bootstrap4.core
  (:require [bootstrap.alert :as alert]))

但是我遇到了这个错误:

events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: Can't resolve './util' in '~/cljsbuild-bootstrap4'
    at onError (~/cljsbuild-bootstrap4/node_modules/enhanced-resolve/lib/Resolver.js:61:15)
    at loggingCallbackWrapper (~/cljsbuild-bootstrap4/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
    at runAfter (~/cljsbuild-bootstrap4/node_modules/enhanced-resolve/lib/Resolver.js:158:4)
    at innerCallback (~/cljsbuild-bootstrap4/node_modules/enhanced-resolve/lib/Resolver.js:146:3)
    at loggingCallbackWrapper (~/cljsbuild-bootstrap4/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
    at next (~/cljsbuild-bootstrap4/node_modules/tapable/lib/Tapable.js:252:11)
    at innerCallback (~/cljsbuild-bootstrap4/node_modules/enhanced-resolve/lib/Resolver.js:144:11)
    at loggingCallbackWrapper (~/cljsbuild-bootstrap4/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
    at next (~/cljsbuild-bootstrap4/node_modules/tapable/lib/Tapable.js:249:35)
    at resolver.doResolve.createInnerCallback (~/cljsbuild-bootstrap4/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:44:6)

注意:我还尝试了以下:foreign-libs选项,但收到的结果相同:

:foreign-libs [{:file "node_modules/bootstrap/js/src"
                :module-type :es6}]})

0 个答案:

没有答案