Skip to content
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

Doesn't resolve directory aliases #19

Open
SudoPlz opened this issue Jul 3, 2020 · 7 comments
Open

Doesn't resolve directory aliases #19

SudoPlz opened this issue Jul 3, 2020 · 7 comments

Comments

@SudoPlz
Copy link

SudoPlz commented Jul 3, 2020

Hey there,

in our project we use module-resolver with directory aliases, the config looks like this:

[
    "module-resolver",
    {
      "root": [
        "."
      ],
      "alias": {
        "~": "./src",
        "lib": "./src/lib",
        "components": "./src/components",
        "state": "./src/state",
        "config": "./src/config",
        "RootParams": "./src/lib/Shared/ScreenManager/RootParams"
      }
    }
  ]

but when running deadfile we get the following error:

err:  Error: Can't resolve './src' in '/Users/workstation/Development/example/mobile'
    at /Users/workstation/.nvm/versions/node/v12.13.1/lib/node_modules/deadfile/node_modules/enhanced-resolve/lib/Resolver.js:209:21
    at /Users/workstation/.nvm/versions/node/v12.13.1/lib/node_modules/deadfile/node_modules/enhanced-resolve/lib/Resolver.js:285:5
    at eval (eval at create (/Users/workstation/.nvm/versions/node/v12.13.1/lib/node_modules/deadfile/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
    at /Users/workstation/.nvm/versions/node/v12.13.1/lib/node_modules/deadfile/node_modules/enhanced-resolve/lib/Resolver.js:285:5
    at eval (eval at create (/Users/workstation/.nvm/versions/node/v12.13.1/lib/node_modules/deadfile/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:27:1)
    at /Users/workstation/.nvm/versions/node/v12.13.1/lib/node_modules/deadfile/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:67:43
    at /Users/workstation/.nvm/versions/node/v12.13.1/lib/node_modules/deadfile/node_modules/enhanced-resolve/lib/Resolver.js:285:5
    at eval (eval at create (/Users/workstation/.nvm/versions/node/v12.13.1/lib/node_modules/deadfile/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:16:1)
    at /Users/workstation/.nvm/versions/node/v12.13.1/lib/node_modules/deadfile/node_modules/enhanced-resolve/lib/Resolver.js:285:5
    at eval (eval at create (/Users/workstation/.nvm/versions/node/v12.13.1/lib/node_modules/deadfile/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:27:1) {
  details: "resolve './src' in '/Users/workstation/Development/example/mobile'\n" +
    '  using description file: /Users/workstation/Development/example/mobile/package.json (relative path: .)\n' +
    '    using description file: /Users/workstation/Development/example/mobile/package.json (relative path: ./src)\n' +
    '      no extension\n' +
    '        /Users/workstation/Development/example/mobile/src is not a file\n' +
    '      .js\n' +
    "        /Users/workstation/Development/example/mobile/src.js doesn't exist\n" +
    '      .jsx\n' +
    "        /Users/workstation/Development/example/mobile/src.jsx doesn't exist\n" +
    '      .ts\n' +
    "        /Users/workstation/Development/example/mobile/src.ts doesn't exist\n" +
    '      tsx\n' +
    "        /Users/workstation/Development/example/mobile/srctsx doesn't exist\n" +
    '      .vue\n' +
    "        /Users/workstation/Development/example/mobile/src.vue doesn't exist\n" +
    '      as directory\n' +
    '        existing directory\n' +
    '          using path: /Users/workstation/Development/example/mobile/src/index\n' +
    '            using description file: /Users/workstation/Development/example/mobile/package.json (relative path: ./src/index)\n' +
    '              no extension\n' +
    "                /Users/workstation/Development/example/mobile/src/index doesn't exist\n" +
    '              .js\n' +
    "                /Users/workstation/Development/example/mobile/src/index.js doesn't exist\n" +
    '              .jsx\n' +
    "                /Users/workstation/Development/example/mobile/src/index.jsx doesn't exist\n" +
    '              .ts\n' +
    "                /Users/workstation/Development/example/mobile/src/index.ts doesn't exist\n" +
    '              tsx\n' +
    "                /Users/workstation/Development/example/mobile/src/indextsx doesn't exist\n" +
    '              .vue\n' +
    "                /Users/workstation/Development/example/mobile/src/index.vue doesn't exist",
  missing: [
    '/Users/workstation/Development/example/mobile/src',
    '/Users/workstation/Development/example/mobile/src.js',
    '/Users/workstation/Development/example/mobile/src.jsx',
    '/Users/workstation/Development/example/mobile/src.ts',
    '/Users/workstation/Development/example/mobile/srctsx',
    '/Users/workstation/Development/example/mobile/src.vue',
    '/Users/workstation/Development/example/mobile/src/index',
    '/Users/workstation/Development/example/mobile/src/index.js',
    '/Users/workstation/Development/example/mobile/src/index.jsx',
    '/Users/workstation/Development/example/mobile/src/index.ts',
    '/Users/workstation/Development/example/mobile/src/indextsx',
    '/Users/workstation/Development/example/mobile/src/index.vue'
  ]
}

Looks like the problem is enhanced-resolver doesn't understand that /src refers to a directory (and not a file), and is trying to find a specific file in there.

Any ideas?

Thanks

@zstuder25
Copy link

Any update on this?

@angelod1as
Copy link

Got this issue today.

@danielcarvalho-hotmart
Copy link

up 👀

@eightHundreds
Copy link

const defaultParsableExtensions = [".js", ".jsx", ".ts", "tsx", ".vue"];

const defaultParsableExtensions = [".js", ".jsx", ".ts", "tsx", ".vue"];

tsx mabe missing .

@leason-wan
Copy link

Can support webpack config?

@joepake
Copy link

joepake commented Oct 26, 2022

I encountered this issue and I resolved by this way:

Replace all import 'alias' to your absolute path. eg: '.src/' -> '/Users/workstation/Development/example/mobile/src/'
Run deadfile command
Delete all unused files
Replace all absolute paths to your alias

@steffenag97
Copy link

In our babel.config.js we have the following, which works like a charm 😃

alias: {
  client: path.resolve(__dirname, './client/')
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants