fettepalette icon indicating copy to clipboard operation
fettepalette copied to clipboard

Fix index.js mess in package.json

Open meodai opened this issue 3 years ago • 5 comments

in parcel 1.x I have to

import {
  generateRandomColorRamp
} from 'fettepalette/dist/index';

to make it work.

in vanilla node it works fine:


import {
  generateRandomColorRamp
} from 'fettepalette'

canvas-sketch uses browserify const {generateRandomColorRamp} = require('fettepalette');

only returns an empty object

meodai avatar Sep 26 '21 19:09 meodai

Hey, maybe it's due to Parcel preferring the "additional new" exports key, so maybe adding something like this to the package would do:

"exports": {
	".": {
		"require": "./dist/index.js",
		"import": "./dist/index.esm.js"
	},
	"./package.json": "./package.json"
}

(you can give it a try before publishing by editing the package.json inside your node_modules on a test project)

lihbr avatar Sep 27 '21 07:09 lihbr

@lihbr thanks so much! I managed to fix it. I now have a build.js script that is easier to modify

meodai avatar Oct 06 '21 11:10 meodai

I had to fix the imports using the following additions/modifications to the package.json file in the node_modules/ folder. I described it aswell in #17.

...,
"exports": {
    "require": "./dist/index.cjs",
    "import": "./dist/index.mjs"
},
...

This worked for me and I'm using it as described. Does anyone have the time to test it aswell?

Apsysikal avatar Apr 26 '22 06:04 Apsysikal

I'm lost

meodai avatar May 18 '22 07:05 meodai

hey there, maybe it's worthwile to take a look at 'vite.js' which has a library mode. it really simplifies the developing and bundling process.

error-four-o-four avatar Aug 07 '22 05:08 error-four-o-four