-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New faster resolver supporting absolute and tilde paths, and aliases #850
Conversation
What about alias modules under specific directory? Or it can be alias one by one? Like: https://webpack.js.org/configuration/resolve/#resolve-modules |
@JounQin yeah, I don't think we are going to support something like that (similar to |
Does this support mapping of named exports? For example webpack supports this syntax:
|
This is a mapping of files only. If you wanted to do something like that I guess you could do it by mapping to your own file which re-exports the thing you want. {
"alias": {
"ipcRenderer": "./electron-ipc.js"
}
} in electron-ipc.js: module.exports = require('electron').ipcRenderer; |
Codecov Report
@@ Coverage Diff @@
## master #850 +/- ##
==========================================
- Coverage 91.98% 91.12% -0.86%
==========================================
Files 68 68
Lines 3404 3392 -12
==========================================
- Hits 3131 3091 -40
- Misses 273 301 +28
Continue to review full report at Codecov.
|
I have a SCSS file containing What am I doing wrong? |
Alright, I took your advice and added a |
Ok, that makes sense. When importing directly in the javascript file however, like this: |
@Cliff122 hmmm not sure why u get an error, might be u are using it incorrectly, your import would resolve like this I think. |
Oh, my bad! I must have misread the description of the pull request. I thought tildes would resolve to the // .sassrc.js
const importer = require('node-sass-tilde-importer')
module.exports = {
importer
} |
@davidnagli An approximation for the release of this update? So excited! |
Does this also allow imports for modules residing in a monorepo root node_modules folder? i.e. Will |
Has 1.7.0 has been released? I see I am trying to use The nearest The import line is Absolute Paths
Tilde Paths
My workaround is to use |
I have the same issue as @wesleyboar. I have been used to doing something like To me it has some great advantages:
Since you've already implemented reading {
"alias": {
"~": "./src/app/"
}
} |
^ Maybe submit a new issue for this. Your request might get lost in a merged PR |
Any news about this ? |
It seems that folders aliased via the package.json file are not being transpiled by babel.
Instructing babel via a .babelrc file to transpile down to es5 doesn't apply to these aliased folders. How can we make that work? |
This is my initial attempt at resolving #184, #132 and documenting parcel-bundler/parcel#850 I have a few questions which I believe should be answered and better described before merging: - I would like to answer this question in the docs parcel-bundler/parcel#850 (comment) - clarify terminology of: - project root: top-level package.json? - package root: package.json in node_module module? where does this start to resolve from? - these comments https://github.com/parcel-bundler/parcel/pull/850/files#diff-f90b0caefa8028ff5ec8f2f2c2e6e39dR8 seem to suggest I may be missing some important information that should be documented Closes #184
For future me, this is now documented in https://parceljs.org/module_resolution.html |
Did you solve this somehow @goyney ? |
Yeah, we solved it by moving to Webpack. 😄 |
Me too. |
No, I cannot. We literally switched away from Parcel over a year ago. |
This replaces the
browser-resolve
andresolve
modules with our own custom resolver which is both faster and more extendible. It especially speeds up building from cache: on one project my build time went from 4.93s to 1.40s.This performance increase is due to severely fewer
fs.stat
calls compared to theresolve
implementation: for example, resolving one dependency I had in my project caused 258fs.stat
calls inresolve
whereas it takes just 9 in the new resolver.In addition to performance, there is also some new features:
package.alias
field in package.json. It works identically to thebrowser
field, but when found in the project root package.json it applies globally rather than to only the local module. The alias field also works within node_modules, but does not apply globally. Closes Add an aliasing system that works for all asset types #25, closes 🙋 Aliasing modules -- react -> preact-compat etc. #832.As an example, you could declare the following in your project's package.json to alias react to preact globally:
This can also be used to alias modules that don't exist in node_modules at all:
Now you can
require('fake-module')
and it will point to the path you've specified.