Code Monkey home page Code Monkey logo

Comments (6)

milesj avatar milesj commented on May 26, 2024

@wespickett This is true for:

[
	{
		"format": "esm"
	},
	{
		"format": "lib"
	}
]

But not:

{
	"format": ["esm", "lib"]
}

But regardless, exports are deep-merged from all artifacts.

from packemon.

wespickett avatar wespickett commented on May 26, 2024

@milesj

https://github.com/wespickett/packemon-test1

Steps:
npm install
cd packages/example1
npm run build

Expected:

  "exports": {
    "./package.json": "./package.json",
    ".": {
      "browser": {
        "types": "./esm/index.d.ts",
        "module": "./esm/index.js",
        "import": "./esm/index.js",
        "default": "./lib/index.js" <==== This is missing
      },
      "node": {
        "types": "./lib/index.d.ts",
        "default": "./lib/index.js"
      },
      "default": "./lib/index.js"
    }
  }

Actual:

  "exports": {
    "./package.json": "./package.json",
    ".": {
      "browser": {
        "types": "./esm/index.d.ts",
        "module": "./esm/index.js",
        "import": "./esm/index.js"
      },
      "node": {
        "types": "./lib/index.d.ts",
        "default": "./lib/index.js"
      },
      "default": "./lib/index.js"
    }
  }

from packemon.

milesj avatar milesj commented on May 26, 2024

@wespickett That's unfortunately correct... lib is configured for node, and shouldn't appear under browser.

Are you actually having issues with this? browser is used by bundlers, nothing else, and would either use require/import anyways.

from packemon.

wespickett avatar wespickett commented on May 26, 2024

@milesj yes, the issue is happening with jest, since we have 'browser' in the conditions list in the config. The previously published version of the packages (using packemon 2.x) do have the exports[path].browser.default key setup correctly, so this appears to be a regression

from packemon.

milesj avatar milesj commented on May 26, 2024

@wespickett v2 was actually wrong IMO.

Is browser really required in Jest? Browser is almost always ESM code, which isn't compatible with Jest. I always configure Jest to use node/cjs.

from packemon.

wespickett avatar wespickett commented on May 26, 2024

Removed the browser condition, and also changed the packemon configs to be ["esm", "lib"] for the browser platforms so the cjs code is generated for the defaults

from packemon.

Related Issues (20)

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.