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

Add latest typescript to CodeSandbox devDependencies #14589

Merged
merged 1 commit into from Mar 22, 2023

Conversation

mike-000
Copy link
Contributor

While adding an empty .babelrc in #14419 prevented unwanted transpiling by CodeSandbox after #14279 it appears that the default parcel template in CodeSandbox uses an old version of Babel for parsing the application JavaScript and as noted in #14445 (comment) modern syntax such as optional chaining (which would have been useful in the example in #14582 (comment)) is rejected. If the unneeded '@babel/core': 'latest', removed from live example by #14279 is injected into the package.json supplied to CodeSandbox it fixes the problem. This is an external use so it does not need to be an OpenLayers dependency.

@github-actions
Copy link

📦 Preview the website for this branch here: https://deploy-preview-14589--ol-site.netlify.app/.

@tschaub
Copy link
Member

tschaub commented Mar 20, 2023

It looks like a few alternatives to adding babel would be to

I'm not sure how much would have to change if we used Cloud Sandboxes instead of Web Sandboxes (I think this is the term they use to differentiate). Also don't know if Cloud Sandboxes will provide a better or worse experience for people trying to edit our examples (not sure if they will be faster or slower, etc.).

It feels pretty easy to just change the icon-width.js example to avoid using optional chaining. But there could be other things that break the CodeSandbox/Parcel parser as well.

I don't have a strong preference regarding Typescript or Babel, but Typescript feels closer to being a first class dev dependency of ours, so I might choose that over Babel.

@mike-000
Copy link
Contributor Author

mike-000 commented Mar 20, 2023

But there could be other things that break the CodeSandbox/Parcel parser as well.

I looks like syntax changes in ES2018 such as let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 }; (or as used in https://openlayers.org/en/latest/examples/clusters-dynamic.html) and later ES versions all cause problems.

Adding "typescript": "latest" as a fix works equally as well as "@babel/core": "latest".

@mike-000 mike-000 changed the title Add latest @babel/core to CodeSandbox devDependencies Add latest typescript to CodeSandbox devDependencies Mar 20, 2023
Copy link
Member

@tschaub tschaub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @mike-000

@tschaub tschaub merged commit b7b14a8 into openlayers:main Mar 22, 2023
8 checks passed
@mike-000 mike-000 deleted the CodeSandbox branch March 22, 2023 16:13
@jahow
Copy link
Contributor

jahow commented Mar 23, 2023

thanks for taking care of this!

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

Successfully merging this pull request may close these issues.

None yet

3 participants