guybedford / chomp

'JS Make' - parallel task runner for the frontend ecosystem with a JS extension system.
https://chompbuild.com
Apache License 2.0
138 stars 7 forks source link

JSX compilation broken #53

Closed fusionstrings closed 2 years ago

fusionstrings commented 2 years ago

Is there a way to enable jsx compilation? Seems to be broken after update. Probably due to this https://github.com/guybedford/chomp/pull/51 some configuration needs to be changed.

guybedford commented 2 years ago

Try running chomp swc:init to reconfigure SWC.

fusionstrings commented 2 years ago

Thanks for quick response I am getting following error after running swc:init.

Warning Implicitly using latest version (0.125.0) for https://deno.land/std/async/mod.ts
error: Uncaught Error: TOML.parse(,,multilineStringJoiner) must be passed, while the source including multi-line string, which started from line 37: run = """
    at mark.nowrap (https://jspm.dev/npm:@ltd/j-toml@1.25.0:301:16)
    at assignBasicString (https://jspm.dev/npm:@ltd/j-toml@1.25.0:1743:40)
    at assign (https://jspm.dev/npm:@ltd/j-toml@1.25.0:1991:11)
    at Root (https://jspm.dev/npm:@ltd/j-toml@1.25.0:2050:28)
    at parse (https://jspm.dev/npm:@ltd/j-toml@1.25.0:2240:18)
    at Module.parse (https://jspm.dev/npm:@ltd/j-toml@1.25.0:2258:6)
    at file:///var/folders/6f/9lqr5q0x7zd946t0x1kx090w0000gp/T/aa22a12d08e0484c80c75c2ad32c8aaa.ts:5:28
x :swc:init [1.719068031s]
Unable to complete all tasks.
guybedford commented 2 years ago

Weird, which version of Deno are you running?

fusionstrings commented 2 years ago

deno 1.18.2

using empty chompfile (assuming some problem parsing existing chompfile).

content of chompfile 

version = 0.1

running swc:init throughs following error.

➜  jspm-packages git:(package-details) ✗ ./chomp_new swc:init
🞂 :swc:init
SWC Chompfile Template Configuration Utility
No SWC template found, creating a new template...
Enter a name for the template (optional): 
Which folder do you want to build with SWC? [src] 
What file extension do you want to build from this folder? [.js] .jsx
Which folder do you want to output the built JS files to? [lib] 
error: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'push')
      chompfile.task.push(task);
                     ^
    at newTemplate (file:///var/folders/6f/9lqr5q0x7zd946t0x1kx090w0000gp/T/2d4c4f144fe340ff8c13b5df3bb7c1bf.ts:68:22)
    at async file:///var/folders/6f/9lqr5q0x7zd946t0x1kx090w0000gp/T/2d4c4f144fe340ff8c13b5df3bb7c1bf.ts:29:14
x :swc:init [10.558964632s]
Unable to complete all tasks.

It works if I select default

What file extension do you want to build from this folder? [.js] .
guybedford commented 2 years ago

@fusionstrings I've just pushed up a couple of changes, try again now.

fusionstrings commented 2 years ago

@guybedford Now it doesn't work on even default 🗡️ :D

➜  jspm-packages git:(package-details) ✗ ./chomp swc:init 
🞂 :swc:init
SWC Chompfile Template Configuration Utility
No SWC template found, creating a new template...
Enter a name for the template (optional): 
Which folder do you want to build with SWC? [src] 
What file extension do you want to build from this folder? [.js] 
Which folder do you want to output the built JS files to? [lib] 
error: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'push')
      chompfile.task.push(task);
                     ^
    at newTemplate (file:///var/folders/6f/9lqr5q0x7zd946t0x1kx090w0000gp/T/bf89e04006a546b1a0a1f8f85fcd4c64.ts:68:22)
    at async file:///var/folders/6f/9lqr5q0x7zd946t0x1kx090w0000gp/T/bf89e04006a546b1a0a1f8f85fcd4c64.ts:29:14
x :swc:init [3.417547667s]
Unable to complete all tasks.
guybedford commented 2 years ago

Should be working now.

fusionstrings commented 2 years ago

now the init file is generated but jsx still not compiling. Throwing syntax parsing error as before... Similar to following

error: Expected '>', got 'class'

  |
7 |       <div class="footer-container">
  |            ^^^^^
guybedford commented 2 years ago

Can you share the chompfile?

fusionstrings commented 2 years ago

This is autogenerated one, just added name to task.

version = 0.1
task = [
    { name = 'jsx', dep = 'src/#.jsx', target = 'lib/#.js', template = 'swc', template-options.auto-install = true, template-options.config.'jsc.target' = 'es2016' },
]
guybedford commented 2 years ago

It seems like SWC doesn't like syntax: 'typescript' as well as JSX.

Try changing syntax: 'typescript' to syntax: 'ecmascript'. I'm not quite sure why it's doing this.

fusionstrings commented 2 years ago

this has same result

version = 0.1
task = [
    { name = 'jsx', dep = 'src/#.jsx', target = 'lib/#.js', template = 'swc', template-options.auto-install = true, template-options.config.'jsc.target' = 'es2016', template-options.config.'jsc.parser.syntax' = 'ecmascript' },
]
guybedford commented 2 years ago

You need the jsc.parser.jsx = true line as well.

guybedford commented 2 years ago

Btw how did you get the task to output as an array like that!? What version of Deno are you on?

guybedford commented 2 years ago

Weird, it seems it does that for that change we made - I'm fixing this now.

fusionstrings commented 2 years ago

You need the jsc.parser.jsx = true line as well.

Yay, this worked. Many many thanks 🙏

fusionstrings commented 2 years ago

Btw how did you get the task to output as an array like that!? What version of Deno are you on?

It's generated by default this way. I used empty chompfile with only version declaration at the top.

chomp --format changes this to something else.

I am using deno 1.18.2

guybedford commented 2 years ago

Ok I've followed this up in https://github.com/LongTengDao/j-toml/issues/15 and https://github.com/swc-project/swc/issues/3458. I've pushed the best workarounds for now.

guybedford commented 2 years ago

This is now fully fixed.