From eb4b2b451f157e3123a49cf9c739390ccfe27ad6 Mon Sep 17 00:00:00 2001 From: Corey Farrell Date: Fri, 29 Nov 2019 11:01:03 -0500 Subject: [PATCH] feat: Add preserveSymlinks option Fixes #23 --- README.md | 7 ++++++- index.js | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d7481e7..13f797a 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,8 @@ Add `bare-import-rewrite` to `plugins` in your babel settings. "ignorePrefixes": ["//"], "failOnUnresolved": false, "resolveDirectories": ["node_modules"], - "processAtProgramExit": false + "processAtProgramExit": false, + "preserveSymlinks": true }] ] } @@ -111,6 +112,10 @@ A list of extensions to use in resolver. Default `['.mjs', '.js', '.json']`. This causes processing to occur during the babel `Program.exit` visitor. In general this option is not needed. +### preserveSymlinks + +This is passed to the `resolve` module. Default `true`. + ### `.resolve(importModule, sourceFileName, pluginOptions)` - Resolve absolute path. This function is used internally by the babel plugin, is exposed so it can be used diff --git a/index.js b/index.js index 17ae1f6..090d1c5 100644 --- a/index.js +++ b/index.js @@ -53,6 +53,7 @@ function absResolve(importPath, sourceFileName, pluginOptions = {}) { basedir: basedirResolve(importPath, sourceFileName, pluginOptions), extensions: pluginOptions.extensions || ['.mjs', '.js', 'json'], moduleDirectory: pluginOptions.resolveDirectories || 'node_modules', + preserveSymlinks: pluginOptions.preserveSymlinks !== false, packageFilter(packageJson) { packageJson.main = packageJson.module || packageJson['jsnext:main'] || packageJson.main;