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

Reassess package publication strategy #78

Closed
mike-marcacci opened this issue Jun 10, 2022 · 5 comments
Closed

Reassess package publication strategy #78

mike-marcacci opened this issue Jun 10, 2022 · 5 comments
Assignees
Labels
question Further information is requested

Comments

@mike-marcacci
Copy link
Owner

This library is currently only published as an ES module without a CommonJS counterpart. As a zero-dependency package, it had appeared less susceptible to the whiplash in guidance for migration to ES modules, and my hope was that doing so might enable consuming packages to leverage the benefits of this newer approach.

However, I want to make sure that this continues to follow best practice. I have a couple changes ready for release as v8.0.0 (most notably #76) but want to give @jaydenseric the chance to figure out if there is anything this library could do to improve the ability to be used here.

I'm not fully up-to-date on the ever-changing recommendations for how to designate the various types of package exports in node, so I wanted to open a conversation for anyone with insight or a strong preferences.

@jaydenseric
Copy link
Collaborator

I reckon publish the fix in #76 now as it is with pure ESM, then if we decide to add support for CJS consumers it can happen in a following version.

@jaydenseric
Copy link
Collaborator

@mike-marcacci are you able to publish the changes, or is there more work to be done?

@mike-marcacci
Copy link
Owner Author

My apologies – I meant to publish this after your last comment. I just published v8.0.0. I'm going to go ahead and close this issue as well, and we can reopen this if this need comes back up.

@jaydenseric
Copy link
Collaborator

jaydenseric commented Jul 22, 2022

The v8.0.0 changelog entry and GitHub release descriptions don't mention the fixes:

@douglas-wang
Copy link

@mike-marcacci , is there any common js support?

I am trying to use fs-capacitor in the following way and I am getting this weird error now.

import { ReadStream, ReadStreamOptions, WriteStream } from 'fs-capacitor'
Error [ERR_REQUIRE_ESM]: require() of ES Module .../node_modules/fs-capacitor/dist/index.js from .../server.ts not supported.
Instead change the require of index.js in .../server.ts to a dynamic import() which is available in all CommonJS modules.
...

I am using ts-node/ts-node-dev for the development and here is the tsconfig.json file.

{
  "compilerOptions": {
    "module": "commonjs",
    "incremental": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "declaration": true,
    "target": "ES2018",
    "noImplicitAny": true,
    "moduleResolution": "node",
    "sourceMap": true,
    "skipLibCheck": true,
    "outDir": "dist",
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "strict": true,
    "resolveJsonModule": true,
    "removeComments": true,
    "forceConsistentCasingInFileNames": true,
    "baseUrl": ".",
    "rootDir": "."
  },
  "include": ["src"],
  "exclude": ["node_modules/**", "dist"]
}

I am also using "module": "commonjs" in package.json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants