How to run babel without inflating my package? - babeljs

I added babel to my project with 2 presets (es2015 and stage-0) and it added 100+ MB of dependencies to my node_modules folder.
Would it be possible to package only my transpiled code without babel dependencies, using a system-wide babel-cli? I tried installing this way but it errors:
Couldn't find preset "es2015" relative to directory "."

Related

Adding dependency removes VS code intelliSense for another local npm workspace dependency

Not sure if this is user error or a bug but I have 3 npm packages that if they exist in my package.json they remove intelliSense for all my other local npm dependencies from my npm workspaces monorepo. Importing the modules still work manually, even if intelliSense doesn't think they exist.
folder structure
/apps
/docs
package.json (does not contain yjs dependencies, intellisense works fine in this folder)
/documentation
package.json (contains yjs dependencies, intellisense to /packages modules does not work)
/packages (contains the modules that is removed)
package.json
"workspaces": [
"apps/*",
"packages/*"
],
These three packages cannot be in package.json. Removing these three dependencies will enable intelliSense to work properly.
"y-webrtc": "^10.2.0",
"y-websocket": "^1.3.16",
"yjs": "^13.5.13"

Include or Exclude node_modules with esbuild

I am using esbuild to build a vscode extension. The build gives a warning like:
✨ Done in 1.28s.
This extension consists of 7026 files, out of which 5430 are JavaScript files. For performance reasons, you should bundle your extension: https://aka.ms/vscode-bundle-extension . You should also exclude unnecessary files by adding them to your .vscodeignore: https://aka.ms/vscode-vscodeignore
DONE Packaged: /my-vscode/my-vscode-0.0.2.vsix (7026 files, 8.43MB)
I am not sure I node_modules need to be added to .vscodeignore ? when I tried doing it and installed the plugin, I get an error that my commands are not found ..
Any thoughts ?

node_modules not installed when running 'vsce package' command

I wrote a VSCode extension and am trying to publish it locally via vsce package. When I install my app through the VSIX file, there's no 'node_modules' folder inside my extension which leads to my extension not loading correctly because no modules are found
I have checked that my required dependencies are indeed inside dependencies and not peerDependencies or devDependencies. I should note that I have a .vscodeingore file containing the following:
.vscode/**
.vscode-test/**
out/test/**
src/**
.gitignore
vsc-extension-quickstart.md
**/tsconfig.json
**/tslint.json
**/*.map
**/*.ts
node_modules
webpack.config.js
I would like that my node_modules be installed and I would see a "node_modules" folder inside my './vscode/extensions/' folder.
Thanks!

Unable to find nuget folder

I'm unable to find some nuget packages (VS 2019, asp.net core 2.2). I found that System.ComponentModels.Annotations can't be found in my .nuget folder and in VS, there is no "expand" arrow next to it like all the other packages:
In my .nuget folder:
I've tried clearing out my packages folder and re-building to get all the packages. I've tried update-package -reinstall. I've tried Installing system.componentmodel.annotations directly (rather than having it install as a dependency). My solution builds fine, but I can't find this package anywhere on my harddrive. I've also noticed that Microsoft.AspNetCore.Razor.Design is exhibiting the exact same behavior.
When NuGet restores a project that uses PackageReference for packages (all SDK-style projects, and opt-in for traditional projects), it writes the obj\project.assets.json file, which is what MSBuild uses to complete the rest of the build.
Looking at the packageFolders section of my test project, I see this:
"packageFolders": {
"c:\\git\\test\\globalPackages\\": {},
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder": {}
},
note that I have a nuget.config that redirects my global packages folder away from my user profile global packages folder, so temporary/fake packages I create don't pollute my real dev environment. FYI in case you're wondering why you don't see c:\users\zivkan\.nuget\packages.
But notice that there are two package folders.
Looking for System.ComonentModel.Annotations in the libraries section of project.assets.json, I see:
"System.ComponentModel.Annotations/4.5.0": {
"sha512": "UxYQ3FGUOtzJ7LfSdnYSFd7+oEv6M8NgUatatIN2HxNtDdlcvFAf+VIq4Of9cDMJEJC0aSRv/x898RYhB4Yppg==",
"type": "package",
"path": "system.componentmodel.annotations/4.5.0",
"files": [
// list of every file in package
]
},
see the path says system.componentmodel.annotations/4.5.0, which means it could be in either or both of c:\git\test\globalPackages\system.componentmodel.annotations\4.5.0 and/or C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.componentmodel.annotations\4.5.0.
For your use-case of trying to load it in Powershell, you can try to load one of the assemblies in the lib\* directory. Pick a TFM you think is compatible with your version of Powershell.
As for the reason that Solution Explorer doesn't have a twisty to expand the package, go find the package in the targets section of the project.assets.json and you'll see this:
"System.ComponentModel.Annotations/4.5.0": {
"type": "package",
"compile": {
"ref/netcoreapp2.0/_._": {}
},
"runtime": {
"lib/netcoreapp2.0/_._": {}
}
},
In other words, the package is not bringing in any assets or additional NuGet dependencies. Therefore nothing to expand in Solution Explorer.
In this specific case it's because netcoreapp2.0 has the assembly built-in to the runtime, and the Microsoft.NETCore.App package has the compile-time metadata for it. This is why I asked why you are looking for the package. If you use project.assets.json to find the exact System.ComponentModel.Annotations.dll that the build uses during compile, you'll find a metadata-only reference assembly that can't be loaded. But I gave insturations above on how to find the package directory and you can look for a loadable dll in one of the lib\* directories to try to load in Powershell.

BabelJS: Doesn't find all .js files in directory

Babel doesn't find all of my .js/.es6 files in my directory.
I have this directory structure:
src/
assets/
sample/
models.es6
scripts/
playground.es6
If I run babel src --out-dir dist --source-maps --copy-files --presets env, it only transpiles /src/assets/sample/models.es6 and doesnt go through src/scripts/playground.es6.
What am I doing wrong?
Looking forward to your response!
You can do like below :
babel src/** --out-dir lib
more at official doc
Compile Directories
Compile the entire src directory and output it to the lib directory. You may use --out-dir or -d. This doesn’t overwrite any other files or directories in lib.
if you still stuck, you can use gulp or grunt or webpack to load/transpile mupltiple directives from different locations.
Hope it helps
I found the problem. It has barely to do with Babel.
Inside the src/assets/** is my Realm database sample.realm (https://realm.io). The file itself doesnt cause the problem. But if you open the sample.realm file with Realm Studio on MacOSX, a file called sample.realm.note gets created. This file causes babel to not exit the transpile task.