As I'm trying to publish my app, there is an "app.build.js" file generated which looks like this:
{
"name": "durandal/amd/almond-custom",
"inlineText": true,
"stubModules": [
"durandal/amd/text"
],
"paths": {
"text": "durandal/amd/text"
},
"include": [
"config",
"main-built",
"main",
and so forth. I get bunch of syntax errors in this file when trying to build the project. How can I define optimizer to generate file with no syntax errors?
Final error I get is when whole project is published, main-built.js generates "ko is not defined" error.
Thanks!
Okay, that was completely my bad, this file is working as intended even tho Resharper shows tons of errors.
I thought it was the reason my main-built.js was showing "ko is not defined" when whole project was published.
For everyone else, when building a release version, make sure your BundleConfig.cs contains non-debug versions of libraries you use. My Bundle contained only knockout-{version}.debug.js. The solution was to just add non-debug version and it all works as intended now!
Related
I have attached chrome inspector to a NodeJS process and see that Chrome can detect the running built source code ( /dist folder ) and also correctly mapped the source code ( /src folder ) to the built source code
However, Whenever I put a debug point in the original source code (/src) , the debugging point is set to the correct line in the built (/dist) version instead and I can only debug the with the built version but not the original source code
The situation can be seen in the picture
Did I do something wrong?
This is a follow up to the previous question which involve VS Code Debugger, in the case of VS Code, they can not even detect the original source or sourcemap!
This seem to be buggy async sourcemap from babel. We had to upgrade #babel/core from version 7.9.0 to 7.13 and add these 2 parts also into .babelrc
"presets": [
[
"#babel/preset-env",
{
"targets": {
"node": true
}
}
]
],
"retainLines": true,
Is there a way to change all eslint errors to warnings using eslintrc.js file?
I just hate it at the moment, especially when it stops the entire program because I added an extra space.
I was wondering is there a way to turn all errors off and let prettier handle the rearranging of the code?
P.S. I am using vscode as the IDE and
I know about the comment thingy at the beginning of the code. It does not work on a vue or nuxt project
If you're using the ESLint extension, you can customize the severity of ESLint rules using the setting eslint.rules.customizations.
For example, if you add the following snippet to your .vscode/settings.json, all ESLint errors will be shown as warnings in VSCode.
"eslint.rules.customizations": [
{ "rule": "*", "severity": "warn" }
]
I'm trying to set up a node project so I can use the common import/export syntax, and for compatibility, use babeljs to convert the import and export statements to requires.
When I try transpiling using babel though, I'm not seeing any changes and I don't know why.
Here's my babel.config.js
// babel.config.js
module.exports = {
// I thought this was what I would need to add for making the changes, based on the docs
plugins: ["#babel/plugin-transform-modules-commonjs"],
// env takes care of the majority of changes I might need to convert code to make
// easy to run on a wider range of machines
presets: [
[
"#babel/preset-env",
{
targets: {
// target an older version where I know there is no ESM support
node: "10"
}
}
]
],
// this was in the docs too - I'm not sure if I need it TBH
sourceType: "module"
}
I have a bunch of code using import/export, and async/await in a directory, that I wanted to transpile and put into another directory, lib.
Here's the command I am using:
npx babel src --out-dir lib
My package.json file online too, and there's nothing too esoteric there. I've tried to follow the documentation faithfully.
I would expect to see changes in the code to replace the import/export calls with requires in the lib, but no joy.
What am I doing wrong here? I worked on a related project 6-7 months ago, where I am using babel like this and it does make the changes for me.
You can see the branch with the problem code on github, with the package.json, and here's the source code for other project mentioned where it is working.
Please be gentle, fellow SO commenters - I'm trying my best, I really am.
It looks like you're using "babel-cli": "^6.26.0" instead of "#babel/cli": "^7.11.6" that should fix it.
I have nodejs module which I unit test with jasmine-ts [0.3.0] by running jasmine-ts --config=spec/support/jasmine.json.
My intention is that I want to run some unit test and stop at breakpoint which is inside the function that I am testing. Unfortunately debugger stops only inside unit tests, but not in production code.
What could be the issue?
More information about my tries.
Typescript recompilation on changes is on in my Intellij IDEA 2020.1. I can recognise that it works correctly as when I change some typescript file in production code, I can see the changes in corresponding Javascript file in dist folder.
If I run my module then I can stop at breakpoints as well.
The weird thing is that I can stop at the breakpoint in production code while executing unit tests in another module where mocha is used and is run like this: npx mocha -r ts-node/register test/**/*.test.ts.
Thoughts what could be wrong.
Dependencies might not work correctly together. I was recently updating the libraries to the latest version, but noticed, that jasmine-ts requires ts-node less than 8, so currently I have the following versions in my package.json:
"devDependencies": {
"jasmine": "3.3.1",
"jasmine-ts": "^0.3.0",
"ts-node": "7.0.1",
"nyc": "^13.0.1",
"typescript": "^3.8.3",
"#types/jasmine": "^3.3.8",
"jasmine-spec-reporter": "^4.2.0",
"jasmine-reporters": "^2.3.2"
}
Source mapping might be broken. I have checked some *.js.map files and it seems like they are pointing to correct *.ts files, so, don't know what to check more there.
I was thinking if typescript configuration might influence as well, but unclear for me exactly how. Anyway, this is my tsconfig.json:
{
"compilerOptions": {
"strict": false,
"target": "es2015",
"sourceMap": true,
"module": "commonjs",
"outDir": "./dist",
"moduleResolution": "node"
},
"include": [
"src/**/*.ts"
],
"exclude": [
"./spec/**/*.ts",
"./node_modules/**/*.ts"
]
}
Something is definitely wrong. When I want to see the coverage that I run with nyc npm test, I see Javascript files, however, it should be Typescript. But I assume that it might be a different issue, but maybe not...
Any hints to resolve the issue?:)
Update:
One way to fix this issue is to clean up the code from Intellij IDEA and other files that might influence to the stable work by removing the project completely from the computer and clone it again. By this action it helped me to stop at breakpoints in other modules that use jasmine, however my module still have weird state as I come to the production code at some point, but not in order. I assume seeing some errors regarding promises, but I don't.
The issue was that I had the Recompile on changes checkbox on in the Language & Frameworks -> Typescript.
This brings the functionality that for each .ts file there will be generated .js file, but in my case all js compiled files must be in dist directory that I specify in tsconfig file. My assumption is that during debug session debugger didn't know which file to take or was taking the wrong one. Setting Recompile to changes to off solved the problem.
Even though I still have weird behaviour as debugger comes to the production code earlier than expected, I think it is different story and relates not to Intellij IDEA preferences, but to async code with running tasks periodically.
I'm using visual studio code v1.19.1 to write unit test with mocha.
I found that when I hover the mouse over the after keyword, vs code says [standard] 'after' is not defined. (no-undef). This means that it doesn't recognize after keyword.
It seems that this problem has something to do with JavaScript Standard Style plugin.
I've read this StackOverflow question. But adding
"standard": {
"env": [ "mocha" ]
}
or
"standard": {
"globals": [
"describe",
"context",
"before",
"beforeEach",
"after",
"afterEach",
"it",
"expect"
]
}
to package.json doesn't work in my case.
What might be wrong with my visual studio code or javascript standard style plugin?
I just found that this error happens because my package.json file is not located in the root folder of visual studio code.
After moving it to the root folder of visual studio code, vscode recognizes before, after keywords in mocha.
I was experiencing the same problem, but unfortunately could not move package.json out of its current directory as I am working within a monorepo. The workaround that worked for me was to directly import the mocha library inside my test files by defining its path as follows:
const mocha = require('../../../node_modules/mocha/lib/mocha.js');
and then use declare its keywords as follows:
mocha.before(() => {})