Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content about nodejs loader #349

Merged
merged 12 commits into from
Nov 15, 2024
Merged

Content about nodejs loader #349

merged 12 commits into from
Nov 15, 2024

Conversation

AugustinMauroy
Copy link
Owner

No description provided.

@AugustinMauroy
Copy link
Owner Author

@JakobJingleheimer could you review this content. Second part, I mean second post will be how to use nodejs-loaders .


#### The `resolve` Hook

The `resolve` hook is responsible for determining the location of a module given a specifier. A specifier is the string or URL that you pass to `import` or `require`. For example, when you write `import 'some-module'`, the `resolve` hook helps Node.js figure out where `some-module` is located.
Copy link
Contributor

@JakobJingleheimer JakobJingleheimer Nov 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The `resolve` hook is responsible for determining the location of a module given a specifier. A specifier is the string or URL that you pass to `import` or `require`. For example, when you write `import 'some-module'`, the `resolve` hook helps Node.js figure out where `some-module` is located.
The `resolve` hook is responsible for determining the location of a module, given a specifier. A specifier is the string or URL that you pass to `import` or `require`. For example, when you write `import 'some-module'`, the `resolve` hook helps Node.js figure out where `some-module` is located.

technically, the thing you pass to require() is called an identifier (or "id").

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Humm yes but most of user will use and understand it as a "module" so I will take this as it

content/blog/how-to-use-nodejs-loader.en.mdx Outdated Show resolved Hide resolved
content/blog/how-to-use-nodejs-loader.en.mdx Show resolved Hide resolved
content/blog/how-to-use-nodejs-loader.en.mdx Outdated Show resolved Hide resolved
content/blog/how-to-use-nodejs-loader.en.mdx Outdated Show resolved Hide resolved

Loaders can be used to implement import maps, which allow you to define custom mappings for module specifiers. This can be useful for overriding the default behavior of `import` statements and `require` calls, making it easier to manage dependencies and module versions.

#### 6. Enabling Hot Module Replacement (HMR)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe HMR should be a loader we add to @nodejs/loaders 🤔

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iDK I saw that on nodejs/loaders repo

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm?

@AugustinMauroy
Copy link
Owner Author

@JakobJingleheimer wanna be added as author ?

@JakobJingleheimer
Copy link
Contributor

@JakobJingleheimer wanna be added as author ?

🥰 thank you, but you wrote 99.99% of this. I don't wanna steal your thunder.

@@ -15,7 +15,9 @@ const Codebox: FC<CodeboxProps> = async props => {
if (!isValidElement(props.children)) return null;

const code = props.children.props.children.trim();
const lang = props.children.props.className.replace('language-', '').replace('mjs', 'js');
const lang = props.children.props.className
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it seems wrong to use classname (but if that's how some tool works, sure)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have test it manually 😇
"I am the test runner"

content/blog/how-to-use-nodejs-loader.en.mdx Outdated Show resolved Hide resolved
content/blog/how-to-use-nodejs-loader.en.mdx Outdated Show resolved Hide resolved
Copy link
Contributor

@JakobJingleheimer JakobJingleheimer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

@AugustinMauroy
Copy link
Owner Author

Big thanks Jacob for your review

@JakobJingleheimer
Copy link
Contributor

You're welcome!

@AugustinMauroy AugustinMauroy merged commit 6ee4843 into main Nov 15, 2024
2 of 3 checks passed
@AugustinMauroy AugustinMauroy deleted the content-loader branch November 15, 2024 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants