You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When alias is resolved with a final .js script (1), and a require() call adds a trailing slash after the package name (2), esbuild fails with the following error:
X [ERROR] Could not resolve "(...)\\node_modules\\util\\util.js/" (originally "util/")
../../node_modules/assert/assert.js:73:19:
73 │ var util = require('util/');
╵ ~~~~~~~
The path "util/" was remapped to "(...)\\node_modules\\util\\util.js/" using the alias feature, which then couldn't be resolved. Keep in mind that import path aliases are resolved in the current working directory.
You can mark the path "(...)\\node_modules\\util\\util.js/" as external to exclude it from the bundle, which will remove this error. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.
Based on the previous configuration example, I had to fix node-libs-react-native final script paths to package directory paths for a couple of modules:
The text was updated successfully, but these errors were encountered:
alxroyer
changed the title
Aliasing fails due to trailing slash when required
Final scripts aliases fail due to trailing slash when required
Dec 9, 2022
Problem
When alias is resolved with a final .js script (1), and a
require()
call adds a trailing slash after the package name (2), esbuild fails with the following error:(1) As node-libs-react-native@1.2.1 does.
(2) As commonjs-assert@1.5.0 does.
Example
Reuse of node-libs-react-native's polyfills in esbuild configuration:
Environment: React Native, Android
Workaround
Based on the previous configuration example, I had to fix node-libs-react-native final script paths to package directory paths for a couple of modules:
The text was updated successfully, but these errors were encountered: