This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-07-06
Channels
- # aws-lambda (8)
- # beginners (49)
- # boot (13)
- # braveandtrue (2)
- # cider (12)
- # cljs-dev (15)
- # cljsrn (2)
- # clojure (143)
- # clojure-italy (8)
- # clojure-nl (17)
- # clojure-spec (22)
- # clojure-uk (21)
- # clojurescript (145)
- # code-reviews (1)
- # cursive (33)
- # data-science (14)
- # datomic (25)
- # emacs (3)
- # events (1)
- # fulcro (48)
- # graphql (1)
- # onyx (15)
- # perun (5)
- # play-clj (2)
- # protorepl (1)
- # re-frame (27)
- # remote-jobs (3)
- # ring (3)
- # rum (7)
- # shadow-cljs (87)
- # specter (4)
- # test-check (14)
- # testing (2)
- # tools-deps (9)
Hi, I'm tracking down a npm dependency issue in my production app that I'm having trouble reproducing in a minimal demo. Pulling in the raven-js npm dependency in my prod app gives me a syntax error when requiring the module. I can trace it to an innocuous-looking function in a utilities js file.
The only difference I can see is in the 'Sources' tab in the Chrome inspector: a file under node_modules/raven-js/src/utils.js
exists in my test project, but in prod it's missing (all neighbouring source files are there). This might be a red herring but I can't see any other differences worthy of note.
The file module\$node_modules\$raven_js\$src\$utils.js
is served up in both projects, along with the .map file.
Any guidance on things I could try greatly appreciated, as I feel a bit like I'm shooting in the dark!
and you do not get this problem during development or is the code just not used in dev?
It's a bit cobbled together atm. I run shadow-cljs watch app
from one terminal window, and boot
to serve assets out of target/public.
and boot copies everything correctly? not that it just stopped in the middle of the file or something?
check if the <output-dir>/cljs-runtime/module\$node_modules\$raven_js\$src\$utils.js
file is corrupted or so
or rather check if the file generated by shadow-cljs is identical to the file served by boot
There is a difference:
1,3c1,3
< shadow$provide.module$node_modules$raven_js$src$utils=function(global,process,require,module,exports){function isUndefined(what){return void 0===what}function isPlainObject(what){return"[object Object]"===Object.prototype.toString.call(what)}function isString(what){return"[object String]"===Object.prototype.toString.call(what)}function isArray(what){return"[object Array]"===Object.prototype.toString.call(what)}function supportsFetch(){if(!("fetch"in _window))return!1;try{return new Headers,new Request(""),
< new Response,!0}catch(e){return!1}}function each(obj,callback){var i,j;if(isUndefined(obj.length))for(i in obj)hasKey(obj,i)&&callback.call(null,i,obj[i]);else if(j=obj.length)for(i=0;i<j;i++)callback.call(null,i,obj[i])}function truncate(str,max){if("number"!==typeof max)throw Error("2nd argument to `truncate` function should be a number");return"string"!==typeof str||0===max?str:str.length<=max?str:str.substr(0,max)+"…"}function hasKey(object,key){return Object.prototype.hasOwnProperty.call(object,
< key)}function joinRegExp(patterns){for(var sources=[],i=0,len=patterns.length,pattern;i<len;i++)pattern=patterns[i],isString(pattern)?sources.push(pattern.replace(/([.*+?^=!:}()|\[\]\/\\])/g,"\\$1")):pattern&&pattern.source&&sources.push(pattern.source);return new RegExp(sources.join("|"),"i")function htmlElementAsString(elem){var out=[],className,attr;if(!elem||!elem.tagName)return"";out.push(elem.tagName.toLowerCase());elem.id&&out.push("#"+elem.id);if((className=elem.className)&&isString(className)){var classes=
---
> shadow$provide.module$node_modules$raven_js$src$utils=function(global,process,require,module,exports,shadow$shims){function isUndefined(what){return void 0===what}function isPlainObject(what){return"[object Object]"===Object.prototype.toString.call(what)}function isString(what){return"[object String]"===Object.prototype.toString.call(what)}function isArray(what){return"[object Array]"===Object.prototype.toString.call(what)}function supportsFetch(){if(!("fetch"in _window))return!1;try{return new Headers,
> new Request(""),new Response,!0}catch(e){return!1}}function each(obj,callback){var i,j;if(isUndefined(obj.length))for(i in obj)hasKey(obj,i)&&callback.call(null,i,obj[i]);else if(j=obj.length)for(i=0;i<j;i++)callback.call(null,i,obj[i])}function truncate(str,max){if("number"!==typeof max)throw Error("2nd argument to `truncate` function should be a number");return"string"!==typeof str||0===max?str:str.length<=max?str:str.substr(0,max)+"…"}function hasKey(object,key){return Object.prototype.hasOwnProperty.call(object,
> key)}function joinRegExp(patterns){for(var sources=[],i=0,len=patterns.length,pattern;i<len;i++)pattern=patterns[i],isString(pattern)?sources.push(pattern.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")):pattern&&pattern.source&&sources.push(pattern.source);return new RegExp(sources.join("|"),"i")}function htmlElementAsString(elem){var out=[],className,attr;if(!elem||!elem.tagName)return"";out.push(elem.tagName.toLowerCase());elem.id&&out.push("#"+elem.id);if((className=elem.className)&&isString(className)){var classes=
otherwise try deleting the .shadow-cljs/builds
directory just to rule out a cache issue
can't really tell what else is different in the diff besides ,shadow$shims
which was added recently
other than that is appears similar. be sure to check the actual output served by boot though might be something happening in transit
OK, still broken but the diff has changed:
3c3
< key)}function joinRegExp(patterns){for(var sources=[],i=0,len=patterns.length,pattern;i<len;i++)pattern=patterns[i],isString(pattern)?sources.push(pattern.replace(/([.*+?^=!:}()|\[\]\/\\])/g,"\\$1")):pattern&&pattern.source&&sources.push(pattern.source);return new RegExp(sources.join("|"),"i")function htmlElementAsString(elem){var out=[],className,attr;if(!elem||!elem.tagName)return"";out.push(elem.tagName.toLowerCase());elem.id&&out.push("#"+elem.id);if((className=elem.className)&&isString(className)){var classes=
---
> key)}function joinRegExp(patterns){for(var sources=[],i=0,len=patterns.length,pattern;i<len;i++)pattern=patterns[i],isString(pattern)?sources.push(pattern.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")):pattern&&pattern.source&&sources.push(pattern.source);return new RegExp(sources.join("|"),"i")}function htmlElementAsString(elem){var out=[],className,attr;if(!elem||!elem.tagName)return"";out.push(elem.tagName.toLowerCase());elem.id&&out.push("#"+elem.id);if((className=elem.className)&&isString(className)){var classes=
replace(/([.*+?^=!:}()|\[\]\/\\])/g,"\\$1"))
replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1"))
@lsnape do you have anything in your config which might affect this? custom :js-options
?
I don't actually think that there is anything you do via the config to affect this but gotta rule it out still
@thheller I think I know what it is. We've got an asset fingerprinting boot task that scans all source files for template params ${param}
and replaces them with a hashed version, or in the case of development skips over them. It looks like the regex is being incorrect replaced by the task. 😞
FWIW shadow-cljs has that built-in via https://shadow-cljs.github.io/docs/UsersGuide.html#NameHashing
Here's the boot task I wrote to take care of it: https://github.com/ELiTLtd/boot-asset-fingerprint
Feel free to steal anything out of there. It's something I'd be interesting in doing with a bit of guidance? Up to you!
Yeah, it hashes the file names and the references in other files, such as html and css.
So ${img/foo.png}
in bar.html becomes img/foo-af28b.png
in the html file, plus a new file is written to the file path.
I really like the way you do it by generating a manifest file for module hashing. It's more work to plumb it in the project, but it's very flexible.
That's what we're doing in our latest project: html page frame is all hiccup rendered on request (memoized).
I'm still struggling with shadow-cljs in CI. running a release build takes up to 10 mins
for reference, about half of that is just starting shadow-cljs 😬 compiling takes about 5 mins
I'm trying to compile a target :karma
build:
-> build target: :karma stage: :configure
NullPointerException:
shadow.build.targets.karma/configure (karma.clj:21)
shadow.build.targets.karma/configure (karma.clj:16)
shadow.build.targets.karma/process (karma.clj:112)
shadow.build.targets.karma/process (karma.clj:108)
clojure.lang.Var.invoke (Var.java:381)
shadow.build/process-stage/fn--15189 (build.clj:120)
shadow.build/process-stage (build.clj:117)
shadow.build/process-stage (build.clj:109)
I'm getting an error when trying to run karma tests:
d on socket wpx59euvS82blWCjAAAA with id 10464947
HeadlessChrome 0.0.0 (Mac OS X 10.13.5) ERROR
{
"message": "Uncaught ReferenceError: shadow is not defined\nat : shadow is not defined\n at eval (eval at <anonymous> (/Users/r627543/Code/fido/packages/web/app/node_modules/karma-cljs-test/adapter.js:6:7), <anonymous>:1:1)\n at ContextKarma.start (/Users/r627543/Code/fido/packages/web/app/node_modules/karma-cljs-test/adapter.js:6:7)\n at ContextKarma.loaded ()\n at ",
"str": "Uncaught ReferenceError: shadow is not defined\nat : shadow is not defined\n at eval (eval at <anonymous> (/Users/r627543/Code/fido/packages/web/app/node_modules/karma-cljs-test/adapter.js:6:7), <anonymous>:1:1)\n at ContextKarma.start (/Users/r627543/Code/fido/packages/web/app/node_modules/karma-cljs-test/adapter.js:6:7)\n at ContextKarma.loaded ()\n at "
}
looks like its trying to call the shadow.test.karma.init
fn maybe and doesnt find it?
this is what my config looks like:
{:target :karma
:ns-regexp ".devcards$"
:output-to "target/karma/tests.js"}
module.exports = function (config) {
config.set({
browsers: ['ChromeHeadless'],
// The directory where the output file lives
basePath: 'target/karma/',
// The file itself
files: ['target/karma/tests.js'],
frameworks: ['cljs-test'],
plugins: ['karma-cljs-test', 'karma-chrome-launcher'],
colors: true,
logLevel: config.LOG_INFO,
client: {
args: ["shadow.test.karma.init"],
singleRun: true
}
})
};