Closed robdodson closed 2 years ago
Are you able to statically import layout.jsx and post.jsx just fine without receiving the error? Try with the plugin setup in the config and without if it fails with. I know vue has its own plugin so not sure if there a difference here that is causing this issue. From what I remember it should see the imports when it processes the file and use whatever loader/plugin that is setup to handle it.
On more thought I recall this issue a bit more, the reason this worked fine for me is my filter was for .js files that dynamically imported .vue files. Overall problem as I remember it is your filter is setup to use .jsx, esbuild is not passing it off to the builtin .jsx loader. I will look into if esbuild has a any new updates or recommended ways around this now.
Hoping version 0.2.0 will fix this issue, you will need to add the loader property you the config and set it to 'jsx'. i.e. Thought about trying to grab it from the filter regex but seemed to error prone. Could maybe try to do that, but still allow the user to overwrite with the config.
plugins: [
DynamicImport({
transformExtensions: ['.jsx'],
changeRelativeToAbsolute: true,
filter: /.*\.jsx$/,
loader: 'jsx'
}),
Hi, thank you for putting together this plugin!
I've been trying to get it to dynamically import jsx files but haven't quite got it to work and was hoping you could give me some advice.
The error I get is:
I've enabled the loader in my build file so I'm not sure what I'm missing. I was wondering if the plugin might need to pass this information along somehow? Here is what I have:
esbuild.config.js
And here is the file that contains the dynamic import:
app.jsx
I was able to log the fileContents that the plugin generates and it looks correct, but it seems like when esbuild runs against this file it doesn't know to use the jsx loader. Any help is much appreciated!