question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Import in ES6 module from ol.js file in dist folder

See original GitHub issue

Hi, I’m trying to use the full ol library importing it in an ES6 module like that

import * as ol from '../../vendor/ol/ol.js';

When I run my web app, ol is not defined because there’s no export in dist/ol.js file image

I know for sure that if the file has this kind of export

!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.ol=n():t.ol=n()}(self,(function(){return etc...

It will be possibile to import it as I want.

The question is, is there a way to build the ol.js in that form? How it can be done?

I tried cloning the openlayer repo but I can’t find a way…

I thought to remove the commonjs() option from the rollup config bundler but I had this error

image

Can someone please help me?

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
tschaubcommented, Sep 29, 2022

I ran into some other problems trying to build the full lib as umd and decided it would be script tag only. I think there were issues with the GeoTIFF workers, but can’t recall. It could be that someone else can solve the problems.

If you already have a bundle/build step in your application, you will benefit from importing just the modules you need. Unless your application uses every format, every source, all layers and renderers, etc., the full build is more than you need.

1reaction
MoonEcommented, Sep 29, 2022

You have to fork this repository and push to your fork, then you can create a pull request here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it possible to import modules from all files in a directory ...
Thanks for the help. I was able to get this working with index. js looking like: import ThingA from 'things/ThingA'; export {ThingA as...
Read more >
The JavaScript Modules Handbook – Complete Guide to ES ...
A JavaScript module is a file that allows you to export its code. This allows other JavaScript files to import and use the...
Read more >
How to include a JavaScript file in another JavaScript file?
An ES6 module is a JS file that can export its code to share with other files and import and use code from...
Read more >
Compiled JavaScript import is missing file extension #40878
Expected behavior: The compiler generates JavaScript "which runs anywhere JavaScript runs: In a browser, on Node.
Read more >
How to transpile ES modules with webpack and Node.js
Learn how webpack interacts with and supports ES modules in this deep dive tutorial on transpilation in Node.js.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found