Skip to content

@mdx-js/esbuild not resolving relative paths #1821

@DCsunset

Description

@DCsunset

Initial checklist

Affected packages and versions

@mdx-js/esbuild: 2.0.0-rc.2

Link to runnable example

No response

Steps to reproduce

Create the following directory structure:

index.mdx
pages/
    page.mdx
    data.js

Suppose index.mdx includes import Component from "./pages/page.mdx",
and pape.mdx includes import data from "./data.js".

Then use @mdx-js/esbuild to build:

import esbuild from 'esbuild'
import mdx from '@mdx-js/esbuild'

await esbuild.build({
  entryPoints: ['index.mdx'],
  outfile: 'output.js',
  bundle: true,
  format: 'esm',
  plugins: [mdx({})]
})

Expected behavior

It's expected to bundle them without any error.

Actual behavior

An error occurs:

pages/page.mdx:3:17: error: Could not resolve "./data.js"
    3 │ import data from "./data.js";

Runtime

Node v16

Package manager

npm v8

OS

Linux

Build and bundle tools

esbuild

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions