Skip to content

šŸ¤– Modern Module is a zero-config modern npm package starter template. šŸŒ 

License

Notifications You must be signed in to change notification settings

igorskyflyer/npm-modern-module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Ā 

History

45 Commits
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 

Repository files navigation

šŸ¤– Modern Module šŸŒ 

šŸ¤– Modern Module is a zero-config starter template that allows you to create modern npm packages with support for both CommonJS modules (Node) and ES modules (browser + Node) out of the box providing no-hassle modern creating of modules. šŸŒ 


By using it you are creating a hybrid-module and a cross-over until ES modules become a standard in Node too and CommonJS modules become obsolete. šŸ¤øā€ā™‚ļø


Features

šŸŒ·Ā Ā Node support,
Ā Ā Ā Ā Ā Ā Ā Ā CommonJS modules and ES modules compatible

šŸ’«Ā Ā browser supportĀ¹ - ES modules compatible,
Ā Ā Ā Ā Ā Ā Ā Ā other module systems are available too

āš”Ā Ā zero-config,

šŸ”„Ā Ā JavaScript supported,

ā˜„ļøĀ Ā TypeScript supported,

šŸŒŸĀ Ā modules interoperability,

šŸŒ“Ā Ā tree-shaking supported,

šŸŒŠĀ Ā single codebase for you to mantain,

šŸ¦Ā Ā codebase written in ES modules style,

šŸ¦œĀ Ā type-checked codebase,

šŸ³Ā Ā TypeScript declarations (*.d.ts) exported by default,

šŸ¦˜Ā Ā transpilation supported.


Ā¹ - if you don't use Node-specific code, of course.



šŸ™‹ā€ā™‚ļøĀ For compatibility reasons this starter usesĀ .jsĀ file extension for the ES modules code andĀ .cjsĀ for CommonJS module code which in turn allows ES modules to be consumed by both Node and compatible browsers while also fixing a Node module lookup issue which currently occurs in Visual Studio Code and probably other Node-compatible editors/IDEs causing them to show an error when importingĀ .mjsĀ modules. CommonJS modulesĀ .cjsĀ behave as expected. Also, TypeScript compiler doesn't support non-.jsĀ files when generatingĀ d.tsĀ declaration files.

Another thing to consider, when consuming ES modules, (most) servers are not configured to serve .mjs files with a mime type of application/javascript which is necessary for JavaScript files (including modules) to work properly while the same does not happen when ES modules have the "regular" .js extension.