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

build: convert .cjs to .js #547

Closed
wants to merge 1 commit into from
Closed

build: convert .cjs to .js #547

wants to merge 1 commit into from

Conversation

stephanos-square
Copy link

@stephanos-square stephanos-square commented Apr 26, 2023

Describe the problem this PR addresses

The code was using a mix of .js ("import") and .cjs ("require") files. This makes it impossible to use from Vite/Vitess and harder to migrate from CommonJS to ESM in the near future.

Describe the changes in this PR

This converts all .cjs files to .js. Most of the change involves just renaming the files and changing require to import and module.exports to export default. But the .postcssrc.js file required an extra build step. That's because it's not capable of dealing with imports (I tried using .mjs and .ts - which both failed). Now the code it needs is pre-bundled so it can be required.

Using the "Compare Directories" feature in IntelliJ to compare the build output before and after the change, we can see that the only files that changed are:

  • components/Theme/script.js
  • utils/maker-colors.js

Taking a closer look at these two, it appears that this change caused Webpack to bundle these two files slightly differently. But the content appears to effectively be the same.

@stephanos-square stephanos-square changed the title chore: convert .cjs to .js build: convert .cjs to .js Apr 26, 2023
@stephanos-square stephanos-square force-pushed the remove-cjs branch 6 times, most recently from c609e8c to e16f3c3 Compare April 26, 2023 16:17
@github-actions github-actions bot added the stale hasn't received any activity in a long time label Jul 28, 2023
@github-actions
Copy link

This PR has been automatically closed because it hasn't received any activity in over 3 months.

@github-actions github-actions bot closed this Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale hasn't received any activity in a long time
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant