Code Monkey home page Code Monkey logo

commonify's Introduction

I create free and open source software because I believe that software should be available to everyone, without having to sell your soul to data mining corporations.

  • ๐Ÿ”ฅ cloudwatch-winston - Robust and simple Winston transport for AWS CloudWatch Logs
  • ๐Ÿ”ฅ mjml-dynamic - Include dynamic MJML content via JSON
  • cognito-backup - AWS missing backup tool for Cognito User Pools.

๐ŸŒ www.mifi.no

commonify's People

Contributors

mifi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

danielegarciav

commonify's Issues

Can't be imported from CommonJS and/or instructions not clear?

This is a really neat idea! However, my first attempt at forking a package and republishing it (by following the instructions in the README.md) resulted in the following error when I tried to run my CJS project using the package I just forked:

/node_modules/@vallerance/globby/index.js:1
import fs from 'node:fs';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1031:15)
    at Module._compile (node:internal/modules/cjs/loader:1065:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.@vallerance/globby (/home/joshua/WebDev/projects/no-code/dist/packages/tsc-compilers/main.js:606:18)
    at __webpack_require__ (/home/joshua/WebDev/projects/no-code/dist/packages/tsc-compilers/main.js:672:41)

This was because index.js had ESM style code.

I figured out I could solve this by doing the following for each forked package:

cd package/
cp ../transpiled ./

This replaced the ESM style code with CJS style code. From there, I could simply increment the version and republish. This resolved the error I was getting from my project and it ran fine with the forked packages.

I'm not sure if this is a bug in this project somewhere, or if maybe the instructions weren't clear (or maybe missing a step).

Idea for handling automatic updates

Maybe projects that have been run through commonify could make use of something like GitHub Actions to run a cron job automatically to find new versions, commonify them, and publish them. Mainly submitting this issue for feedback on the idea, if people think it's a good idea I can probably submit a PR sometime soon adding this.

you did replicate something existing.

https://www.npmjs.com/package/@vercel/ncc

is pritty capable of solving your cjs versions generation on a project base you will never want to publish the CJS dependencies you should adopt the following pattern.

you create so called dev bundels of your dependencies so your dependencies get a own package.json and bundler config then you run that only when you add or remove external dependencies to your project.

then you use the resulting bundle in your main project. and also commit that to the main project as it is a required dependencie

this is called a dev-bundle.

Short version

You should avoid publishing your own CJS dependencies as packages. you should bundle them and commit that bundle to your main project and create a indipendent package or project to build only your external dependencies as CJS modules.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.