lion icon indicating copy to clipboard operation
lion copied to clipboard

[remark-extend] dependencies of imports are not considered

Open tlouisse opened this issue 3 years ago • 3 comments

Expected behavior

When I import an external .md, I would expect it to work without having knowledge about its internals and/or having to do manual work on top.

Actual Behavior

I need to copy its dependencies. Everytime the internals of the imported part change, I need to manually change this in my extension layer as well.

Additional context

Would it be possible to do smth like this (around here):

  • find all imports in the file
  • resolve their paths to new relative context in case they are local imports
  • inject those at the top of the md

So I would expect the js imports to be copied in md below when it would be imported in external context:

    ```js
    import { some } 'asset-lib'
    import { another } '../asset.js'
    ```    
    # Imported Content Heading
    
    Lorem Ipsum...

This is now:

    # Imported Content Heading
    
    Lorem Ipsum...

It should become:

    ```js
    import { some } 'asset-lib'
    import { another } '../../node_modules/pkg-extended/src/asset.js'
    ```    
    # Imported Content Heading
    
    Lorem Ipsum...

tlouisse avatar Dec 08 '21 10:12 tlouisse

hmmm you sure?

iirc it should import the code blocks as well? e.g. it should bring everything along "as is".

changing the path automatically is IMHO not possible as you can not know the public import path of that local file. So in order to use any imports you should always use a package entry points

```js
import { another } '../asset.js'
// should be
import { another } 'my-pkg/asset.js'
// or
import { another } 'my-pkg/asset'
```

daKmoR avatar Dec 09 '21 06:12 daKmoR

Ok, maybe I experienced an edge case, then. It was for the overlay config doc (it doesn't bring along './assets/ref.js';)

tlouisse avatar Dec 09 '21 09:12 tlouisse

See for an illustration: https://github.com/ing-bank/lion/pull/1637

It currently makes it hard to debug our extension layer, since it's quite unpredictable how the total page is assembled, especialyy when conflicting versions of lit are involved.

Especially when we need to support local design systems extending ours, we need to have a stable, debuggable solution for this I think

tlouisse avatar Mar 23 '22 23:03 tlouisse