How to alias externaled module path?
See original GitHub issueThere’s a problem for me to do SSR building, it’s our framework export alias module, and use resolve.alias
to alias the module , like React, we use
import React from 'bar/lib/sdk/react';
// not use
import React from 'react';
so now, I only add bar/lib/sdk/react
into whiteList
, but it’s unconscionable to bundle all React library.
How could I solve the problem?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Module Resolution or Import Alias: The Final Guide - Raul Melo
Module resolution or import alias is a way we can emulate the same way we import node_modules but with our internal code. We...
Read more >Path aliases with TypeScript in Node.js
Step 2: Install module-alias package ... Note that 'dist' is the folder where the compiled JS files are located. Last but not least...
Read more >How to alias external module path when in ssr?
In other words, I config the resolve.alias = { 'bar/sdk/react': dirname(join(process.cwd(), 'node_modules', 'react')) } both in client and ...
Read more >Absolute Imports and Module Path Aliases
Configure module path aliases that allow you to remap certain import paths.
Read more >How to have path alias in Node.js
Create aliases of directories and register custom module paths in NodeJS using module-alias. Let's first install module-alias. Syntax: npm ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think they had a resolve alias for react but Webpack was requiring react as an external dependency instead of their aliased module. I just ran into a similar issue with lodash-es, which doesn’t work in a node runtime. I tried to rewrite the import to lodash
but Webpack was still requiring lodash-es. I was able to work around it with the following.
Note that the resolve alias is not necessary in this case. This seems to be an issue with Webpack but it might be nice to add an API to this module to rewrite external modules.
@ycjcl868 same question, looks like that you had avoided this by giving up external。