Set babel config to use commonjs modules on server#61
Open
penx wants to merge 2 commits intoreactjs:mainfrom
Open
Set babel config to use commonjs modules on server#61penx wants to merge 2 commits intoreactjs:mainfrom
penx wants to merge 2 commits intoreactjs:mainfrom
Conversation
Previously, if you had
```js
export default function App({
selectedId,
isEditing,
searchText,
something = ['a', 'b'],
}) {
const [a, b] = something;
console.log(a, b);
```
this would error with
```console
internal/modules/cjs/loader.js:1102
throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
^
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /rsc/server-components-demo/node_modules/@babel/runtime/helpers/esm/slicedToArray.js
require() of ES modules is not supported.
```
This updates the babel config on the server to use `useESModules: false`
The package lock in the repository is v2. Using fermium (14) sets it back to v1. Instead, update the version of node in .nvmrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #60
Previously, if you had
this would error with
This updates the babel config on the server to use
useESModules: false