From 682acc11ec1942fa4e348310a24fbd85d8c124d5 Mon Sep 17 00:00:00 2001 From: ShaMan123 Date: Thu, 6 Jul 2023 21:13:32 +0900 Subject: [PATCH 1/3] cd(node): ban `package.json` main entry --- package.json | 2 +- test/unit/env.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f8f7b1b8237..2f8ebdc3e49 100644 --- a/package.json +++ b/package.json @@ -131,7 +131,7 @@ "node": ">=16.20.0" }, "module": "./dist/index.mjs", - "main": "./dist/index.node.cjs", + "main": null, "types": "./dist/index.d.ts", "typesVersions": { ">=4.2": { diff --git a/test/unit/env.js b/test/unit/env.js index 315c7b65300..c5b8d171518 100644 --- a/test/unit/env.js +++ b/test/unit/env.js @@ -5,12 +5,17 @@ QUnit.module('env', (hooks) => { delete global.document; }) + QUnit.test('import/require of `main` field of package.json throws', assert => { + assert.rejects(import('../..'), 'should not resolve main'); + assert.throws(() => require('../..'), 'should not resolve main'); + }); + QUnit.test('import/require sets env', async assert => { const done = assert.async(); global.window = { devicePixelRatio: 1.25 }; global.document = { foo: 'bar' }; const imported = await import('../../dist/index.node.cjs'); - const required = require('../..'); + const required = require('../../dist/index.node.cjs'); assert.equal(imported.getEnv().document.foo, undefined, 'should be node env'); assert.equal(required.getEnv().document.foo, undefined, 'should be node env'); done(); From 9a0d062f3cfed8853a778b3d0dd477ba7d7c5cf2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 6 Jul 2023 12:16:10 +0000 Subject: [PATCH 2/3] update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73abd57bad1..d586c5b96d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -99,6 +99,7 @@ - ci(): properly checkout head for stats [#9080](https://github.com/fabricjs/fabric.js/pull/9080) - fix(Text): `_getFontDeclaration` wasn't considering fontFamily from the style object [#9082](https://github.com/fabricjs/fabric.js/pull/9082) - chore(TS): Fix ITextBehaviour enterEditing type [#9075](https://github.com/fabricjs/fabric.js/pull/9075) +- cd(node): ban `package.json` main entry [#9068](https://github.com/fabricjs/fabric.js/pull/9068) - chore(TS): export FabricObjectProps and GroupProps [#9025](https://github.com/fabricjs/fabric.js/pull/9025) - chore(TS): Replace BaseFabricObject with FabricObject [#9016](https://github.com/fabricjs/fabric.js/pull/9016) - refactor(svgImport): remove the css/gradient/clipPath global definitions [#9030](https://github.com/fabricjs/fabric.js/pull/9030) From 5e212da0fd6903f16b9f2df59bab6d7c9a51162a Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Tue, 12 Dec 2023 00:23:49 +0100 Subject: [PATCH 3/3] remove main from package.json --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 2f8ebdc3e49..d92ccb77e7a 100644 --- a/package.json +++ b/package.json @@ -131,7 +131,6 @@ "node": ">=16.20.0" }, "module": "./dist/index.mjs", - "main": null, "types": "./dist/index.d.ts", "typesVersions": { ">=4.2": {