How to properly build a CRA project to support IE11? - cross-browser

I'm working on a project that needs to support IE11.
We are using create-react-app.
"browserslist": {
"production": [
">0.2%",
"ie 11",
"not dead",
"not op_mini all"
]
}
Given the fact that IE11 is such an old browser, does it even make sense to add anything else to the browserslist config?
Couldn't I just do this?
"browserslist": {
"production": [
"ie 11"
]
}
Also, if I'm building targeting ie 11 do I also need to add react-app-polyfill ?
import 'react-app-polyfill/ie11';

Just found out that this:
"browserslist": {
"production": [
"ie 11"
]
}
Will remove many useful prefixes like -webkit-.
So, you should use:
"browserslist": {
"production": [
">0.2%",
"ie 11",
"not dead"
]
}
About the polyfills, you definitely need to add them as well.
From the image above, you can see that babel will transpile the arrow function () => {} to a syntax compatible with IE 11, but you can also see that Object.assign, Promise and URL will all need polyfills to work on older browsers that don't natively support them.
Here react-app-polyfill/ie11 you can see all the polyfills that are added for IE11.

Related

Can't get custom configuration points working for my VS Code extension

So I've been spending a lot of time trying to get a couple specific settings working for my language extension in VS Code, and while the documentation and the few articles online seem to make it sound as simple as adding a "configuration" point in my package.json and a "getConfiguration()" call in the extension.ts file, it seems that there is more needed to get them working. This is my first extension I've made so I'm a bit unfamiliar with some of these things.
I am working on this project for work, so I will paste some of my code below with certain edits. The main issue I am getting right now is that it recognizes that I have added the configuration points to the package json, but I get this error when trying to debug the extension:
Cannot register '<configuration_name>'. This property is already registered
I have read as much as I can online about this and it seems that maybe the issue is that VS Code is seeing these settings as already defined and therefore is confused because it may be expecting custom configurations. I'm not sure. I feel though the issue must lie in my extension.ts file since when I look at the configuration example on the VS Code Examples repository on Github, they are doing quite a lot more than just the simple "getConfiguration()" function I am using. But I really have no idea what I would do. I am not very familiar with typescript as of yet, so any help would be greatly appreciated on this. Anyone have any insight as to why it would be doing this?
Here is my package.json:
{
"name": "ex-lang",
"displayName": "Example",
"description": "Example language support",
"version": "0.0.1",
"engines": {
"vscode": "^1.64.2"
},
"categories": [
"Programming Languages",
"Snippets"
],
"contributes": {
"languages": [
{
"id": "ex",
"aliases": [
"EX",
"ex",
"Example"
],
"extensions": [
".ex"
],
"configuration": "./language-configuration.json",
"icon": {
"light": "./icons/icon.png",
"dark": "./icons/icon.png"
}
}
],
"grammars": [
{
"language": "ex",
"scopeName": "source.ex",
"path": "./syntaxes/ex.tmLanguage.json"
}
],
"snippets": [
{
"language": "ex",
"path": "./snippets.json"
}
],
"configuration": [
{
"id": "ex-config",
"title": "Example Custom Settings",
"properties": {
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": [
"comment.block.documentation.ex"
],
"settings": {
"foreground": "#efc752"
}
}
]
},
"editor.bracketPairColorization.enabled": true,
"workbench.colorCustomizations": {
"editorBracketHighlight.foreground1": "#2b85d5",
"editorBracketHighlight.foreground2": "#559ddd",
"editorBracketHighlight.foreground3": "#80b6e6",
"editorBracketHighlight.foreground4": "#aaceee",
"editorBracketHighlight.foreground5": "#d5e7f7",
"editorBracketHighlight.foreground6": "#c6cad4",
"editorBracketHighlight.unexpectedBracket.foreground": "#db6165"
}
}
}
]
},
"dependencies": {
"vsce": "^2.9.2"
},
"devDependencies": {
"#types/node": "^16.11.7",
"#types/vscode": "^1.40.0",
"#typescript-eslint/eslint-plugin": "^5.19.0",
"#typescript-eslint/parser": "^5.19.0",
"eslint": "^8.13.0",
"typescript": "^4.7.2"
}
}
I have tried messing a bit with Activation Events, but I was getting more issues with it as I suppose I don't understand them as well as I might like. I have also fiddled with different scopes for the configuration points and such but to no avail. And lastly, I did have a "main" contribution point, but I was having very strange pathing issues when I had it (it kept saying the file was not found), so I removed it. Not sure if any of these things are also contributing to my problem or not.
Here is my extension.ts file for reference:
import * as vscode from 'vscode';
export function activate(context: vscode.ExtensionContext) {
vscode.workspace.getConfiguration('ex-config');
}

