How can one view debug logs in Semantic-UI-React? - semantic-ui

Semantic-UI-React emits debug logs: https://github.com/Semantic-Org/Semantic-UI-React/blob/master/src/modules/Modal/Modal.js#L162
But I don't see them in my browser. I'm using semantic-ui-react 0.76.0. In my local npm version of semantic-ui-react, the debug lines seem to be stripped out. Is there some debug build I need? Or maybe I need to set some webpack configuration?

These logs are accesible only within development build of SUIR, they are striped from any npm build by babel-plugin.
You can import component directly from src with such import:
import Modal from 'semantic-ui-react/src/modules/Modal';
Your builder will build component with all non-transformed code and you will can enable it with browser console:
localStorage.debug = '*'
Also, you we will to make a page reload after this.
Don't do this with your production builds :)

Related

Nextjs middleware prevents build

I am currently working on a nextjs project. The nextjs project is a bit older and used initially a _middleware.ts file in the pages directory. A while ago, the older nextjs version came in conflict with an update that we wanted to do. In order to get it working, we had to change the name of the file to: middleware.ts(without the underscore). Everything is working fine in development. When running npm run dev the following warning is displayed:
warn - using beta Middleware (not covered by semver) - https://nextjs.org/docs/messages/beta-middleware
until the actual build. When building, the following error is displayed:
- Collecting page data .ReferenceError: self is not defined
at Object.<anonymous> (/Users/****/**** Dropbox/**** ****/Mac/Documents/GitHub/******.com/_next/server/pages/middleware.js:1:1)
***
> Build error occurred
Error: Failed to collect page data for /middleware
According to: https://nextjs.org/docs/messages/middleware-upgrade-guide, the middleware file should currently be placed in the root directory (next to the pages folder). when moving the file middleware file to this directory, the error displayed while building does indeed go away, but when using npm run dev a white page is displayed containing:
style data-next-hide-fouc="true"body{display:none}/style
Moving the middleware file back to the pages folder, everything works fine in dev, but the page can not be built.
I have tried different things, among them:
I ran npm i eslint-config-next#latest --save-dev according to the above mentioned page, trying to make sure that I am running the latest nextjs verion. (When running npm next -v this although displays: 8.11.0).
I made sure that there is no assetPrefix defined, neither a basepath (Next.js Error Getting 404 When Fetching JS Resources After Refresh).
I added: <body style={{ display: "block" }}> according to this: https://github.com/vercel/next.js/issues/10285 . This only displays a plain version of the website (all styling is gone).
I made sure that there was no cypres being used to mess with the clock. This does not seem to be the case.
Any help is appreciated.

How to console.log inside node_modules in NextJs?

I am using NextJS version 12.1. I'm running my application locally with next dev -p 3030.
I'm trying to debug one node_module library behavior by adding some console.log inside of the module, but this don't change the results in my application. What should I do?
place debugger in the file and then replace dev script
"dev": "NODE_OPTIONS='--inspect' next dev"
then you need to start debug mode in vscode
proof of work:

error deploying react project with font-awesome import

I'm trying to npm run deploy on my project where I'm storing the minified font-awesome css file and I'm getting the following error:
Creating an optimized production build...
Failed to compile.
./src/assets/css/font-awesome.all.min.css
ParserError: Syntax Error at line: 1, column 30
The app works fine on development sever.
The error shows whether I'm importing the css to the main css file or the main js file.
I only found some related old posts with potential solutions for a next.js project and yarn like in this link: https://github.com/vercel/next-plugins/issues/310
This is a react project and I'm using npm.
Any suggestions?
Can't comment on this unless there's more information regarding module-bundler and what is the configuration for the same. As it's treated differently according to module-bundler.
I would suggest you to use official package of fontawesome for react #fortawesome/react-fontawesome
PS. Module Bundler configuration should not be changed without proper knowledge as it can make whole application crash.

Nette - importing naja library

I have a question. I need to make some modification to our nette application (first time working with the framework). I need to import NAJA lib via FTP and by downloading code from github. I do not have access to server or console, so download via composer, npm... is not possible.
I done this:
Downloaded all files from https://github.com/jiripudil/Naja/releases (not the ZIPs) and put them in directory vendor
loaded in app/presenters/templates/#layout.latte with:
<script src="{$basePath}/js/vendor/Naja.js" type="module"></script>
Tried to inicialize it in one of my javascript with:
document.addEventListener('DOMContentLoaded', naja.initialize() );
But then error pop up, saying that naja is not defined. What am I missing?
Naja is written using modern JavaScript, it can be initialized only via ES5+ import, for instance
import naja from 'naja';
and then the event listener for initializing naja can be added after that code, and it can be compiled via webpack like this https://github.com/MinecordNetwork/Website/blob/master/webpack.config.js
You can do it all on your local machine with npm and yarn installed, and then upload bundle.js that was built to the server, it's also used in the mentioned repository so you can check out how and what libraries are needed, to compile the code from /public/js/main.js type yarn encore production or yarn build for development.

Error when running Corda flow tests from IntelliJ

When I run Corda flow tests from IntelliJ, the tests fail with the following errors:
QUASAR WARNING: Quasar Java Agent isn't running. If you're using
another instrumentation method you can ignore this message; otherwise,
please refer to the Getting Started section in the Quasar
documentation.
and
java.lang.IllegalStateException: Missing the '-javaagent' JVM
argument. Make sure you run the tests with the Quasar java agent
attached to your JVM. See https://docs.corda.net/troubleshooting.html
- 'Fiber classes not instrumented' for more details.
How can I fix this?
Corda flows need to be instrumented using Quasar before they are run, so that they can be suspended mid-execution.
To achieve this in IntelliJ, you need to:
Create a run config for your tests
Open the run config and change the VM options to -ea -javaagent:PATH-TO-QUASAR-JAR
In the CorDapp example and templates, quasar.jar is located at lib/quasar.jar, so you'd use -ea -javaagent:../lib/quasar.jar
Alternatively, you can edit the default JUnit run config to use the Quasar javaagent by default, avoiding you having to do this every time you pick a new test to run.
This is a basic error that you get if you don't set Quasar, you need to select your test-> go to Intellij top bar-> Run -> Edit Configurations and then set up like this photo in VM options:
From template readme
We recommend editing your IntelliJ preferences so that you use the Gradle runner - this means that the quasar utils plugin will make sure that some flags (like -javaagent - see below) are set for you.
To switch to using the Gradle runner:
Navigate to Build, Execution, Deployment -> Build Tools -> Gradle ->
Runner (or search for runner) Windows: this is in "Settings" MacOS:
this is in "Preferences" Set "Delegate IDE build/run actions to
gradle" to true Set "Run test using:" to "Gradle Test Runner" If you
would prefer to use the built in IntelliJ JUnit test runner, you can
run gradlew installQuasar which will copy your quasar JAR file to the
lib directory. You will then need to specify -javaagent:lib/quasar.jar
and set the run directory to the project root directory for each test.
Btw, if you face same error in VSCode, you can add
"java.test.config": {
"vmArgs": ["-ea", "-javaagent:../lib/quasar.jar"]
},
to settings.json. The path ../lib/quasar.jar may be different in your project.

Resources