question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

add support for webpack alias

See original GitHub issue

Cannot detect the imported file if a project not use relative path import.

For example, use babel-plugin-module-resolver:

// .babelrc
{
  "plugins": [
    [ "module-resolver", {
       "alias": {
          "@": "./src"
        }
     }]
  ]
}

or use webpack resolve. alias

module.exports = {
  //...
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src')
    }
  }
};

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Slapboxcommented, Jun 6, 2022

Hey @smeijer, thanks for your reply!

What I mean is to allow resolutions to be set on a per-entry basis. So in your example, maybe entry[0] would need to resolve our-utils-platform to our-utils-node and in entry[1] would need to resolve our-utils-platform to our-utils-web.

It seems like unimported makes a configuration like that of its own behind the scenes that looks like below, and it would be great if we could set the same type of config from the .unimportedrc.json

"entryFiles": [
    {
      "file": "src/main.ts",
      "aliases": {
        "our-utils-platform": "our-utils-node
      },
      "extensions": [ ".js", ".ts", ".tsx" ]
    },
    {
      "file": "src/pages/**/*.{js,ts}",
      "aliases": {
        "our-utils-platform": "our-utils-web
      },
      "extensions": [ ".js", ".ts", ".tsx" ]
    },

Does that explanation make sense? Thanks again for your hard work and for your reply!

0reactions
smeijercommented, May 29, 2022

Hi @Slapbox , it is possible to specify entryFiles via the config file. Does that help?

{
  "entry": ["src/main.ts", "src/pages/**/*.{js,ts}"],
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Resolve | webpack
you can use the alias: import Utility from 'Utilities/utility';. A trailing $ can also be added to the given object's keys to signify...
Read more >
How to Create a Path Alias in Webpack - Bitovi
Establish the Module Aliases · Open your Webpack.config.js file. · If it's not already there, add a resolve property to the configuration object ......
Read more >
Simplify your imports with webpack aliases
By adding some options to webpack's resolve configuration object, we can define aliases for specific directories. For example:.
Read more >
Webpack Aliases Keep My Code Sane | by Michael McShinsky
Aliases are a way to let webpack know where to find our code by providing a word or character that represents a partial...
Read more >
Configuring aliases in webpack + VS Code + Typescript + Jest
Webpack needs to know physical paths that map to the aliases we want to create. In order to inform that mapping, we need...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found