vscode extension [tht13.python]: 'configuration.jsonValidation.url'

I got this error notification while using VSCode:
[tht13.python]: 'configuration.jsonValidation.url' must be
an absolute URL or start with './' to reference
schemas located in the extension.
I have found and changed jsonValidation to:
"jsonValidation": [
{
"fileMatch": ".condarc",
"url": "./schemas/condarc.json"
},
{
"fileMatch": "environment.yml",
"url": "./schemas/conda-environment.json"
},
{
"fileMatch": "meta.yaml",
"url": "./schemas/conda-meta.json"
}
]
in package.json, but it still doesn't work.
How to figure out this issue?
You are using the extension "Python for VSCode" (tht13.python). It looks like this extension is not maintained anymore (last commit on Jun 13, 2018)
Maybe you should switch to another extension. I'm quite happy with the "Python" (ms-python.python) extension from Microsoft https://marketplace.visualstudio.com/items?itemName=ms-python.python

Babel with babel-preset-env seems to ignore browserslist config

I’m testing Babel with browserslist in an npm script.
Here is my current package.json, in which Babel is doing what I expect:
{
"name": "npm-scripts-igloo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"devserver": "live-server",
"watch-sass": "node-sass sass/style.scss css/style.css --output-style expanded --watch",
"compile-sass": "node-sass sass/style.scss css/style.compiled.css --output-style expanded",
"prefix-css": "postcss css/style.compiled.css --use autoprefixer -o css/style.prefix.css",
"compress-css": "node-sass css/style.prefix.css css/style.min.css --output-style compressed",
"build-css": "npm-run-all compile-sass prefix-css compress-css",
"babel": "babel app.js --watch -o js/app.compiled.js",
"start": "npm-run-all -p devserver watch-sass babel"
},
"browserslist": [
"last 5 versions"
],
"babel": {
"presets": [
[
"env",
{
"targets": {
"browsers": [
"cover 99.5%"
]
}
}
]
]
},
"author": "",
"license": "ISC",
"devDependencies": {
"#fortawesome/fontawesome-free": "^5.6.1",
"autoprefixer": "^9.4.7",
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0",
"live-server": "^1.2.1",
"node-sass": "^4.11.0",
"npm-run-all": "^4.1.5",
"postcss-cli": "^6.1.1"
}
}
I’m not using a .babelrc file or any other configuration of Babel.
I’ve tried to target Edge 16 using the browserslist key:
"browserslist": [
"Edge 16"
]
With this configuration, Babel should NOT convert const to var, but it does, as explained here:
Babel doesn’t change const since Edge 16 supports it
https://github.com/browserslist/browserslist-example
However, if I target Edge 16 using the babel key:
"babel": {
"presets": [
[
"env",
{
"targets": {
"browsers": [
"Edge 16"
]
}
}
]
]
}
then Babel correctly doesn’t change const to var since Edge 16 supports it.
I would prefer to use the browserslist key, as it’s the recommended practice
https://github.com/browserslist/browserslist
Also, I could then simply share this browserslist option with autoprefixer, which is how it’s supposed to work.
But, the problem is that Babel seems to ignore the browserslist key.
The same is true if I use a .browserslistrc file containing:
Edge 16
There is an asterisked note on this slide:
https://slides.com/ai/browserslist#/14
that reports:
Only Babel 7 supports config file
So, I tried updating Babel to v7:
npm install #babel/core -D
This produced the following in devDependencies:
"#babel/core": "^7.3.4"
Unfortunately, that didn’t seem to make any difference.
So, my questions are:
Why does the browserslist key not appear to be affecting Babel? Is there something wrong with my syntax?
Does it matter where in package.json the browserslist key appears? i.e. does key order matter?
A little bit late for the party but I was reading through the docs and found out this:
"By default #babel/preset-env will use browserslist config sources unless either the targets or ignoreBrowserslistConfig options are set."
source: here
So in your case you need to get rid of targets property otherwise it will take precedence and neither .browserlistrc nor browserslist property in package.json will take effect.
Hope it helps!
try to clean cache in node_modules/.cache/babel-loader
Its worked for me with babel#7.6.0 with following config in .babelrc fie
'#babel/preset-env', {
'useBuiltIns': 'usage',
'corejs': 3,
'targets': {
'browsers': ['chrome 74']
}
}
Found more info here.
An or combiner can use the keyword or as well as ,. last 1 version or > 1% is equal to last 1 version, > 1%.
and query combinations are also supported to perform an intersection of the previous query: last 1 version and > 1%.

