🏠 back to Observable

How to require @antv/l7

We are trying to require the library L7:

Demo: https://l7.antv.vision/en/examples/gallery/animate#animate_line
Github: https://github.com/antvis/L7
npm: https://www.npmjs.com/package/@antv/l7

we have tried a lot of ways and followed https://observablehq.com/@observablehq/how-to-require-stubborn-modules and the “module require debugger” but it still does not work. We even try to change the way of packaging the library.

The import works on stackblitz and CodeSandbox. Could anyone help? THANKS!

Sure, here’s a demo:

The problem is that AntV L7 appears to be publishing an invalid AMD bundle: it depends on a variety of core-js modules which aren’t available as AMD modules. But those core-js modules aren’t needed anyway, apparently: you can get the module to load just fine by having them all resolve to null using require.alias.

In cases like this, I’d probably fork their repository and then use Rollup to build my own bundle that works correctly. Stackblitz and CodeSandbox effectively do this for you using Webpack, but Observable doesn’t provide a built-in bundler. I’d also consider posting a PR to the L7 repo that fixes the bundle, but I’m not sure what the intent was in crafting the AMD bundle this way.

2 Likes

Thank you, Mike! You saved my day!

I believe the authors of L7 would be super happy to get your help, you are the best!

1 Like

Thanks,I have solved this problemin L7 library。 https://observablehq.com/@lzxue/l7-line-layer

Welcome to star L7, I will be honored。

1 Like

Awesome, thanks for the fast fix! I’ve updated my notebook accordingly.

1 Like

the demo of hello antV L7 not work can you fix it . L7 = require("@antv/l7") thanks.