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(macro): Apply macro.js shim at pkg build time #1998

Closed

Conversation

floryst
Copy link
Collaborator

@floryst floryst commented Jul 12, 2021

babel-plugin-macros interferes with our macro.js file. As it is not
ideal to rename it, nor is it feasible to convince babel-plugin-macros
to change its "ownership" of any files ending in "macro.js", this is an
attempt at shimming macro.js to effectively sneak past
babel-plugin-macros while still maintaining compatibility with existing
macro.js consumers.

Context

Changes

  • Add a package build-time step to apply a macro.js shim.

Results

  • CRA, Jest, and other users of babel-plugin-macro should no longer have cryptic errors when trying to use vtk.js.

Testing

  • verify Typescript experience is still the same
  • verify both ESM and UMD packages operate correctly

@floryst floryst requested a review from jourdain July 12, 2021 20:32
babel-plugin-macros interferes with our macro.js file. As it is not
ideal to rename it, nor is it feasible to convince babel-plugin-macros
to change its "ownership" of any files ending in "macro.js", this is an
attempt at shimming macro.js to effectively sneak past
babel-plugin-macros while still maintaining compatibility with existing
macro.js consumers.
@floryst floryst force-pushed the babel-plugin-macros-workaround branch from 4bda2a2 to abcd2db Compare July 12, 2021 20:33
@floryst floryst removed the request for review from jourdain July 12, 2021 21:25
@floryst floryst marked this pull request as draft July 12, 2021 21:25
@floryst
Copy link
Collaborator Author

floryst commented Jul 12, 2021

This has been converted to a draft, as there is a blocking issue:

import * as macro from '@kitware/vtk.js/macro' fails inside babel-plugin-macros, because it does not handle ImportNamespaceSpecifiers. (See: kentcdodds/babel-plugin-macros#111). As of now, the only resolution is to change all instances of import * as macro from ... to import macro from ..., which I think means we do not get tree shaking.

@floryst
Copy link
Collaborator Author

floryst commented Jul 13, 2021

Closing in favor of #2001

@floryst floryst closed this Jul 13, 2021
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.

Can't use @kitware/vtk.js with Jest
1 participant