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

Fix index.js mess in package.json #13

Open
meodai opened this issue Sep 26, 2021 · 5 comments
Open

Fix index.js mess in package.json #13

meodai opened this issue Sep 26, 2021 · 5 comments

Comments

@meodai
Copy link
Owner

meodai commented Sep 26, 2021

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 meodai changed the title Fix index.js mess in package.js Fix index.js mess in package.json Sep 26, 2021
@lihbr
Copy link
Contributor

lihbr commented Sep 27, 2021

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)

@meodai
Copy link
Owner Author

meodai commented Oct 6, 2021

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

@Apsysikal
Copy link

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?

@meodai
Copy link
Owner Author

meodai commented May 18, 2022

I'm lost

@error-four-o-four
Copy link

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.

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

No branches or pull requests

4 participants