You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying use ESM with Gatsby community edition v3, but it does not work as I expected. I found a workaround using this command "npx --node-arg '-r esm' gatsby build", however I would like to use the recommendation from Gatsby by using "gatsby-ssr.esm.js".
Next rename your gatsby-ssr.js file to gatsby-ssr.esm.js. Then refactor the contents of the file to ES6 module syntax like this:
importReactfrom"react"exportfunctiononRenderBody({ pathname }){// solve pathname and add some content to script or style tags in HTMLconsole.log('pathname',pathname);}
Now create a new gatsby-ssr.js file and add the following content:
This discussion was converted from issue #31025 on April 23, 2021 20:26.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Description
I'm trying use ESM with Gatsby community edition v3, but it does not work as I expected. I found a workaround using this command
"npx --node-arg '-r esm' gatsby build"
, however I would like to use the recommendation from Gatsby by using"gatsby-ssr.esm.js"
.Steps to reproduce
esm
(npm i esm
)gatsby-ssr.js
file togatsby-ssr.esm.js
. Then refactor the contents of the file to ES6 module syntax like this:gatsby-ssr.js
file and add the following content:Expected result
After run
gatsby build
orgatsby develop
the process should consider the filegatsby-ssr.esm.js
but it doesn't happens.console.log
never run.Actual result
gatsby-ssr.esm.js
is ignoredEnvironment
Beta Was this translation helpful? Give feedback.
All reactions