sandpack icon indicating copy to clipboard operation
sandpack copied to clipboard

Feature request: Skip babel transpilation

Open S0ulDrag0n opened this issue 2 years ago • 7 comments

Tell us how you think we can improve Sandpack

To give some context, I have additional library files in a public folder that is meant to be statically served. Currently, I am passing it to the Sandpack component via the files prop. However, these files have already been transpiled and passing them through the files prop seems to make the babel transpiler do it again. You would think that running it through would not have much impact but it turns out it just generates errors.

Packages affected

  • [ ] sandpack-client
  • [x] sandpack-react

What is this feature?

I am proposing that a flag be added to the SandpackFile type to skip babel transpilation.

How would your idea work?

<Sandpack
  files={{
    '/public/jquery.min.js': {
      code: '/public/jquery.min.js',
      transpile: false,  // Default: true
    }
  }}
/>

S0ulDrag0n avatar Nov 11 '21 01:11 S0ulDrag0n

Hey @S0ulDrag0n thanks for letting us know about this issue. @DeMoorJasper do you think it's something doable? Curious to know how much effort it would require to implement it

danilowoz avatar Nov 11 '21 10:11 danilowoz

@danilowoz this is definitely doable and not a whole lot of work, was gonna work on related tasks anyway in a couple weeks. However this code would still be passed through our custom transformer that collects dependencies and rewrites import statements which uses acorn and it super-fast.

Or should it be more of an isolated module that can never have any dependencies?

Sounds very similar to #119 which we already support in the bundler

DeMoorJasper avatar Nov 11 '21 11:11 DeMoorJasper

Or should it be more of an isolated module that can never have any dependencies?

I think there's a chance that may be the case. Perhaps there should be another flag for skipping that as well?

S0ulDrag0n avatar Nov 11 '21 20:11 S0ulDrag0n

Yeah probably, for your example you can probably use externalResources for now, but we've added this feature request to the backlog, there's some bundler refactoring planned that will make this possible so will implement it once that is done.

DeMoorJasper avatar Nov 21 '21 09:11 DeMoorJasper

@danilowoz Is this issue still open?

amareshsm avatar Aug 24 '22 19:08 amareshsm

Yeah, this's a valid issue. However, it's not a priority now. Please thumbs up the main comment for those who are interested in this feature.

danilowoz avatar Aug 24 '22 21:08 danilowoz

+1 for skipping babel transpilation.

iampava avatar Aug 31 '23 11:08 iampava