datatables icon indicating copy to clipboard operation
datatables copied to clipboard

Error [ERR_UNSUPPORTED_DIR_IMPORT]

Open torrfura opened this issue 11 months ago • 4 comments

We're using a monorepo, where we have multiple resources in our packages/ui. Chartist, Melt, OpenTS, etc, which we're re-exporting so multiple apps can use same source. This works for all, but not for this projekt, and I cannot figure out why?

We get this problem:

Directory import '/frontend/node_modules/.pnpm/@[email protected][email protected]/node_modules/@vincjo/datatables/dist/src/client' is not supported resolving ES modules.

Someone know how to fix this? What we essentially want to do, is in our packages/ui, have a component which re-exports @vincjo/datatables:

/packages/ui/components/table/index.ts:

export * from '@vincjo/datatables';
export type * from '@vincjo/datatables';

export { default as Table } from './table.svelte'

This table.svelte, is essentially then itself using the node module:

<script lang="ts">
  import { TableHandler, Datatable, ThSort, ThFilter } from '@vincjo/datatables'
  let { data } = $props();
  const table = new TableHandler(data, { rowsPerPage: 10 })
</script>

<Datatable basic {table}>

This works with other packages, as mentioned.

torrfura avatar Jan 20 '25 11:01 torrfura

I think the entry point should be "@vincjo/datatables/dist" instead of "@vincjo/datatables/dist/src/client"

Directory import '/frontend/node_modules/.pnpm/@[email protected][email protected]/node_modules/@vincjo/datatables/dist/src/client' is not supported resolving ES modules.

There are exports in src/client but they are not intended for use outside of local development.

vincjo avatar Jan 20 '25 16:01 vincjo

Thanks, but I'm only importing / exporting from @vincjo/datatables as you can see in my example above...

torrfura avatar Jan 20 '25 18:01 torrfura

Just released a patch adding "/index.js" in internal imports -> 2.3.2

Hopefully this resolves the issue.

vincjo avatar Jan 21 '25 08:01 vincjo

Sorry, It does not :(

Now I'm not even re-exporting anything, just using the table in my component, trying to import that component in one of my apps...

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/frontend/node_modules/.pnpm/@[email protected][email protected]/node_modules/@vincjo/datatables/dist/src/client/TableHandler.svelte'

torrfura avatar Jan 29 '25 16:01 torrfura