Angular6 ServiceWorker dont cache all files

I generated a clean Angular6 Project and use ng add #angular/pwa i get this ngsw-config.json:
{
"index": "/index.html",
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": [
"/favicon.ico",
"/index.html",
"/*.css",
"/*.js"
]
}
},
{
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
"files": [
"/assets/**"
]
}
}
]
}
There is the whole assets folder marked for "Service Worker Caching" But the Sad reality show that this isnt real:
The 3 Graphic files i use ( header-bg.jpg, list-border-red.svg & list-border-green.svg ) Are marked as "from ServiceWorker" But when i create a App on my Smartphone, and disconnect the Internet connection and open the App, is only header-bg.jpg available. but list-border-red.svg & list-border-green.svg are not available offline.
Also shows the graphic thas 2 favicons are loaded from "Disc Cache" and one from the ftp... The files are also in the assets folder, why they are not cached fro mServiceWorker? Is the ServiceWorker stuff maybe bugged in Chrome?
The App is allready Online and can be found here: https://expense-calculator.com/ Just open and make your own tests if you need this to reproduce my problem.
Your service worker code looks good and is registered perfectly to serve the files in offline just as you have expected it to work. I've checked in Chrome with Airplane mode on. All files including .svg files loaded from cache.
Please retry.

VS Code "Include file not found in include path."

First of all, I know this issue has been answered a bunch of times already, but the answer (the same one every time) doesn't work for me still..
I get the infamous "Include file not found in include path" when trying to include iostream in a simple hello world c++ program. I then include the path to my MinGW include folder as follows:
{
"name": "Win32",
"includePath": [
"${workspaceRoot}",
"C:/MinGW/lib/gcc/mingw32/4.9.3/include/c++"
],
"defines": [
"_DEBUG",
"UNICODE"
],
"browse": {
"path": [],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
Yet, I still get the same error. This is, for what I've found, the only solution to this problem. It's really frustrating that VS Code just doesn't seem to recognize the path.
Any advice is helpful and appreciated!
This seems like you're looking at it from the start of the project. I would go to the extension (C++ my guess) and see how to implement it. If this doesn't work for you I would check your path.
https://code.visualstudio.com/docs/languages/cpp
I met the same trouble with you.
Maybe you could try to set "brose"-"path" like this.
{
"name": "Win32",
"includePath": [
"${workspaceRoot}",
"C:/MinGW/lib/gcc/mingw32/4.9.3/include/c++"
],
"defines": [
"_DEBUG",
"UNICODE"
],
"browse": {
"path": [
"${workspaceRoot}",
"C:/MinGW/lib/gcc/mingw32/4.9.3/include/c++"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
Wish this could help you.