I installed shadow-cljs as follows:
npm install -g shadow-cljs
Then I created a shadow-cljs.edn file, with the following:
[{:id "app"
:source-paths ["src/cljs" "src/cljc" "dev"]
:figwheel {:on-jsload "myapp.system/reset"}
:compiler {:main cljs.user
:asset-path "js/compiled/out"
:output-to "dev-target/public/js/compiled/myapp.js"
:output-dir "dev-target/public/js/compiled/out"
:source-map-timestamp true
:preloads [devtools.preload]
:optimizations :none}}
{:id "test"
:source-paths ["src/cljs" "test/cljs" "src/cljc" "test/cljc"]
:compiler {:output-to "dev-target/public/js/compiled/testable.js"
:main myapp.test-runner
:optimizations :none}}
{:id "min"
:source-paths ["src/cljs" "src/cljc"]
:jar true
:compiler {:main myapp.system
:output-to "resources/public/js/compiled/myapp.js"
:output-dir "target"
:source-map-timestamp true
:optimizations :advanced
:closure-defines {goog.DEBUG false}
:pretty-print false}}
]
Then in the already running clj repl, I do M-x cider-connect-sibling-cljs, and select the shadow repl option. But I get that shadow-cljs Clojurescript REPL is not available. How do I get shadow cljs to work?
Related
I found tutorials like this: https://medium.com/heresy-dev/getting-started-with-postcss-a-quick-guide-for-sass-users-90c8b675d5f4
(I must really wonder how less i find on the internet about the use of a postcss.json config file.)
and this one: https://www.sitepoint.com/an-introduction-to-postcss/
But all those tutorials didnt worked for me. I use the latest version of postcss and postcss-cli. When i start this script:
"postcss": "postcss --config postcss.json"
then i just get a error:
Input Error: Did not receive any STDIN
When i google for this, i also dont find any solution that helps me.
My package.json:
{
"scripts": {
"postcss": "postcss --config postcss.json"
},
"devDependencies": {
"autoprefixer": "^7.1.6",
"bootstrap-sass": "^3.3.7",
"cssnano": "^3.10.0",
"node-sass": "^4.5.0",
"postcss": "^6.0.13",
"postcss-cli": "^4.1.1",
"postcss-colormin": "^2.2.2",
}
}
My postcss.json:
{
"use": [
"autoprefixer"
],
"input": "public_html/css/",
"output": "public_html/css/min/*.css",
"local-plugins": true,
"watch": false
}
I have an existing front js application without any unit tests. It's not actually particularly suitable for all sources to be unit tested (no dependency injection, not decoupled in units, DOM manipulation heavily mix with logic, etc.) but some files (ES2015 modules) can be right now testable.
I decided to go with Karma/Mocha/Chai and i already have a standalone karma test which works with the following configuration.
module.exports = function(config) {
config.set({
basePath: '',
frameworks: [
'mocha',
'chai',
],
singleRun: true,
files: [
'node_modules/babel-polyfill/dist/polyfill.js',
'src/**/*.js',
],
preprocessors: {
'src/**/*.js': ['babel'],
},
babelPreprocessor: {
options: {
presets: ['es2015'],
plugins: ['transform-es2015-modules-umd'],
sourceMap: 'inline',
},
},
browsers: [
'Chrome',
//'ChromeCanary',
//'PhantomJS',
//'Firefox',
//'Opera',
//'IE',
//'Safari',
],
reporters: [
'mocha',
],
});
};
my structure files is as follow :
node_modules
src/
module.js
module.test.js
karma.conf.js
package.json
the package.json have this dependencies :
"devDependencies": {
"babel-core": "^6.26.0",
"babel-plugin-transform-es2015-modules-umd": "^6.24.1",
"babel-polyfill": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"chai": "^4.1.2",
"karma": "^1.7.1",
"karma-babel-preprocessor": "^7.0.0",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-firefox-launcher": "^1.0.1",
"karma-growl-reporter": "^1.0.0",
"karma-ie-launcher": "^1.0.0",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.4",
"karma-opera-launcher": "^1.0.0",
"karma-phantomjs-launcher": "^1.0.4",
"karma-safari-launcher": "^1.0.0",
"mocha": "^4.0.0"
}
And just for easy usage :
"scripts": {
"test": "karma start"
},
Now i'm trying to integrate that configuration with the existing project, but it's failing because it runs all sources on the browser, so trying to bootstrap the app without the dependencies (external scripts). But even if I include all those in the 'file' config property of karma, there will be always problems with DOM manipulation on not existing HMTL, relying on global variables not here, etc.
So I'm wondering how to preprocess (logically and with what tools) to have only my *.test.js to be launched without my app bootstrapping. And so to load only the files needed for the tests.
I was thinking of making a bundle for each *.test.js file with the corresponding file tested (resolved with the import), and this way, as far as i don't make test files for all files not ready to be tested in my app, they should not be loaded.
Is this the best way to go, how can the tests can be done in an other way ?
I have gulp-babel task in my gulp build script and it was working well until I removed the node_modules directory and run npm install again.
It returned
SyntaxError: j.js: Unexpected token (790:10)
and the error log pointed the error token as follow :
789 | data,
> 790 | async = true,
| ^
791 | cache = 'no-cache',
792 | method = 'GET',
793 | headers = {},
If I compile j.js with cli babel j.js directly, will not get error message and returned compiled code as expected.
My gulp task code :
const gulp = require( 'gulp' );
const { babel } = require( 'gulp-load-plugins' )();
gulp.task( 'babel', () => {
return gulp.src( [
'.tmp/j.js'
] ).pipe( babel() ).pipe( gulp.dest( '.tmp' ) );
} );
My .babelrc :
{
"presets" : [ "es2016" ],
"plugins" : [
"transform-es2015-arrow-functions",
"transform-es2015-object-super",
"transform-es2015-parameters",
"transform-object-assign",
"transform-es2015-block-scoping",
"transform-es2015-shorthand-properties",
"transform-es2015-block-scoped-functions",
"transform-es2015-for-of",
"transform-es2015-destructuring",
[ "transform-es2015-classes", { "loose" : true } ],
[ "transform-es2015-spread", { "loose" : true } ],
[ "transform-es2015-template-literals", { "loose" : true } ]
]
}
My npm dependencies :
"devDependencies": {
"babel-cli": "^6.14.0",
"gulp-babel": "^6.1.2",
"babel-plugin-transform-es2015-arrow-functions": "^6.8.0",
"babel-plugin-transform-es2015-block-scoped-functions": "^6.8.0",
"babel-plugin-transform-es2015-block-scoping": "^6.10.1",
"babel-plugin-transform-es2015-classes": "^6.9.0",
"babel-plugin-transform-es2015-destructuring": "^6.9.0",
"babel-plugin-transform-es2015-for-of": "^6.8.0",
"babel-plugin-transform-es2015-object-super": "^6.8.0",
"babel-plugin-transform-es2015-parameters": "^6.11.4",
"babel-plugin-transform-es2015-shorthand-properties": "^6.8.0",
"babel-plugin-transform-es2015-spread": "^6.8.0",
"babel-plugin-transform-es2015-template-literals": "^6.8.0",
"babel-plugin-transform-object-assign": "^6.8.0",
"babel-preset-es2016": "^6.11.3",
"colors": "^1.1.2",
"del": "^2.2.2",
"gulp": "^3.9.1",
"gulp-concat": "^2.6.0",
"gulp-file-include": "^0.14.0",
"gulp-load-plugins": "^1.2.4",
"gulp-uglify": "^2.0.0",
"gulp-watch": "^4.3.9",
"require-dir": "^0.3.0",
"run-sequence": "^1.2.2",
"uglify-js": "github:mishoo/UglifyJS2#harmony"
},
I am coming to answer my question again.
Babeljs 6.14.0 start to support "async function" which was declared in ES7. The word "async" became a keyword for the compiler, so I can't use "async" as a variable name.
Then I change "async = true" to "sync = false" to solve this problem.
I reported an issue to the Babeljs on github. I think this issue has already been fixed.
Inherited a broken NLog project from a long-gone co-worker...
VS2015 update 2
Latest Node install
Latest npm update 3.10.3
'.net 5.0' project (pre-core 1.0)
My npm node always says 'npm - not installed'
When I right click, I instantly get 'illegal characters in path'
here's my package.json
{
"version": "0.0.0",
"name": "asp.net",
"devDependencies": {
"gulp": "^3.9.0",
"gulp-bower": "^0.0.11",
"gulp-concat": "^2.6.0",
"gulp-install": "^0.6.0",
"gulp-sass": "^2.1.1",
"gulp-uglify": "^1.5.1",
"gulp-util": "^3.0.7",
"gulp-watch": "^4.3.5",
"run-sequence": "^1.1.5",
"browser-sync": "^2.10.0",
"gulp-filter": "^3.0.1",
"main-bower-files": "^2.9.0",
"gulp-rename": "^1.2.2",
"gulp-sourcemaps": "^1.6.0"
}
here's my project.json:
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"EntityFramework.Commands": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final",
"Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-rc1-final",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.Server.WebListener": "1.0.0-rc1-final",
"Microsoft.AspNet.Session": "1.0.0-rc1-final",
"Microsoft.AspNet.SignalR.Server": "3.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
"Microsoft.Extensions.Caching.Memory": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.NLog": "1.0.0-rc1-final",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final",
"MvcWebApiCors": "0.3.0"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel",
"ef": "EntityFramework.Commands"
},
"frameworks": {
"dnx451": {
"dependencies": {
"Rally.RestApi": "1.0.0-*"
}
}
},
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
],
"publishExclude": [
"node_modules",
"bower_components",
"**.kproj",
"**.user",
"**.vspscc"
],
"scripts": {
"postrestore": [ "npm install" ],
"prepare": [ "gulp" ]
}
Here's my Bower.json
{
"name": "WebApplication",
"private": true,
"dependencies": {
"bootstrap": "^4.0.0-alpha.2",
"signalr": "^2.2.0",
"font-awesome": "^4.5.0",
"moment": "^2.11.0",
"Chart-js": "^1.0.2",
"tether": "^1.1.1",
"bootstrap-daterangepicker": "2.1.17",
"handlebars": "^4.0.5",
"chosen": "^1.4.2"
}
global.json
{
"projects": [
"src",
"wrap"
],
"sdk": {
"version": "1.0.0-rc1-update1"
}
The overall problem is that none of the css/styles are showing. The site looks skeletal compared to what's on our iis box.
Faced the same issue when tried to install an npm package globally (with -g flag).
Any npm package which I tried to install globally was throwing the same error given below.
npm ERR! code EINVAL
npm ERR! path C:\Users\xxxxxxx'C:\Users\xxxxxxx\AppData\Roaming\npm
npm ERR! Illegal characters in path.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\xxxxxxx\AppData\Local\npm-cache\_logs\2021-12-15T10_49_39_874Z-debug.log
I checked the PATH variable. All is well.
After some research over the internet, tried the following command
npm bin -g
This showed a weird path.
C:\Users\xxxxxx'C:\Users\xxxxxx\AppData\Roaming\npm
(not in PATH env variable)
After reading this post, I tried to set the path prefix of npm config and it worked!
This is how I set it.
npm config set prefix C:\Users\xxxxxxx\AppData\Roaming\npm
You can check & confirm the same using,
npm config get prefix
Ideally, this path was getting added to the '.npmrc' file in my home directory (C:\Users\xxxxxxx). If you don't have any other content in the '.npmrc' file (like an access token to your private npm registry), deleting the file will fix this issue.
Just posting here, so that someone facing similar issue might find
this helpful as the question title relates to this issue.
Found the answer...
Some packages (for instance webpack) have dependency on packages that are not supported on windows which causes NPM to print warning about it. VS interprets it as generic problem and says that packages are not installed even though in reality this warning should be ignored.
I'm having an issue with vue-loader where it will not recognize es2015 format.
Here are the steps I'm taking:
//initialize the project via vue-cli
vue init webpack-simple && npm i
// start the webpack-dev-server, this npm script is an alias for the command:
// webpack-dev-server --inline --hot
npm run dev
At this point the files are being hosted by webpack-dev-server at localhost:8080 successfully.
When I modify App.vue and add anything es2015 in I get an error from webpack-dev-server:
<template>
<div id="app">
<h1>{{ msg }}</h1>
</div>
</template>
<script>
export default {
data () {
return {
msg: 'Hello Vue!'
}
},
// added this function call for the ready lifecycle hook
ready () => alert('worked')
}
</script>
<style>
body {
font-family: Helvetica, sans-serif;
}
</style>
This made me think that the es2015 preset for babel wasn't installed, but it is definitely in the dev dependencies list along with the transform-runtime:
// truncated package.json
{
...
"scripts": {
"dev": "webpack-dev-server --inline --hot",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
},
"dependencies": {
"vue": "^1.0.0",
"babel-runtime": "^5.8.0"
},
"devDependencies": {
"babel-core": "^6.0.0",
"babel-loader": "^6.0.0",
"babel-plugin-transform-runtime": "^6.0.0",
"babel-preset-es2015": "^6.0.0",
"babel-preset-stage-2": "^6.0.0",
"cross-env": "^1.0.6",
"css-loader": "^0.23.0",
"file-loader": "^0.8.4",
"json-loader": "^0.5.4",
"url-loader": "^0.5.7",
"vue-hot-reload-api": "^1.2.0",
"vue-html-loader": "^1.0.0",
"vue-loader": "^8.2.1",
"vue-style-loader": "^1.0.0",
"webpack": "^1.12.2",
"webpack-dev-server": "^1.12.0"
}
}
Plus the docs for vue-loader say that es2015 is enabled by default:
There are many cool features provided by vue-loader:
ES2015 enabled by default;
Is there a step or a configuration I'm missing?
Versions:
vue-cli: 2.0.3
npm: 3.8.6
node: 6.0.0
I think it should be
ready: () => alert('worked')
or
ready(){alert('worked')}