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

cd(node): ban package.json main entry #9068

Merged
merged 3 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@
"node": ">=16.20.0"
},
"module": "./dist/index.mjs",
"main": "./dist/index.node.cjs",
"types": "./dist/index.d.ts",
"typesVersions": {
">=4.2": {
Expand Down
7 changes: 6 additions & 1 deletion test/unit/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading