mincho-js / mincho

Natural CSS in TypeScript
MIT License
40 stars 0 forks source link

Publish `debug-log` package #38

Closed black7375 closed 3 months ago

black7375 commented 3 months ago

Description

Package and release the internal tool debug-log.

Jeong-jj commented 3 months ago

Hi I found some problems when I publish Debug-log package,

1. project name

yarn install & yarn build proceeding was sccessfully finished, But after proceeding to yarn workspace @mincho-js/debug-log run publish, I got the following error

publish failed

So I changed project name mincho to mincho-js


2. Version matching about "pretify-deep-diff"

When we proceed yarn add @mincho-js/debug-log, we have to choose version of "pretify-deep-diff"

select version during install


3. CommonJS's require()

when I test const debugLogs = require("@mincho-js/debug-log") on node terminal

Uncaught:
Error [ERR_REQUIRE_ESM]: require() of ES Module D:\project_test\node_modules\chalk\source\index.js from D:\project_test\node_modules\@mincho-js\debug-log\dist\cjs\index.cjs not supported.
Instead change the require of index.js in D:\project_test\node_modules\@mincho-js\debug-log\dist\cjs\index.cjs to a dynamic import() which is available in all CommonJS modules.
    at Module.<anonymous> (D:\project_test\node_modules\@mincho-js\debug-log\dist\cjs\index.cjs:1:89) {
  code: 'ERR_REQUIRE_ESM'
}


4. Importing JSON modules

I got a warning message about importing JSON modules

(node:30428) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)

It could find when we use debug-log tools



Summary

black7375 commented 3 months ago

1. project name

Yes. It seems to be fully resolved once it is reflected in the lockfile.

2. Version matching about "pretify-deep-diff"

This is because we are using a patched version. Let's solve this by forking the project and deploying our patched version.

https://github.com/mincho-js/mincho/blob/4975f3afe25ea520e053c25016e5384e2bac63cf/packages/debug-log/package.json#L48-L54

3. CommonJS's require()

This rough prototype works well. (chalk, boxen convert to dynamic load)

But, You should have switched all your code to asynchronous. The tool was intended for internal use, so it's not worth the extra effort here.

IMO, We recommend using it as a dedicated ESM.

4. Importing JSON modules

See

black7375 commented 3 months ago

Now published. We only support ESM package.