Esbuild cannot resolve node_modules that contains relative paths - esbuild

I have a node_module with the structure like this.
#module_name
+-- dist
| +-- folder1
| +-- folder2
| +-- file1.d.ts
| +-- src
| +-- file2.d.ts
|
The file1.dt.ts is to expose, through export, some types from the file file2.d.ts.
//file1.dt.ts
export * from '../../src/file2';
But when I try to run the esbuild I receive the error
✘ [ERROR] Could not resolve "../../src/file2"
I have seen this problem in different libraries that use relative paths.

Related

How to include a link to index.html of content generated by another program in reST

My RST directory looks like this:
.
|-- Makefile
|-- build
| |-- doctrees
| `-- html
| |-- codecov <-- Generated by coverage.py
| |-- index.html
| | .... <-- Generated by Sphinx
|-- make.bat
`-- source
|-- _static
|-- changelog.rst
|-- conf.py
|-- contact.rst
|-- getting_started.rst
|-- index.rst
`-- introduction.rst
In my index.rst, I would like to create a relative link titled Code Coverage that points to codecov/index.html. I am not sure how to do that because it is outside my source folder. The 'codecov' folder is auto generated when I run code coverage in python. How to accomplish this?
.. toctree::
:caption: Table of Contents
:maxdepth: 2
introduction
getting_started
changelog
contact
Indices and tables
==================
* :ref:`genindex`
* :ref:`search`
You have at least two options.
Use an external link.
`Code Coverage <../_build/codecov/index.html>`_
Put this in a toctree directive.
.. toctree::
Code Coverage <https://www.example.com/_build/codecov/index.html>
There may be other options, but let's see if either satisfies your need.

how to include .hrl files across multiple modules rebar3

I have several modules's directories. For each module, I have include (containing *.hrl files) and src (containing *.erl files) folder separeated. How can I share *.hrl file from a module to another without duplicating them?
With rebar, I added {erl_opts, [{i, "folderContainsIncludeFile"}]} and it worked.
But with rebar3, the compilation is failed by saying can't find include file "include/xx.hrl"
I take it then you don't have an umbrella project, you just have multiple directories at the same level, each one with its own project managed with rebar3.
Something like:
root_folder
|- project1
| |- src
| |- include
| | `- one.hrl
| `- rebar.config
|- project2
| |- src
| | `- two.erl
| |- include
| `- rebar.config
…
And you want to include one.hrl into two.erl.
If that's the case, you should consider one of these alternatives:
A. Moving to an umbrella project structure, like…
root_folder
|- rebar.config <<<<<<<< notice this file is here now
`- apps
|- project1
| |- src
| `- include
| `- one.hrl
|- project2
| |- src
| | `- two.erl
| `- include
…
B. Using individual repos for each project and configuring them as dependencies from each other. The structure is like the one you currently have, but now you have to add deps to rebar.config's. For instance, in our example, you should add the following line to project2's rebar.config:
{deps, [project1]}.
(if you manage to publish project1 in hex.pm)
C. Properly setting $ERL_LIBS so that it includes the paths where your apps are built with rebar3. Something like…
ERL_LIBS=$ERL_LIBS:/path/to/root_folder/project1/_build/lib:/path/to/root_folder/project2/_build/lib:…
Hope this helps :)

Log4j Configuration File path

We are working on grails and also have microservices. There is a logging service in grails folder and log4j2.xml in grails-app/conf. Now we want to migrate logging service to jar(means outside of grails to one of microservices). So added log4j.xml in our resources folder of maven project. But it is not detecting the configuration file, so logging only to consoles.
Tried several things like
1. Setting system property in code
2. renaming log4j.xml file as log4j2.xml (but it gives error in grails startup)
Edit: Project Structure
Project
|
+-- grails-app
| |
| +-- conf
| |
| +--log4j2.xml
| +-- services/OldLoggingService.groovy
|
+--logevent(mavenproject)
| |
| +-- src/main/groovy/com/log/LogEventProducer.groovy
| +-- src/main/resources/log4j.xml
xml configuration file link
it is not showing any error (just writing logs to console only)

