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

Could not resolve import '@/utils/string' #2607

Open
andyjessop opened this issue Jan 10, 2024 · 1 comment
Open

Could not resolve import '@/utils/string' #2607

andyjessop opened this issue Jan 10, 2024 · 1 comment

Comments

@andyjessop
Copy link

andyjessop commented Jan 10, 2024

I'm using the esbuildPlugin to transpile TS into JS, and am using the tsconfig option, e.g.:

esbuildPlugin({
      ts: true,
      tsconfig: fileURLToPath(new URL('../../tsconfig.src.json', import.meta.url)),
    }),

I've confirmed that this does return the correct file path. It seems, however, that the paths in the tsconfig are not being respected during the compilation, as I get this error when running tests:

Running tests...
Running 2 test files...
transforming file /first.test.ts
first.test.ts:
 🚧 Browser logs:
      TypeError: Failed to fetch dynamically imported module: http://localhost:8000/first.test.ts?wtr-session-id=d1dh5bc6PE_wVL6xPM-bP
../../packages/browser/second.test.ts:
 🚧 Browser logs:
      TypeError: Failed to fetch dynamically imported module: http://localhost:8000/packages/browser/second.test.ts?wtr-session-id=hg9x2wsRXit4BnNTNOwjm
 🚧 404 network requests:
    - packages/browser/second.test.ts?wtr-session-id=hg9x2wsRXit4BnNTNOwjm
 ❌ Could not import your test module. Check the browser logs or open the browser in debug mode for more information.
Error while transforming first.test.ts: Could not resolve import "@/utils/string".
  1 | import chai from "@esm-bundle/chai";
> 2 | import { toKebabCase } from "@/utils/string";
    |                             ^
  3 | describe("myFunction", () => {
  4 |   it("adds two numbers together", () => {
  5 |     chai.expect(toKebabCase("test to kebab case")).to.equal("test-to-kebab-case");
Chromium: |██████████████████████████████| 2/2 test files | 0 passed, 0 failed
Error while running tests.
@koddsson
Copy link
Contributor

Can you create a minimal reproduction of this issue? What does the paths key in the tsconfig.src.json file look like?

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

2 participants