This content is in progress and is expected to continue to evolve.

Publishing JavaScript and TypeScript

Notes

  • When using a dist directory, it may be ignored when you go to publish. You can run npm publish --dry-run to test which files are included.
    • The .gitignore is generally respected as a default.
    • If you use the files: [] option in package.json, you may specify the dist directory there.
    • If you specify the main property as dist/index.js, then it will include the whole directory even without a files: [].
  • The main property supports "old node".
    • It seems that webpack4 does not use this in file resolution, but webpack5 does. This means if publishing with a dist folder with "main": "dist" then import { invoke } from "@tauri-apps/api/tauri" won't work in webpack4 but import { invoke } from "@tauri-apps/api/dist/tauri" will work for a scoped package called @tauri-apps/api.

Links

General

  • https://dev.to/garylchew/bringing-modern-javascript-to-libraries-432c
  • https://twitter.com/MylesBorins/status/1364768015372472333 then https://twitter.com/MylesBorins/status/1364770368519602176 and finally https://twitter.com/MylesBorins/status/1364771129387270147 https://blog.sindresorhus.com/get-ready-for-esm-aa53530b3f77

JavaScript

  • https://twitter.com/_developit/status/1347296236282523648
  • https://github.com/evanw/esbuild/issues/187#issuecomment-756456336
  • Webpack5 Exports

TypeScript

https://twitter.com/_developit/status/1347306689264033795 https://github.com/microsoft/TypeScript/issues/33079