How to use swig template in geddy js - swig

I have this error when start geddy
TypeError: Object # has no method 'init'
at new swig (C:\Users\Username\AppData\Roaming\npm\node_modules\geddy\lib\template\adapters\swig.js:25:15)
at C:\Users\Username\AppData\Roaming\npm\node_modules\geddy\lib\template\adapters\index.js:42:14
at setOptions (C:\Users\Username\AppData\Roaming\npm\node_modules\geddy\lib\template\adapters\index.js:44:5)
at Adapter.set (C:\Users\Username\AppData\Roaming\npm\node_modules\geddy\lib\template\adapters\index.js:97:21)
at Partial.renderSelf (C:\Users\Username\AppData\Roaming\npm\node_modules\geddy\lib\template\partial.js:125:13)
at handleData (C:\Users\Username\AppData\Roaming\npm\node_modules\geddy\lib\template\partial.js:99:16)
at C:\Users\Username\AppData\Roaming\npm\node_modules\geddy\lib\template\partial.js:117:9
at fs.js:266:14
at Object.oncomplete (fs.js:107:15)

This was caused by a breaking change in the last Swig update, and has been fixed in this pull request.
I'll check now with #mde to see if we've pushed it out to NPM yet.

Related

Remove debugger keyword during compilation in google closure

UPDATE:
The JS version of closure-compiler is no longer supported or maintained.
https://github.com/google/closure-compiler-npm/blob/master/packages/google-closure-compiler-js/readme.md
Im trying to find if there is a way to remove the "debugger" keyword during compilation process, im using the javascript version google-closure-compiler with gulp.
Looking through the documentation it is clear we can set the flag to stop/show error messages during compilation by doing the following.
https://github.com/google/closure-compiler/wiki/Flags-and-Options
--jscomp_off
translating this to gulp, it is:
const googleClosureOptions = {
...
jscomp_error:"checkDebuggerStatement"
}
however this works on stopping the compilation by throwing error or to show a warning.
zyxcdafg.js:1444: ERROR - [JSC_DEBUGGER_STATEMENT_PRESENT] Using the debugger statement can halt your application if the user has a JavaScript debugger running.
debugger;
^^^^^^^^^
but what I am trying to achieve is to remove the debugger keyword. Is this possible to achieve using googleclosure. I can not find any flags or options relating to this.
UPDATE:
The JS version of closure-compiler is no longer supported or maintained.
https://github.com/google/closure-compiler-npm/blob/master/packages/google-closure-compiler-js/readme.md
No I don't think so. I'd suggest you use something else to do it. Like sed:
find dist -name "*.js" -exec sed -i 's/\sdebugger;//' {} +
Something like that will find files in your dist folder that end with .js and then exec-ute sed to replace all instances of debugger; with nothing.
You could add that to a script that calls your Closure Compiler build.
The compiler doesn't have a command-line api for defining custom code removal passes, but the compiler's architecture does allow for registering custom passes and a pass to remove a debugger statement should be trivial:
if (n.isDebugger()) {
compiler.reportChangeToEnclosingScope(n);
n.detach();
}
The general structure would follow:
https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/CheckDebuggerStatement.java

How can I stop the ClojureScript compiler from resolving certain `require`s?

In my ClojureScript code I am requiring a JavaScript module called seedrandom which is in the node_modules folder, like this:
(ns something.core
(:require ["seedrandom" :as rnd]))
(js/console.log (.quick (rnd "x")))
According to the seedrandom documentation it is intended for both nodejs and the browser, and I've previously included and used it successfully in ClojureScript code via a <script> tag, confirming it works in the browser.
Running this cljs file in lumo on the command line works well and outputs a deterministically random number.
When I try to use this same cljs file in my Reagent frontend project I see the following error:
Compiling build :app to "public/js/app.js" from ["src" "env/dev/cljs"]...
events.js:183
throw er; // Unhandled 'error' event
^
Error: module not found: "crypto" from file /home/chrism/dev/something/node_modules/seedrandom/seedrandom.js
at onresolve (/home/chrism/dev/something/node_modules/#cljs-oss/module-deps/index.js:181:30)
...
Inside seedrandom.js we see the following:
// When in node.js, try using crypto package for autoseeding.
try {
nodecrypto = require('crypto');
} catch (ex) {}
Clearly this code is intended to ignore the built-in nodejs crypto module when running in the browser. The problem, as far as I can tell, is that the ClojureScript compiler does not know that - it sees that require('crypto') and tries to pull it into the compilation phase, but can't find it because it's a nodejs built-in.
Is there some way I can tell the compiler to ignore that particular require? Or can I shim the 'crypto' module somehow? What is the cleanest way to solve this?
Note: I have previously experienced this same issue with JavaScript modules which check for the fs node module. Hope we can find a general solution to use again in future. Thanks!
Relevant versions: [org.clojure/clojurescript "1.10.520"] and [reagent "0.8.1"].
This answer is related, asking a similar question from the perspective of Google Closure, which ClojureScript uses, but I'm looking for an answer I can use specifically with cljs.

How to fix 'write callback called multiple times'

I am suddenly getting a gulp error that I don't understand for a project that was previously running fine. I haven't changed anything in my gulpfile.js, so I don't understand what caused the error. Can anyone enlighten me?
This is the error I am getting:
Error: write callback called multiple times
at DestroyableTransform.afterTransform (/Users/hannah/Documents/random projects/salamander/node_modules/readable-stream/lib/_stream_transform.js:84:31)
at EventEmitter.signals.on.err (/Users/hannah/Documents/random projects/salamander/node_modules/gulp-cache/lib/index.js:451:7)
at EventEmitter.emit (events.js:198:13)
at DestroyableTransform.onError (/Users/hannah/Documents/random projects/salamander/node_modules/gulp-cache/lib/index.js:288:15)
at Object.onceWrapper (events.js:286:20)
at DestroyableTransform.emit (events.js:203:15)
at Immediate.<anonymous> (/Users/hannah/Documents/random projects/salamander/node_modules/through2-concurrent/through2-concurrent.js:37:14)
at runCallback (timers.js:706:11)
at tryOnImmediate (timers.js:676:5)
at processImmediate (timers.js:658:5)
Emitted 'error' event at:
at DestroyableTransform.onerror (/Users/hannah/Documents/random projects/salamander/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:558:12)
at DestroyableTransform.emit (events.js:198:13)
at DestroyableTransform.afterTransform (/Users/hannah/Documents/random projects/salamander/node_modules/readable-stream/lib/_stream_transform.js:84:17)
at EventEmitter.signals.on.err (/Users/hannah/Documents/random projects/salamander/node_modules/gulp-cache/lib/index.js:451:7)
[... lines matching original stack trace ...]
at runCallback (timers.js:706:11)
In case anyone else has this issue:
I found out that the error was coming from my image minifying task (gulp-imagemin). I had some SVG files in my image folder that I think were structured incorrectly or something. I removed them from the image folder and then gulp started running again.
This is actually due to we are using the imagemin's plugins along with cache.
Please run this npm rebuild jpegtran-bin this will reset it, and run your gulp task comment again!.
thanks.
In my case, it was optimization with imagemin.gifsicle() and a big animated gif-file (57Mb). Resaving the image with PhotoShop didn't help. I'm not sure about the root of the problem, but removing the file solves the problem.
My issue was a dumb one... I am using through2 to pipe and replace the contents of my file and wrapped it as a function. Well, this function was trying to console.log a variable that never gets defined in the branch of logic it was called from.
So yeah, the error message made me look deeper than I needed to since I would have expected an undefined type error instead of the 'write callback called multiple times' I got.

feathers-blob error dauria can no read property startsWith

I just started using feathers-blob for uploading files from a angular4 client using dropzone.
I followed the example but made an explicit service for the upload not tu blur up the app.js.
It compiles without error, but on execution i receive the following error, even i do NOT use multipart portion:
Info: error:
system/file-upload - Method: create: Cannot read property 'startsWith'
of undefined error: TypeError: Cannot read property 'startsWith' of
undefined
at Dauria.parseDataURI (/projects/esaas-2/esaas-server-basic/node_modules/feathers-blob/node_modules/dauria/dauria.js:27:17)
at Object.create (/projects/esaas-2/esaas-server-basic/node_modules/feathers-blob/lib/index.js:87:52)
at /projects/esaas-2/esaas-server-basic/node_modules/feathers-hooks/lib/hooks.js:101:31
at /projects/esaas-2/esaas-server-basic/node_modules/feathers-hooks/lib/hooks.js:85:16
I also made sure to use the same versions of feathers-blob and dauria and multer as in the sample and not the newer ones from the npm. Result is the same.
What am i doing wrong? Any help appreciated. Thanks
If you look into dauria's code you'll see where the problem comes from:
Dauria.prototype.parseDataURI = function(dataURI){
if(!( dataURI.startsWith('data:') )) throw new Error(
this.errors.MISSING_PREFIX
);
Which means that somehow the value that you pass to the caller dauria.parseDataURI(yourDataVariable) - the yourDataVariable value does not start with 'data:'.
I made a test on Node and I had the same error while trying to upload an image. I solved it by adding the string "data:image/jpeg;base64" followed by the 64 encoded image.

HTML 5 - GRUNT BUILD : Fatal error: Object has no method 'compact'

I'm trying to build a project with GRUNT. it throws the following error,
Running "cuff:dev" (cuff) task
>> Building src/pages/home
Fatal error: Object home.less has no method 'compact'
src/pages/home/ -> home.less file,
section#home {
}
I didn't have any method in home.less. What i did wrong?. I can't understand the meaning of this error.
the info you provided is too less, my guess is dev target of cuff task has nested tasks probably something related to home task taking less as target, but grunt is not able to load less target. ( probably not defined at all or part of a grunt plugin you forgot to load )
That kind of errors are thrown when you call a target/task but grunt can not find/load it.
use grunt --help to load all available commands in your context ( commands from plugins are not shown by this command)