Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement Request: Custom Builds using Typescript Compiler #6494

Closed
ca0v opened this issue Feb 14, 2017 · 8 comments
Closed

Enhancement Request: Custom Builds using Typescript Compiler #6494

ca0v opened this issue Feb 14, 2017 · 8 comments

Comments

@ca0v
Copy link

ca0v commented Feb 14, 2017

I created a custom openlayers 4 build using typescript and amd (https://github.com/ca0v/ol4-lab) but had to tweak rbush/quickselect because, unlike ol, it cannot support es6 syntax. This was the only thing preventing a basic custom build using nothing but tsc.

@marcjansen
Copy link
Member

Very interesting!

@bjornharrtell
Copy link
Contributor

Agreed, I also find this interesting. But I don't understand the size comparison i.e the reference to a 91k ol-debug.js doesn't seem right to me?

@ca0v
Copy link
Author

ca0v commented Feb 14, 2017

@bjornharrtell Those were line counts so roughly 1.4MB vs 2.5MB uncompressing.

@ahocevar
Copy link
Member

ahocevar commented Feb 15, 2017

@ca0v I have not tried, and I don't know how Rollup would fit into your stack. But https://github.com/rollup/rollup-plugin-commonjs (and similar tools) should be able to help here. Just so you know, rbush is a normal dependency of ol.

That said, please keep us posted on any findings that make the ol package work with the TypeScript compiler.

@ca0v
Copy link
Author

ca0v commented Feb 15, 2017

@ahocevar rollup might do it because the rbush project cannot use es6 syntax due to a browserify limitation (see mourner/rbush#66 (comment)). @morner might consider use tsc instead although I'm not sure how that would work.

Maybe: tsc --allowJs rbush.js --outDir ./out --module umd

@probins
Copy link
Contributor

probins commented Feb 16, 2017

what exactly is the 'enhancement request' here? OL uses 5 external 'modules': the 4 in ol.ext, and proj4js. It uses proj4js global, and tasks/build-ext.js hacks the ol.ext ones so they can be used with GCC. The ol ES-module package simply imports the ol.ext ones as CJS modules. This however only works with server-side tools that can import CJS, so isn't usable directly in the browser, and from what you say can't be used with TS either.

I'm currently exploring using the ES-module OL version directly in the browser, and as part of this have created a custom version of proj4js and rbush replacing the UMD wrapper with an ES one. I could make these available for use in other environments, such as TS if that can't handle the current CJS import. Alternatively, there are tools like https://github.com/nolanlawson/cjs-to-es6 which enable you to convert CJS modules to ES (with various caveats, as it's not a simple 1-to-1). I view these though as short-term fixes. ISTM the long-term solution is for the upstream packages to provide the code in ES module form. I don't see much that OL can do ATM other than provide short-term hacks.

@ca0v
Copy link
Author

ca0v commented May 1, 2017

@probins The 'enhancement' is to allow TSC to build OL projects without modifying the dependencies. The implications of using TSC to build the transpiled code instead of browserify means asking multiple project owners to experiment with something that might not work. I can only say it worked for a very simple demo using 4.0.1 and if it works in the larger picture would simplify the build process (tsc will transpile and concatenate) for typescript developers. As an aside, typescript delivers freedom through constraint that ol developers might come to love nearly as much as their unit tests.

@fredj
Copy link
Member

fredj commented Apr 23, 2019

The es6 module migration is now complete, closing

@fredj fredj closed this as completed Apr 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants