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

incorrect path when resolve to the same or the sub folder #404

Open
lake2 opened this issue Nov 1, 2021 · 2 comments · May be fixed by #405
Open

incorrect path when resolve to the same or the sub folder #404

lake2 opened this issue Nov 1, 2021 · 2 comments · May be fixed by #405

Comments

@lake2
Copy link

lake2 commented Nov 1, 2021

this test case will fail:

  ['should support wild card aliases']: {
    options: { config: { paths: { '@/*': ['./src/*'] } } },
    path: './src/pages/Page.ts',
    input: "import module from 'module'\nimport Component from '@/pages/components'",
    output: "import module from 'module'\nimport Component from './components'",
  },
@lake2
Copy link
Author

lake2 commented Nov 19, 2021

please merge and release a new version

@ayelsew
Copy link

ayelsew commented Mar 4, 2023

To help others, while #405 isn't merged, I'm changing de code inside node_modules without transpile.

Inside lib/index.js line 61

function resolveImports(file, imports, options) {
        //...code 
        
        const target = path_1.default.relative(base, resolved);
        let relative = path_1.default.relative(current, target).replace(/\\/g, '/');
        if (!relative.startsWith('..')) {
            // https://github.com/gulp-plugin/alias/issues/404
            // in the some folder or the sub folder
            relative = './' + relative
        }
        lines[imported.index] = line.replace(imported.import, relative);
        
        //...code
  }

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

Successfully merging a pull request may close this issue.

2 participants