Manage Plugin's Asset in Rails

I am just trying to figure out what's the best way to manage Plugin's Asset in Rails.
For Eg. Let's consider Bootstrap.
I understand there is "vendor" directory for that but even there
I like to keep below directory structure:
App
|-- assets
| |-- plugins
| | |-- bootstrap
| | | |-- fonts
| | | |-- css
| | | | |-- bootstrap.css
| | | | |-- bootstrap.min.css
| | | |-- js
| | | | |-- bootstrap.js
| | | | |-- bootstrap.min.js
I DON'T LIE to follow below directory structure:
App
|-- assets
| |-- fonts
| |-- css
| | |-- application.css
| | |-- bootstrap.css
| | |-- bootstrap.min.css
| | |-- common-style.css
| |-- js
| | |-- application.js
| | |-- bootstrap.js
| | |-- bootstrap.min.js
| | |-- common-script.css
As you can notice above, now if you start adding plugins, files goes into general folders rather grouping all assets with respect to a plugin stay together. If not grouped it will look messy, isn't it?
I understand there is "vendor" directory even there I LIKE to keep below directory structure:
|-- App
|-- vendor
| |-- assets
| | |-- javascripts
| | |-- stylesheets
| |-- bootstrap
| | |-- fonts
| | |-- css
| | | |-- bootstrap.css
| | | |-- bootstrap.min.css
| | |-- js
| | | |-- bootstrap.js
| | | |-- bootstrap.min.js
I DON'T LIKE to follow below directory structure:
|-- App
|-- vendor
| |-- fonts
| |-- assets
| |-- stylesheets
| | |-- bootstrap.css
| | |-- bootstrap.min.css
| | |-- iCheck.css
| |-- javascripts
| | |-- bootstrap.js
| | |-- bootstrap.min.js
| | |-- iCheck.js
Rails has a special directory for adding third party assets. It's called vendor. Underneath it you will find vendor/assets, which contains javascripts and stylesheets subdirectories. So use that instead of app/assets. The latter is where you are supposed to save your own files.
If you are using something like Bootstrap, and this stands true for most plugins, well, it's even easier. Most frameworks are packaged into gems. This means you don't have to worry about manually adding the asset files as the Asset Pipeline handles all of that for you. At most you just have to include the files in your manifest.
A JavaScript file in application.js, for example:
//= require jquery
If you want to go a step further and enforce your own directory structure, you will have to change Rails' config:
config.assets.precompile += %w(vendor/custom_dir/*.jpg)
config.assets.precompile += %w(vendor/custom_dir/*.js)
You can read more about this on Rails guides
You might also find this issue helpful.

How to add LESS files to a rails app

I can't seem to get this to work in my rails app. At a high level, I wan't to use LESS in my app and have it go through the asset pipeline.
This is what my assets look like:
assets
|
|--- javascript
|
|--- stylesheets
|
|-- reset.less
|-- my-mixins.less
|-- my-variables.less
|-- base.less
|
|--- images
|
|--- libs
|
|---foo
|
|--css
|
|--- foo-mixins.less
|
|--- bar.less
I would like to import "my-mixins.less", "my-variables.less" and "foo-mixins.less" into "base.less", as well as other files. "bar.less" should also be added to specific pages if needed.
How would I go about doing this?
This should work, assuming you're using the less-rails gem.
First, add this to somewhere in your configuration (I have mine in my environment.rb):
YourApp::Application.configure do
config.less.paths << File.join(Rails.root, 'app', 'assets', 'less')
end
Now, if you have a file setup like this:
assets
|
|--- javascript
|
|--- css
| |--- site-stylesheet.css.less
|
|--- less
|--- my-mixins.less
You can import my-mixins in site-stylesheet by using:
#import "my-mixins"
And import the stylesheet into your app with:
<%= stylesheet_link_tag "site-stylesheet" %>
You should be able to extrapolate from there for your specific directory structure.
In base.css.less you can write #import "my-variables.less"; and it should work.
The files have to be in the "vendor/assets" or "vendor/plugins" (both at the root level) folder in order to reference them with relative paths.

Resources