New ag-grid CSS import path throws error during build process in my react app - ag-grid

I'm doing some changes to my React project (React version: 16.13.1, created with CRA) in order to upgrade from v27 to v28 of Ag-Grid. One of the changes requested is the new way to import the css files. It used to be
import 'ag-grid-community/dist/styles/ag-grid.css'
and now it has to be like this:
import 'ag-grid-community/styles/ag-grid.css'
This is generates an error during the build process:
Failed to compile.
./node_modules/ag-grid-community/styles/ag-grid.css
ParserError: Syntax Error at line: 1, column 83
error Command failed with exit code 1.
This makes me think it is a webpack problem, maybe a loader?. If it is the case, is there a way to handle this error without ejecting the webpack config?
Other clues I explored:
is it because I try to import CSS from a module?
is it a problem with the react version (16.13.1)?
Any ideas and solutions will be much appreciated.

You can find more details on this issue on the following Github Issue which is related to a known issue with CRA 3.x
The main thing to note is that we will be applying a fix in v28.2 which is due out next week.
AG-7222 Add Post Processing of CSS for CRA 3.x/4.x Compatibility which should help address this issue will be released as part of our next release 28.2 and should resolve these issues without the need for a workaround.

CSS file ag-grid.css has two syntax errors. Calc() function is missing in two places.
line-height: min(var(--ag-line-height, calc(var(--ag-row-height) - 2px)), var(--ag-row-height) - 2px);
This should be:
line-height: min(var(--ag-line-height, calc(var(--ag-row-height) - 2px)), calc(var(--ag-row-height) - 2px));
And..
height: min(var(--ag-line-height, calc(var(--ag-row-height) - 2px)), var(--ag-row-height) - 2px);
should be:
height: min(var(--ag-line-height, calc(var(--ag-row-height) - 2px)), calc(var(--ag-row-height) - 2px));
Correcting these issues resolved above build error in my case.

Related

A constructor from a node module I'm importing works when using Create React App, but errors in ParcelJS. What is going on?

I'm converting a project that was built using Create React App to use ParcelJS as a bundler instead. Strangely, a dependency that I imported during development (#twilio/voice-sdk) works fine in the CRA version of the application, but I get the following error when I try to invoke the constructor in the Parcel version:
TypeError: (this._options.AudioHelper || audiohelper_1.default) is not a constructor
The package is identical between both (#v2.1.1, the latest). I'm importing using ESM syntax, so:
import { Device } from '#twilio/voice-sdk'
I trying using CommonJS syntax (require) and it still didn't work. I've dug into the compiled code, and that seems to be the issue. I imagine there are a lot of differences, but one that I've noticed is here:
On the left is the code compiled by Create React App, which does seem to be exporting something more substantial than on the left - is the export just an empty object? If so, it's no wonder I'm getting a constructor error.
Unfortunately, no amount of googling and SO sleuthing has clarified what I could do to make ParcelJS transpile this dependency properly, if that's the issue. I've tried to make the babel config for ParcelJS match CRA more closely by adding the following to a babel.config.json
{
"plugins": [
"#babel/plugin-transform-modules-commonjs"
]
}
But no luck. Any ideas from where to go from here, or is it time to switch to Webpack?
It looks like Twilio package has a problem when using Parcel 2: https://github.com/twilio/twilio-voice.js/issues/101

I have an error when executing ionic serve

When I execute ionic serve, it shows the following errors:
Refused to load the image 'http://localhost:8100/favicon.ico' because
it violates the following Content Security Policy directive:
"default-src 'none'". Note that 'img-src' was not explicitly set, so
'default-src' is used as a fallback.
Failed to load resource: the server responded with a
status of 404 (Not Found)
How can I solve this?
I had the same error message.
Looking through the logs printed when doing
ionic serve
showed me a bunch of errors, all similar to this
[ng] ERROR in ./src/global.scss (./node_modules/#angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!./node_modules/postcss-loader/src??embedded!./node_modules/sass-loader/lib/loader.js??ref--14-3!./src/global.scss)
[ng] Module build failed (from ./node_modules/sass-loader/lib/loader.js):
[ng] Error: Cannot find module 'node-sass'
[ng] Require stack:
This lead me to get the application up and running again by
npm install node-sass --save
The compilation process is sometimes spitting out rather confusing error messages from time to time, but with a little digging one can start guessing where to start poking
I had the same issue. I was able to solve it. I fixed the routing file, I had a route that couldn't load because another route was higher order.
Ionic include default favicon icon into index.html file.
<link rel="icon" type="image/png" href="assets/icon/favicon.png" />
You can put your favicon icon into "assets/icon" and replace href above.
I had this error and it was because I had included an import I wasn't actually using. In my example, I had accidently imported Console when using console.log.
I was getting error TS2307: Cannot find module 'console'. in the VS Code terminal, but my error in Chrome was "Refused to load the image 'http://localhost:8100/favicon.ico' because it violates the following Content Security Policy directive: "default-src 'none'". Note that 'img-src' was not explicitly set, so 'default-src' is used as a fallback.
Failed to load resource: the server responded with a status of 404 (Not Found)"
So be aware that this error is not necessarily to do with the favicon.
I had same issue but solved using below solution.
<link rel="icon" type="image/x-icon" href="assets/icon/favicon.ico" />
I used .ico file instead of .png file and thats works for me. try once.
I get same error multiple times,this error throw when u missed any small issue like wrong image path or forget to write import statement of any module/service/component.these error will shown in terminal when u running your project.After fixing these run your project
I had the exact same problem.
I advise you to take a look at your Terminal in VSCode (or the standard terminal if you launched it by there) and look for an ERROR message.
Most likely the problem isn't the favicon.ico blabla stuff but another element of your app, something in a .ts doc for example. Via Terminal you can seek for it in a better way than Chrome, that shows you this unrelated message.
I too faced same error .In my case i have done mistake in importing file
import { IUser } from 'src/app/shared/interfaces/IUser
Changed path like below is fixed error.
import { IUser } from './shared/interfaces/IUser
Cross check your import file. it might helps
I got the same error when I downloaded a new branch of the project, I just run npm install of the lastest components
I solved by created copy favicon.png from assets/icon/favicon.png to root project folder and rename it to favicon.ico , and also put it on assets/icon/favicon.ico
and also check this answer .
https://stackoverflow.com/a/63749758/8370334
Same issue here with ionic v5 and angular v10.
You may have this error when you create some error in the variables.scss file.
I was using adding a list of global variable that will be used across the app but I forgot to add a ,.
It didn't create an error while compiling...
The code was :
$color-settings: (
'primary': (
'base': #297bfd,
) // <-- Comma is missing here
'secondary': (
'base': #297bfd,
)
}
It will display the same error, I think, it breaks somehow the way ionic compile the scss.
I had the same issue after an upgrade. I solved the problem doing:
npm rebuild node-sass
Try to change the browser, I fixed this clicking on the url resource which opened firefox and then I've been able to test the app normally on Firefox

Migrating to Dart 2 I get a "check imports error" that means that some templates have not been generated

I'm trying to migrate to Dart 2, I have a lot of packages and up to now I could do my job with not so much problems.
Now I'm getting a strange error bot with DDC and dart2js:
[SEVERE] build_web_compilers|entrypoint on web/main.dart (cached):
Unable to find modules for some sources, this is usually the result of either a
bad import, a missing dependency in a package (or possibly a dev_dependency
needs to move to a real dependency), or a build failure (if importing a
generated file).
Please check the following imports:
`import 'package:ledger_web/src/ui/components/main_selection_bar.template.dart';` from ledger_web|lib/src/ui/components/service/main_selection_bar_service.dart at 7:1
`import 'package:ledger_web/src/ui/components/main_selection_bar.template.dart';` from ledger_web|lib/src/ui/components/service/main_selection_bar_service.template.dart at 11:1
... and more
It is correct to signal that there is not the import (MainSelectionBar is an angular component), because the template has not been generated.
Now the problem is, why the template is not there?
I checked the .dart_tool/build/generated directory but the template has not been created.
I have a similar package with a similar component that works fine, so I cannot figure out what's happened.
Is there a place where there is a more detailed error list?
Interestingly enough, there is also a case in which the template exists, but it is listed like if it was not found....
Any hint?
Most likely this is related to a build failure when generating the template, which is not being properly reported on subsequent builds. This pull request should help that https://github.com/dart-lang/build/pull/1834/, but you can also try running pub run build_runner clean and then doing a new build to get the original error back.

Angular Dart Tutorial - Unable to find modules for some sources

I'm trying to follow the Angular Dart tutorial (https://webdev.dartlang.org/angular/tutorial/toh-pt1) but got stuck after adding some html that makes use of the ngModel directive.
According to the tutorial in order to make use of the ngModel directive one has to add "angular_forms: ^2.0.0" to the pubspec.yaml, import 'package:angular_forms/angular_forms.dart' and add "formDirectives" to the component directives. I did all of that including running "pub get" to get the dependencies but when I run "webdev serve" I get the following error:
[SEVERE] build_web_compilers|entrypoint on test/app_test.dart (cached):
Unable to find modules for some sources, this is usually the result of either a
bad import, a missing dependency in a package (or possibly a dev_dependency
needs to move to a real dependency), or a build failure (if importing a
generated file).
What am I missing?
I had the same the problem. I don't think it mentions explicityly in the tute but after adding angular_forms dependency to the pubspec.yaml file, you need to pull in this new dependency with:
pub get
Hope it helps!

eslint / babel-eslint issue with escope

Currently getting this error when i try to run eslint locally:
Error: Cannot find module 'escope'
at Function.Module._resolveFilename (module.js:455:15)
at monkeypatch (/Users/pablorincon/Documents/SSENSE/micro-services/ws-website/services/ui-website/node_modules/babel-eslint/index.js:53:26)
at Object.exports.parse (/Users/pablorincon/Documents/SSENSE/micro-services/ws-website/services/ui-website/node_modules/babel-eslint/index.js:358:5)
at parse (/Users/pablorincon/Documents/SSENSE/micro-services/ws-website/services/ui-website/node_modules/eslint/lib/linter.js:671:23)
at Linter.verify (/Users/pablorincon/Documents/SSENSE/micro-services/ws-website/services/ui-website/node_modules/eslint/lib/linter.js:806:27)
at processText (/Users/pablorincon/Documents/SSENSE/micro-services/ws-website/services/ui-website/node_modules/eslint/lib/cli-engine.js:278:31)
at processFile (/Users/pablorincon/Documents/SSENSE/micro-services/ws-website/services/ui-website/node_modules/eslint/lib/cli-engine.js:320:18)
at executeOnFile (/Users/pablorincon/Documents/SSENSE/micro-services/ws-website/services/ui-website/node_modules/eslint/lib/cli-engine.js:655:25)
at fileList.forEach.fileInfo (/Users/pablorincon/Documents/SSENSE/micro-services/ws-website/services/ui-website/node_modules/eslint/lib/cli-engine.js:693:13)
at Array.forEach (native)
What's weird is that im using the same linting configuration with another project, and i had no issues at all.
I'm using:
babel-eslint#7.1.1
eslint#4.0.0-beta.0
Any ideas ?
Even though I had same package.json, babel-eslint was set as "7.1.1" in one and "^7.1.1" in the other.
Basically ESLint v4 uses a new fork of escope, which was then updated on version 7.2.3 of babel-eslint.
So, adding the little ^ to my configuration fixed my problem.