René's URL Explorer Experiment


Title: require is not defined · Issue #7 · ModuleLoader/node-es-module-loader · GitHub

Open Graph Title: require is not defined · Issue #7 · ModuleLoader/node-es-module-loader

X Title: require is not defined · Issue #7 · ModuleLoader/node-es-module-loader

Description: Given this snippet: import bodyParser from 'koa-bodyparser'; import Koa from 'koa'; const chalk = require('chalk'); the result when trying to load this module is: const chalk = require('chalk'); ^ require is not defined I understand from...

Open Graph Description: Given this snippet: import bodyParser from 'koa-bodyparser'; import Koa from 'koa'; const chalk = require('chalk'); the result when trying to load this module is: const chalk = require('chalk'); ^ ...

X Description: Given this snippet: import bodyParser from 'koa-bodyparser'; import Koa from 'koa'; const chalk = require('chalk'); the result when trying to load this module is: const chal...

Opengraph URL: https://github.com/ModuleLoader/node-es-module-loader/issues/7

X: @github

direct link

Domain: patch-diff.githubusercontent.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"require is not defined","articleBody":"Given this snippet:\r\n\r\n```js\r\nimport bodyParser from 'koa-bodyparser';\r\nimport Koa from 'koa';\r\n\r\nconst chalk = require('chalk');\r\n```\r\n\r\nthe result when trying to load this module is:\r\n\r\n```\r\nconst chalk = require('chalk');\r\n              ^\r\nrequire is not defined\r\n```\r\n\r\nI understand from this issue https://github.com/ModuleLoader/es-module-loader/issues/427 that the loader has made the assumption that the user only wants ES6 module support and not interoperability with require for CommonJS modules.\r\n\r\nWhile that is a perfectly good and reasonable argument for the es-module-loader module, the `node-esml` binary would imply by README description and name that there is a measure of interoperability with Node's current and default loader mechanisms. This would follow use of babel in node server-side code in which we're able to use `require` within ES6 modules.\r\n\r\nThe 'sync' nature of `require` can be duplicated using `async/await` patterns on the dynamic `import`, however that can only be used on node \u003e 7 with harmony flags, or node 7.6 - both of which are not yet options for a large chunk of developers due to restrictions in the workplace. \r\n\r\nI'd like to at the least point out this limitation and the perception that it _may_ be interpreted as a bug by folks not intimately familiar with loaders and/or es-module-loader. And I'd like to propose the interoperability with default node `require` support as a new feature.\r\n\r\nOr at the least, an updated README with a solution to provide support for `require`. If I'm missing something where require-like capabilities exist, such as the ability to load JSON files as objects, then please do consider adding those to the README, as I haven't found a suitable workaround as simplistic as requiring the file.","author":{"url":"https://github.com/shellscape","@type":"Person","name":"shellscape"},"datePublished":"2017-03-16T00:07:26.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/7/node-es-module-loader/issues/7"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:d0b72f78-0ec3-f28f-dc30-0e8ac250f0c7
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idDEE4:3128EA:C1089D:1100FC2:696FBA91
html-safe-nonce63c937cb22fcaed0db184e31a6cc70bed9ac751e72790b114a9c5fbdc52fb798
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERUU0OjMxMjhFQTpDMTA4OUQ6MTEwMEZDMjo2OTZGQkE5MSIsInZpc2l0b3JfaWQiOiI3NzE3Njc0MzMyNzc4OTA0MjA5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacab8ed58ba32ec10fce870f2bbe64049eaba21ae0fc75db77975e7c535bff6c93
hovercard-subject-tagissue:214562619
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/ModuleLoader/node-es-module-loader/7/issue_layout
twitter:imagehttps://opengraph.githubassets.com/7550435caf4f1e4db10e4b81d804eb094aad1c763b86b9f29c5f76f1146c3b81/ModuleLoader/node-es-module-loader/issues/7
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/7550435caf4f1e4db10e4b81d804eb094aad1c763b86b9f29c5f76f1146c3b81/ModuleLoader/node-es-module-loader/issues/7
og:image:altGiven this snippet: import bodyParser from 'koa-bodyparser'; import Koa from 'koa'; const chalk = require('chalk'); the result when trying to load this module is: const chalk = require('chalk'); ^ ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameshellscape
hostnamegithub.com
expected-hostnamegithub.com
None40ce4030a7db32193be29054756ed7f7eceec3a82973f060300035bdff8cf777
turbo-cache-controlno-preview
go-importgithub.com/ModuleLoader/node-es-module-loader git https://github.com/ModuleLoader/node-es-module-loader.git
octolytics-dimension-user_id4904197
octolytics-dimension-user_loginModuleLoader
octolytics-dimension-repository_id65407421
octolytics-dimension-repository_nwoModuleLoader/node-es-module-loader
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id65407421
octolytics-dimension-repository_network_root_nwoModuleLoader/node-es-module-loader
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release1cdcabe0d7ddc4be91a713d57280849e4c89f5cd
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/ModuleLoader/node-es-module-loader/issues/7#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2FModuleLoader%2Fnode-es-module-loader%2Fissues%2F7
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2FModuleLoader%2Fnode-es-module-loader%2Fissues%2F7
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=ModuleLoader%2Fnode-es-module-loader
Reloadhttps://patch-diff.githubusercontent.com/ModuleLoader/node-es-module-loader/issues/7
Reloadhttps://patch-diff.githubusercontent.com/ModuleLoader/node-es-module-loader/issues/7
Reloadhttps://patch-diff.githubusercontent.com/ModuleLoader/node-es-module-loader/issues/7
ModuleLoader https://patch-diff.githubusercontent.com/ModuleLoader
node-es-module-loaderhttps://patch-diff.githubusercontent.com/ModuleLoader/node-es-module-loader
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2FModuleLoader%2Fnode-es-module-loader
Fork 3 https://patch-diff.githubusercontent.com/login?return_to=%2FModuleLoader%2Fnode-es-module-loader
Star 28 https://patch-diff.githubusercontent.com/login?return_to=%2FModuleLoader%2Fnode-es-module-loader
Code https://patch-diff.githubusercontent.com/ModuleLoader/node-es-module-loader
Issues 1 https://patch-diff.githubusercontent.com/ModuleLoader/node-es-module-loader/issues
Pull requests 0 https://patch-diff.githubusercontent.com/ModuleLoader/node-es-module-loader/pulls
Actions https://patch-diff.githubusercontent.com/ModuleLoader/node-es-module-loader/actions
Projects 0 https://patch-diff.githubusercontent.com/ModuleLoader/node-es-module-loader/projects
Security Uh oh! There was an error while loading. Please reload this page. https://patch-diff.githubusercontent.com/ModuleLoader/node-es-module-loader/security
Please reload this pagehttps://patch-diff.githubusercontent.com/ModuleLoader/node-es-module-loader/issues/7
Insights https://patch-diff.githubusercontent.com/ModuleLoader/node-es-module-loader/pulse
Code https://patch-diff.githubusercontent.com/ModuleLoader/node-es-module-loader
Issues https://patch-diff.githubusercontent.com/ModuleLoader/node-es-module-loader/issues
Pull requests https://patch-diff.githubusercontent.com/ModuleLoader/node-es-module-loader/pulls
Actions https://patch-diff.githubusercontent.com/ModuleLoader/node-es-module-loader/actions
Projects https://patch-diff.githubusercontent.com/ModuleLoader/node-es-module-loader/projects
Security https://patch-diff.githubusercontent.com/ModuleLoader/node-es-module-loader/security
Insights https://patch-diff.githubusercontent.com/ModuleLoader/node-es-module-loader/pulse
require is not definedhttps://patch-diff.githubusercontent.com/ModuleLoader/node-es-module-loader/issues/7#top
https://github.com/shellscape
https://github.com/shellscape
shellscapehttps://github.com/shellscape
on Mar 16, 2017https://github.com/ModuleLoader/node-es-module-loader/issues/7#issue-214562619
ModuleLoader/es-module-loader#427https://github.com/ModuleLoader/es-module-loader/issues/427
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.