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

Use cjs extension for cjs entrypoint #72

Merged
merged 2 commits into from
Jul 12, 2023

Conversation

ling1726
Copy link
Contributor

@ling1726 ling1726 commented Jul 11, 2023

Updates entrypoints and export maps for cjs to parsel.min.cjs

Fixes #73

By using `"type": "module"` all cjs code needs to end with the correct
extension. Currently trying to use parsel-js as cjs results in this
error

```
ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/home/lingga/selector-lint/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at file:///home/lingga/selector-lint/test.js:1:16
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
    at async loadESM (node:internal/process/esm_loader:91:5)
    at async handleMainPromise (node:internal/modules/run_main:65:12)
```
@netlify
Copy link

netlify bot commented Jul 11, 2023

Deploy Preview for parsel ready!

Name Link
🔨 Latest commit 2b149ac
🔍 Latest deploy log https://app.netlify.com/sites/parsel/deploys/64ae9de485241000089ec86c
😎 Deploy Preview https://deploy-preview-72--parsel.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@LeaVerou
Copy link
Owner

LeaVerou commented Jul 11, 2023

Hey, thank you for contributing!

Fine with the change, though then we don't need a /cjs/ directory at all, we can just have them directly in /dist/.

Any thoughts @jrandolf ?

@ling1726
Copy link
Contributor Author

Hey, thank you for contributing!

Fine with the change, though then we don't need a /cjs/ directory at all, we can just have them directly in /dist/.

Any thoughts @jrandolf ?

Changing the dist folder output can happen anytime, right now the entire library is unusable by anyone that needs to compile to cjs - which unfortunately includes webpack 🥲

@ling1726 ling1726 changed the title fix: Use cjs extension for cjs entrypoing fix: Use cjs extension for cjs entrypoint Jul 12, 2023
@LeaVerou
Copy link
Owner

Sure, but isn't that a trivial change, since you're already working on this PR?

@ling1726
Copy link
Contributor Author

ling1726 commented Jul 12, 2023

Sure, but isn't that a trivial change, since you're already working on this PR?

Oh sure, didn't realize you were asking me to do it, throught you were starting a round of discussion 😅

Done in 2b149ac

@jrandolf-2 jrandolf-2 changed the title fix: Use cjs extension for cjs entrypoint fix: use cjs extension for cjs entrypoint Jul 12, 2023
@jrandolf-2 jrandolf-2 merged commit 61762b2 into LeaVerou:master Jul 12, 2023
4 checks passed
jrandolf-2 added a commit that referenced this pull request Jul 12, 2023
@jrandolf-2 jrandolf-2 changed the title fix: use cjs extension for cjs entrypoint Use cjs extension for cjs entrypoint Jul 12, 2023
@LeaVerou
Copy link
Owner

Sure, but isn't that a trivial change, since you're already working on this PR?

Oh sure, didn't realize you were asking me to do it, throught you were starting a round of discussion 😅

Done in 2b149ac

Nah, it was more a "any objections?" 😁
Thanks so much!

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.

parsel-js does not work with commonjs require
3 participants