Skip to content

Commit

Permalink
docs(config): added type : "module" to the package.json in getting …
Browse files Browse the repository at this point in the history
…started section section

The getting started doc's package.json was missing `type:"module"` setting. Because of that the users following the docs get error at the import statements.
  • Loading branch information
RajeevPullat committed Jan 11, 2025
1 parent 35023e3 commit a7d6ccd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/content/guides/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ contributors:
- d3lm
- snitin315
- Etheryen
- RajeevPullat
---

Webpack is used to compile JavaScript modules. Once [installed](/guides/installation), you can interact with webpack either from its [CLI](/api/cli) or [API](/api/node). If you're still new to webpack, please read through the [core concepts](/concepts) and [this comparison](/comparison) to learn why you might use it over the other tools that are out in the community.
Expand Down Expand Up @@ -111,6 +112,7 @@ T> If you want to learn more about the inner workings of `package.json`, then we
"description": "",
- "main": "index.js",
+ "private": true,
+ "type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand All @@ -134,6 +136,8 @@ There are problems with managing JavaScript projects this way:

Let's use webpack to manage these scripts instead.

T> The `type: module` in the package.json is required to enable ES module import statements in .js files by telling Node.js to treat them as ES modules instead of the default CommonJS modules.

## Creating a Bundle

First we'll tweak our directory structure slightly, separating the "source" code (`./src`) from our "distribution" code (`./dist`). The "source" code is the code that we'll write and edit. The "distribution" code is the minimized and optimized `output` of our build process that will eventually be loaded in the browser. Tweak the directory structure as follows:
Expand Down

0 comments on commit a7d6ccd

Please sign in to comment.