File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 24462446 (filter package-json?)
24472447 (map (fn [path]
24482448 [path (json/read-str (slurp path))])))
2449- module-fseq)]
2449+ module-fseq)
2450+ trim-package-json (fn [s]
2451+ (if (string/ends-with? s " package.json" )
2452+ (subs s 0 (- (count s) 12 ))
2453+ s))]
24502454 (into []
24512455 (comp
24522456 (map #(.getAbsolutePath %))
24612465 ; ; should be the only edge case in
24622466 ; ; the package.json main field - Antonio
24632467 (let [main (cond-> main
2464- (.startsWith main " ./" )
2468+ (string/starts-with? main " ./" )
24652469 (subs 2 ))
24662470 main-path (-> pkg-json-path
2467- (string/replace #" \\ " " / " )
2468- ( string/replace #" package\. json$" " " )
2471+ (string/replace \\ \/ )
2472+ trim- package- json
24692473 (str main))]
24702474 (some (fn [candidate]
2471- (when (= candidate (string/replace path #" \\ " " / " ))
2475+ (when (= candidate (string/replace path \\ \/ ))
24722476 name))
24732477 (cond-> [main-path]
2474- (nil? (re-find #"\. js(on)?$" main-path))
2478+ (not (or (string/ends-with? main-path " .js" )
2479+ (string/ends-with? main-path " .json" )))
24752480 (into [(str main-path " .js" ) (str main-path " /index.js" ) (str main-path " .json" )]))))))
24762481 pkg-jsons)]
24772482 {:provides (let [module-rel-name (-> (subs path (.lastIndexOf path " node_modules" ))
2478- (string/replace #" \\ " " / " )
2483+ (string/replace \\ \/ )
24792484 (string/replace #"node_modules[\\\/ ]" " " ))
24802485 provides (cond-> [module-rel-name (string/replace module-rel-name #"\. js(on)?$" " " )]
24812486 (some? pkg-json-main)
You can’t perform that action at this time.
0 commit comments