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

fix(sandpack): Rewrite import.meta to $csb__import_meta #6031

Merged
merged 1 commit into from
Aug 10, 2021

Conversation

DeMoorJasper
Copy link
Member

@DeMoorJasper DeMoorJasper commented Aug 9, 2021

What kind of change does this PR introduce?

Before this PR we didn't touch import.meta which resulted in errors as import.meta is only allowed in ESModules.

What is the current behavior?

We don't do anything with import.meta resulting in errors.

What is the new behavior?

Now sandpack replaces import.meta with $csb__import_meta which we insert as a module-scoped variable if import.meta is used.

What steps did you take to test this? This is required before we can merge, make sure to test the flow you've updated.

Wrote some basic unit tests and tried out this failing sandbox https://codesandbox.io/s/quizzical-cerf-2ph7r?file=/src/index.tsx

Closes CSB-858

@DeMoorJasper DeMoorJasper requested a review from CompuIves August 9, 2021 17:19
@linear
Copy link

linear bot commented Aug 9, 2021

CSB-858 `import.meta` isn't currently polyfilled

We need to polyfill import.meta.url to get Framer's esmodules to work, this is also a great feature for us in general.

These should be transpiled away to something like $csb_import_meta which we can define at the top of each file

@lbogdan
Copy link
Contributor

lbogdan commented Aug 9, 2021

Build for latest commit 578c306 is at https://pr6031.build.csb.dev/s/new.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 9, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 578c306:

Sandbox Source
Notifications Test Configuration
cool-cdn-trmbh PR

@DeMoorJasper DeMoorJasper merged commit 4ca3232 into master Aug 10, 2021
@DeMoorJasper DeMoorJasper deleted the fix/rewrite-import-meta branch August 10, 2021 09:53
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.

2 participants