Compile error when using the new mmlight with a preprocessing script - mmenu

I've moved from the now deprecated jquery.mmenu (available at http://mmenu.frebsite.nl/) to mmlight (https://mmenujs.com/).
Same author, different version of the script, with the latter being more modern and short in size between the other things.
While using the new version in conjunction with a static site generator that has a pre-processing routine to compress Javascript I got an error that I was able to pin down to the line that contains the =>
document.addEventListener("DOMContentLoaded", () => {
Regrettably the error from the verbose is not helpful when it says:
SyntaxError: Unexpected token: punc ())
JS_Parse_Error.get ((execjs):3538:621)
(execjs):4060:48
(execjs):1:102
Object.<anonymous> ((execjs):1:120)
Module._compile (internal/modules/cjs/loader.js:738:30)
Object.Module._extensions..js (internal/modules/cjs/loader.js:749:10)
Module.load (internal/modules/cjs/loader.js:630:32)
tryModuleLoad (internal/modules/cjs/loader.js:570:12)
Function.Module._load (internal/modules/cjs/loader.js:562:3)
Function.Module.runMain (internal/modules/cjs/loader.js:801:12)
Does anybody have an idea on how to forward?
Is there any chance to rewrite the routine as a custom prototype or similar?

So apparently the issue is the new ES6 and Uglifier that doesn't support it in full yet as stated here https://github.com/lautis/uglifier
The workaround is to activate the compressor as per their recommendation.

Related

How do I build a modernizr with my custom list of features?

With the "old" modernizr I used something like
https://modernizr.com/download?-flexbox-flexboxlegacy-flexboxtweener-flexwrap-fullscreen-geolocation-video-webp-setclasses-dontmin
in order to build it with my needed features.
Apparently it doesn't work any more, at least it doesn't use the current release. The docs say that I must install modernizr with npm and then use bin/modernizr, which want the features to detect as a comma separated list of the -f parameter, and the options as a comma separated list of the -o paramenter.
I'm seeing a list of options and features in https://github.com/Modernizr/Modernizr/blob/HEAD/lib/config-all.json, but the features don't work: I'm trying
$ ./bin/modernizr -f "img/webp"
and I get
/home/user/git/Modernizr/bin/modernizr:137
throw new Error('invalid key value name - ' + prop);
^
Error: invalid key value name - img/webp
at /home/paolo/git/Modernizr/bin/modernizr:137:17
at Array.map (<anonymous>)
at find (/home/paolo/git/Modernizr/bin/modernizr:122:8)
at Object.<anonymous> (/home/paolo/git/Modernizr/bin/modernizr:145:24)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
at internal/main/run_main_module.js:17:47
I'm getting the same error with a comma separated list of various options.
What am I missing?

nexus generate supabase url not found (env variable)

Prisma Nexus generate does not find environment variable
I have import 'dotenv/config' at the root of my Apollo Server set. So I can develop fine. However, when I try to run ts-node --transpile-only apollo/schema I get the following error.
This tells me that dotenv isn't running on generate. Is there a configuration for this somewhere?
/{user-path}/node_modules/#supabase/supabase-js/src/SupabaseClient.ts:62
if (!supabaseUrl) throw new Error('supabaseUrl is required.')
^
Error: supabaseUrl is required.
at new SupabaseClient (/{user-path}/node_modules/#supabase/supabase-js/src/SupabaseClient.ts:62:29)
at createClient (/{user-path}/node_modules/#supabase/supabase-js/src/index.ts:21:10)
at /{user-path}/apollo/src/supabase-client.ts:9:22
at Object.<anonymous> (/{user-path}/apollo/src/supabase-client.ts:10:3)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Module.m._compile (/{user-path}/node_modules/ts-node/src/index.ts:1371:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Object.require.extensions.<computed> [as .ts] (/{user-path}/node_modules/ts-node/src/index.ts:1374:12)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
error Command failed with exit code 1.
I put import 'dotenv/config' at the root of the apollo server so running the server was fine. However, when I go to build the schema directly I don't get my env vars. So I also put the dotenv/config in my schema.ts. It's not a great solution since on server startup I config twice. But it works for now. Would appreciate to hear a better solution if anyone has one.

Cypress parallel run with Browserstack

I'm trying to run Cypress BDD test suites with Browserstack but i kept getting this error
CYPRESS_RUN_FAILEDCypress failed to run. Hide stack trace [-]
The plugins file is missing or invalid.
Your pluginsFile is set to .\cypress\plugins\index.js, but either
the file is missing, it contains a syntax error, or threw an error
when required. The pluginsFile must be a .js, .ts, or .coffee
file.
Or you might have renamed the extension of your pluginsFile. If
that's the case, restart the test runner.
Please fix this, or set pluginsFile to false if a plugins file is
not necessary for your project.
Error: Cannot find module 'cypress-cucumber-preprocessor' Require
stack:
.\cypress\plugins\index.js
\cypress_package\4.12.1\app\packages\server\lib\plugins\child\run_plugins.js
\cypress_package\4.12.1\app\packages\server\lib\plugins\child\index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:798:15)
at Module._load (internal/modules/cjs/loader.js:691:27)
at Module._load (electron/js2c/asar.js:717:26)
at Function.Module._load (electron/js2c/asar.js:717:26)
at Module.require (internal/modules/cjs/loader.js:853:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object. (.\cypress\plugins\index.js:2:18)
at Module._compile (internal/modules/cjs/loader.js:968:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:986:10)
at Module.load (internal/modules/cjs/loader.js:816:32)
at Module._load (internal/modules/cjs/loader.js:728:14)
at Module._load (electron/js2c/asar.js:717:26)
at Function.Module._load (electron/js2c/asar.js:717:26)
at Module.require (internal/modules/cjs/loader.js:853:19)
at require (internal/modules/cjs/helpers.js:74:18)
at module.exports (\cypress_package\4.12.1\app\packages\server\lib\plugins\child\run_plugins.js:208:15)
cypress run process exited with code 1 cypress run failed, exiting
with code: 1
After following the answer suggestion, it seems it cannot read my stepDef and Page class files;
enter image description here
From the stack trace, I see:
Cannot find module 'cypress-cucumber-preprocessor' Require stack
Looks like you're missing the dependency.
Cypress execution on BrowserStack requires you to explicitly mention the npm packages required by the test in the browserstack.json file.
Here's the documentation link: https://www.browserstack.com/docs/automate/cypress/npm-packages

Code coverage for Mocha in Windows 7

I am trying to do code coverage for mocha using istanbul which I have installed globally:
I do this as suggested here
E:\Do\learn_mocha>istanbul cover _mocha -- -R spec
C:\Users\Vamsi\AppData\Roaming\npm\_mocha.CMD:1
(function (exports, require, module, __filename, __dirname) { #IF EXIST "%~dp0
^
No coverage information was collected, exit without writing coverage information
SyntaxError: Unexpected token ILLEGAL
at Module._compile (module.js:439:25)
at Module._extensions..js (module.js:474:10)
at Object.Module._extensions..js (C:\Users\Vamsi\AppData\Roaming\npm\node_mo
dules\istanbul\lib\hook.js:102:13)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at runFn (C:\Users\Vamsi\AppData\Roaming\npm\node_modules\istanbul\lib\comma
nd\common\run-with-cover.js:114:16)
at C:\Users\Vamsi\AppData\Roaming\npm\node_modules\istanbul\lib\command\comm
on\run-with-cover.js:232:17
at C:\Users\Vamsi\AppData\Roaming\npm\node_modules\istanbul\lib\util\file-ma
tcher.js:56:16
at C:\Users\Vamsi\AppData\Roaming\npm\node_modules\istanbul\lib\util\file-ma
tcher.js:35:9
This command also throws the same error as above:
E:\Do\learn_mocha>istanbul cover --hook-run-in-context _mocha -- -R spec
I was told by a github issue that I had to add a path to mocha from node_modules,so I did this:
E:\Do\learn_mocha>istanbul cover C:\Users\Vamsi\AppData\Roaming\npm\mocha -- -R
spec
C:\Users\Vamsi\AppData\Roaming\npm\mocha:2
basedir=`dirname "$0"`
^
No coverage information was collected, exit without writing coverage information
SyntaxError: Unexpected token ILLEGAL
at Module._compile (module.js:439:25)
at Module._extensions..js (module.js:474:10)
at Object.Module._extensions..js (C:\Users\Vamsi\AppData\Roaming\npm\node_mo
dules\istanbul\lib\hook.js:102:13)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at runFn (C:\Users\Vamsi\AppData\Roaming\npm\node_modules\istanbul\lib\comma
nd\common\run-with-cover.js:114:16)
at C:\Users\Vamsi\AppData\Roaming\npm\node_modules\istanbul\lib\command\comm
on\run-with-cover.js:232:17
at C:\Users\Vamsi\AppData\Roaming\npm\node_modules\istanbul\lib\util\file-ma
tcher.js:56:16
at C:\Users\Vamsi\AppData\Roaming\npm\node_modules\istanbul\lib\util\file-ma
tcher.js:35:9
I am using Windows 7 as my OS
My test looks like this:
var assert = require("assert"); // core module
var C = require('../cash.js'); // our module
describe('Cash Register', function(){
describe('Module C', function(){
it('should have a getChange Method', function(){
assert.equal(typeof C, 'object');
assert.equal(typeof C.getChange, 'function');
})
it('getChange(210,300) should equal [50,20,20]',function(){
assert.deepEqual(C.getChange(210,300),[50,20,20]);
})
it('getChange(486,1000) should equal [500,10,2,2]',function(){
assert.deepEqual(C.getChange(486,1000),[500,10,2,2]);
})
it('getChange(1487,10000) should equal [5000,2000,1000,500,10,2,1]',function(){
assert.deepEqual(C.getChange(1487,10000),[5000,2000,1000,500,10,2,1]);
})
})
})
This worked for me:
I have both mocha and istanbul installed locally (no -g on the npm install).
I was running
*./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha*
and this came up with the error you were seeing above. I have changed this to look in the explicit local folder for mocha
*./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha*
and now everything is working great.
Please note I'm running my setup under gitbash on windows 7
Try this one, it should work.
istanbul cover %APPDATA%/npm/node_modules/mocha/bin/_mocha -- -R spec
As per this comment in github, in windows the batch commands are not being resolved inside javascript. Hence causing the issue.
As per the suggestion, you can directly pass the javascript function for mocha to istanbul. Here is how you can do it
Type npm ls -g --depth=0
Copy the first line of the output.
it should be C:\Users\<YourUserName>\AppData\Roaming\npm
Type istanbul cover C:\Users\<YourUserName>\AppData\Roaming\npm\node_modules\mocha\bin\_mocha test\folder
So here instead of passing the _mocha(windows command), the javascript from your global mocha installation is being passed. This is exactly what, happening for the local installation of mocha in the previous answer.
Try this command:
istanbul cover C:\\Users\\username\\AppData\\Roaming\\npm\\node_modules\\mocha\\bin\\_mocha
^
Insert Your username here
Where username = Your username
Try:
istanbul cover %NODE_HOME%\node_modules\mocha\bin_mocha -- -R spec --recursive test

Unable to generate syntax highlighter from .tmlanguage file in Ace.js

I have a .tmlanguage file that works fine in Sublime Text 2 and highlights everything as needed. But I'm unable to convert it to the Ace highlight rules.
Or rather I convert it but I get errors in ace.js main file.
What I do:
1) clone ace repository
2) navigate to ace/tool and execute this command in command prompt: npm install
3) then execute this command: node tmlanguage.js <path_to_tmlanguage_file> and get:
parseString is deprecated. Please, use parseStringSync instead.
Two files are created in ace\lib\ace\mode directory.
4) navigate to ace main folder by executing cd ..
5) execute node Makefile.dryice.js full and get:
module.js:340
throw err;
^
Error: Cannot find module 'dryice'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (E:\myPath\ace\Makefile.
dryice.js:38:12)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
6) have to execute npm install in /ace main folder and then again call node Makefile.dryice.js full to build the project.
Now built files are copied to ace/build folder.
Suppose my html file and /ace folder are in the same folder. Here is a chunk from html:
<script src="ace/build/src-noconflict/ace.js"></script>
<script>
var editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
editor.getSession().setMode("ace/mode/slbeclipse");
</script>
In the ace\build\src-noconflict folder I have mode-slbeclipse.js file.
7) open this html file in chrome (or other browsers) and get (in console tab):
Uncaught TypeError: object is not a function ace.js:8018
Here is the 8018th line:
this.moveCursorTo(row, column);
8) set a breakpoint -> first time it's hit this.moveCursorTo is undefined but the error is not thrown, the error thrown second time.
9) change that line to:
if(this.moveCursorTo)
{
this.moveCursorTo(row, column);
}
Than I get error on line 8564: Uncaught TypeError: object is not a function:
this.getTokenizer = function() {
if (!this.$tokenizer) {
this.$highlightRules = new this.HighlightRules();
// here the exception occures
this.$tokenizer = new Tokenizer(this.$highlightRules.getRules());
}
return this.$tokenizer;
};
10) Tried to debug and edit ace.js file multiple times - errors in other places occure.
Sublime Text 2 uses .tmlanguage properly and everything is highlighted. So, I think, the problem should be in ace or (I hope) it's my fault and I'm missing something obvious.
The converter isn't fully automatic, it just extracts regexps from tmlanguage file, and resulting file needs to be fixed manually. (see here)
I'd suggest to ask for help on that issue.

Resources