Why is importing an icon named ImportExport breaking other dependencies? - babeljs

I added a Material-UI icon to one of my react components like so:
import { ImportExport } from '#material-ui/icons';
Thereafter, on my production site (but not my localhost dev server), I started getting an error on pageload whereby my socket-io client library was unable to correctly import something in one of its internal files. It had this:
const encodePacket = require("./encodePacket");
Which was used like so:
encodePacket(packet, false, encodedPacket => {
This is where the error arises: TypeError: encodePacket is not a function. Inspecting it, I can see that encodePacket is indeed not a function. When printed in the console, it shows as {default: {…}, __esModule: true}.
On my localhost dev server, this isn't the case. It's a function as expected. Moreover, the import right next to it, for decodePacket, is still a function in both contexts, locally and in production.
More bizarrely, when I examine the encodePacket module in the console, it looks like this:
Mui is Material-UI, a UI lib I use in other parts of the application and from which the icon is sourced - obviously it has no connection to a network library's internal packet encoding logic.
By commenting out the ImportExport icon and its import, I found that the error goes away.
What on earth though? How could this happen?
I even tried renaming the icon, but that didn't work either~
import { ImportExport as ReverseSortIcon } from '#material-ui/icons';
Any suggestions? I'm using Parcel and this is my tsconfig that has worked for 2+ years uneventfully~
{
"compilerOptions": {
"outDir": "./dist/",
"sourceMap": true,
"strict": true,
"noImplicitReturns": true,
"noImplicitAny": true,
"module": "es6",
"moduleResolution": "node",
"target": "es5",
"allowJs": true,
"jsx": "react",
"esModuleInterop": true
},
"include": [
"./src/**/*"
]
}

Related

VSCode Error with Schema for Azure DevOps Yaml extension

I am trying to work with my usersettings.json file and make sure that on a particular file type it uses the Azure DevOps Schema, for syntax checking. Yet I keep getting this error when loading in a .yml file:
Problems loading reference 'schemaservice://combinedschema/azure-devops': Unable to load schema from 'schemaservice://combinedschema/azure-devops': No content (note for my setup .yaml is reserved for kubernetes yaml)
I was wondering if anyone else had come across this problem before, I have been following this repo for setting up my user settings: https://github.com/Microsoft/azure-pipelines-vscode and this document: https://marketplace.visualstudio.com/items?itemName=ms-azure-devops.azure-pipelines
Here is my usersettings.json file
{
"redhat.telemetry.enabled": true,
"vs-kubernetes": {
"vscode-kubernetes.helm-path.windows": "C:\\Users\\Jason\\.vs-kubernetes\\tools\\helm\\windows-amd64\\helm.exe",
"vscode-kubernetes.minikube-path.windows": "C:\\Users\\Jason\\.vs-kubernetes\\tools\\minikube\\windows-amd64\\minikube.exe"
},
"files.associations": {
"**/ci/*.yml": "azure-pipelines"
},
"[azure-pipelines]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
}
I figured out what was wrong in the end for some reason in my settings VSCode can not resolve: "http://www.schemastore.org/json/composer"
Now this was not originally appearing in my usersettings.json but was being used what VSCode Was referring to was a hidden file in my project area called .vscode once I deleted that it then brought up the right file with the json schema.
I have since changed my settings to use the camel schema.
Here are my settings also with these settings you can now diffrentiate between an azure devops yaml file and kuberneted yaml file. As long as you have on the end of your kubernetes file _kube.yaml This will then let vscode know im working on a kubernetes file use the relevant schema.
{
"redhat.telemetry.enabled": true,
"yaml.schemas": {
"https://raw.githubusercontent.com/microsoft/azure-pipelines-vscode/master/service-schema.json": "*.yml",
// "http://www.schemastore.org/json/composer": ["/*"],
"https://raw.githubusercontent.com/apache/camel/main/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/camel-yaml-dsl.json" : "/_kube*.yaml",
"kubernetes": ["/*.yaml"]
},
"vs-kubernetes": {
"vscode-kubernetes.helm-path.windows": "C:\\Users\\Jason\\.vs-kubernetes\\tools\\helm\\windows-amd64\\helm.exe",
"vscode-kubernetes.minikube-path.windows": "C:\\Users\\Jason\\.vs-kubernetes\\tools\\minikube\\windows-amd64\\minikube.exe"
},
"files.associations": {
"**/ci/*.yml": "azure-pipelines"
},
"[azure-pipelines]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"yaml.schemaStore.url": "http://www.schemastore.org/api/json/catalog.json",
}

VSCode: settings.json file is not recognizing a terminal.integrated setting

Why is this entry not recognized by VSCode? I have a very slow terminal output that I am hoping this will help fix:
"terminal.integrated.rendererType": "experimentalWebgl"
The above command is known to exist, here: https://github.com/Microsoft/vscode-docs/blob/master/docs/editor/integrated-terminal.md
Here is my settings.json file:
{
"atomKeymap.promptV3Features": true,
"editor.formatOnPaste": true,
"editor.multiCursorModifier": "ctrlCmd",
"python.pythonPath": "C:\\Users\\Andrew\\Anaconda3",
"workbench.colorTheme": "Visual Studio Dark",
"terminal.integrated.rendererType": "experimentalWebgl", # grey'd out assuming its not a real command
"workbench.iconTheme": "Monokai Pro Icons",
"workbench.editorAssociations": {
"*.ipynb": "jupyter-notebook"
},
"python.defaultInterpreterPath": "C:\\Users\\Andrew\\Anaconda3",
"terminal.integrated.defaultProfile.windows": "Command Prompt",
"notebook.cellToolbarLocation": {
"default": "right",
"jupyter-notebook": "left"
},
"debug.javascript.pickAndAttachOptions": {
},
"workbench.colorCustomizations": {
}
}
The referenced markdown documentation file is not up to date (note that it's on branch master, while current development happens on the main branch). The WebGL renderer has been made the default in v1.55 (March 2021):
As part of this work we also added some fallback logic. When "terminal.integrated.rendererType": "auto", the following happens:
The WebGL renderer will try to start up.
If it fails, for example due to lack of OS/browser support:
The canvas renderer will be enabled and the time it takes to render a frame will start to be measured.
If the first 20 frames are rendering slowly, for example if there are hardware issues or GPU rendering is disabled:
The DOM renderer will be enabled.
In the next release, we plan on removing the rendererType setting all together in favor of a much more understandable "terminal.integrated.gpuAcceleration": "auto" | "on" | "off".
See the current documentation on this for further reference.

NestJS, PortsgreSQL and TypeORM - Migrations not running properly

When trying to run the TypeORM Migrations, either automatically in the application startup or manually via the TypeORM CLI, only the migrations table gets created (and it stays empty). The migration files themselves are not being executed.
Here is my tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "es2017",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true
}
}
Here is my package.json
...
"typeorm": "node --require ts-node/register ./node_modules/typeorm/cli.js",
...
Here is my ormconfig.json
...
"entities": ["dist/**/*.entity{.ts,.js}"],
"synchronize": true,
"migrationsRun": true,
"migrations ": ["dist/migrations/*{.ts,.js}"],
"cli": {
"migrationsDir": "src/migrations"
}
...
The migration files are being created through the TypeORM CLI and they are to populate some tables (insert statements). They are not related to changes in the database schema.
Please, can anyone help me make it work?
That was a silly one!
I guess some times the simplest problems are the hardest to spot.
The problem was in the ormconfig.json file.
I removed this empty space ("migrations ":) and everything worked just fine.
you should have synchronized to false synchronize:false
And from the terminal run
npx typeorm migration:generate -n AnyNameYouWant
After that, you can run
npx typeorm migration:run
You may also have to run nest build before running these commands.
I think this one is to synchronize the database with the schema, and it's not a good idea.
"synchronize": true,

Protractor-CucumberJS - Tagged scenarios - Browser Launched for Scenarios not Tagged

We have a Protractor-CucumberJS framework using BDD feature files and need to create a suite of sanity tests by tagging the relevant scenarios as '#sanity' in feature files and run only the scenarios with this tag.
With this setup, Protractor launches the browser for each feature file one by one, checks if it contains the '#sanity' tag and closes the browser if tag not found and so on.
This will take up a lot of time as there are close to 200 feature files and hence we want the the browser to launch only if the feature file contains the required tag and not otherwise.
Is there a way to achieve that.
Config file -
exports.config = {
seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
specs: [../features/*.feature]
cucumberOpts: {
require: [
'../step-definitions/**/*_Steps.js',
'generateJsonReport.js'
],
format: 'pretty',
tags: ['#sanity'],
},
multiCapabilities: [{
browserName: 'chrome',
shardTestFiles: true,
}
],
onPrepare: function () {
browser.driver.manage().window().setSize(1600, 800);
}
};
This is not possible due to the fact that you are using the option shardTestFiles:true, see the config.
If you disable it, or remove it, it will first search all the files (without parsing all files and opening a browser for it) for your specific tag and only run the featurefiles that have that tag.
Use tags:'#sanity', in Conf file, This will call only Sanity features

Unexpected token at # error in Aurelia module

When I run an Aurelia app, I get the following error in Chrome. I get the error wherever I have #. For example, #customElement and #bindable gives the error.
My config.js looks like below:
System.config({
"baseURL": "/",
"transpiler": "babel",
"babelOptions": {
"optional": [
"runtime"
]
},
"paths": {
"*": "*.js",
"github:*": "jspm_packages/github/*.js",
"npm:*": "jspm_packages/npm/*.js"
}
});
#customElement and #bindable are called decorators which is an experimental feature in JavaScript ES7, so it is currently not supported by the browsers.
However babel can also transpile this feature back to ES5 which is then can be executed by the common browsers
You just need to configure this feature in babel with using the es7.decorators option:
"babelOptions": {
"optional": [
"es7.decorators",
"runtime"
]
},
You can always check the Aurelia navigation skeleton as a reference for the config.js or other setup options.