Skip to content

Commit 215fd7e

Browse files
committed
fix: update bundling config
1 parent c8287e0 commit 215fd7e

File tree

9 files changed

+60
-30
lines changed

9 files changed

+60
-30
lines changed

.changeset/tangy-singers-film.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"cssom-gen": patch
3+
---
4+
5+
fix ts config for cjs bundling

pnpm-lock.yaml

Lines changed: 32 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/entities/CSSStyleSheet.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
// biome-ignore lint/suspicious/noTsIgnore: no types available for this package
2-
// @ts-ignore-next-line no-restricted-globals
3-
import Window from 'window';
4-
import type { CSSComment } from './CSSComment';
1+
import global from '../global.js';
2+
import type { CSSComment } from './CSSComment.js';
53

6-
const window = new Window();
7-
8-
interface CSSStyleSheetInit extends Window.CSSStyleSheetInit {
4+
// TODO: figure out how to properly extend globalThis in a way that is compatible with both Node.js and the browser.
5+
interface CSSStyleSheetInit extends globalThis.CSSStyleSheetInit {
96
nodes: CSSComment[];
107
}
118

12-
export class CSSStyleSheet extends window.CSSStyleSheet {
9+
export class CSSStyleSheet extends global.CSSStyleSheet {
1310
nodes: CSSComment[];
1411

1512
constructor(options: CSSStyleSheetInit) {

src/entities/__tests__/CSSComment.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from 'vitest';
2-
import { CSSComment } from '../CSSComment';
2+
import { CSSComment } from '../CSSComment.js';
33

44
describe('CSSComment', () => {
55
it('should create a comment', () => {

src/entities/__tests__/CSSStyleSheet.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, expect, it } from 'vitest';
2-
import { CSSComment } from '../CSSComment';
3-
import { CSSStyleSheet } from '../CSSStyleSheet';
2+
import { CSSComment } from '../CSSComment.js';
3+
import { CSSStyleSheet } from '../CSSStyleSheet.js';
44

55
describe('CSSStyleSheet', () => {
66
it('should create a stylesheet', () => {

src/global.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// biome-ignore lint/suspicious/noTsIgnore: no types available for this package
2+
// @ts-ignore-next-line no-restricted-globals
3+
import Window from 'window';
4+
5+
// TODO: figure out how to properly extend globalThis in a way that is compatible with both Node.js and the browser.
6+
const global: typeof globalThis = new Window();
7+
8+
export default global;

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export * from './entities/CSSComment';
2-
export * from './entities/CSSStyleSheet';
1+
export * from './entities/CSSComment.js';
2+
export * from './entities/CSSStyleSheet.js';

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"declarationMap": true,
55
"erasableSyntaxOnly": true,
66
"lib": ["DOM", "ESNext"],
7-
"module": "preserve",
8-
"moduleResolution": "bundler",
7+
"module": "NodeNext",
8+
"moduleResolution": "NodeNext",
99
"noFallthroughCasesInSwitch": true,
1010
"noUncheckedIndexedAccess": true,
1111
"noUnusedLocals": true,

vitest.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { defineConfig } from 'vitest/config';
22

33
export default defineConfig({
4-
test: {},
4+
test: {
5+
environment: 'node',
6+
},
57
});

0 commit comments

Comments
 (0)