Skip to content

Commit b1ded31

Browse files
committed
feat: improve esm support
1 parent adb12f1 commit b1ded31

File tree

33 files changed

+138
-193
lines changed

33 files changed

+138
-193
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,22 @@ jobs:
99
strategy:
1010
matrix:
1111
os: [ubuntu-latest, windows-latest, macos-latest]
12-
node: ["18"]
12+
node: ["20"]
1313

1414
steps:
1515
- name: Code checkout
16-
uses: actions/checkout@v2
17-
18-
- name: Setup pnpm
19-
uses: pnpm/action-setup@v2
20-
with:
21-
version: 8
16+
uses: actions/checkout@v4
2217

2318
- name: Setup node
24-
uses: actions/setup-node@v2
19+
uses: actions/setup-node@v4
2520
with:
2621
node-version: ${{ matrix.node }}
27-
cache: "pnpm"
22+
cache: npm
2823

2924
- name: Install dependencies
30-
run: |
31-
pnpm -v
32-
pnpm config set enable-pre-post-scripts true
33-
pnpm i --frozen-lockfile
34-
env:
35-
CI: true
25+
run: npm ci
3626

3727
- name: Test
38-
run: pnpm t
28+
run: npm run test
3929
env:
40-
CI: true
30+
NODE_OPTIONS: --experimental-vm-modules

.github/workflows/cov.yml

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,23 @@ jobs:
88

99
steps:
1010
- name: Code checkout
11-
uses: actions/checkout@v2
11+
uses: actions/checkout@v4
1212
with:
1313
fetch-depth: 0
1414

15-
- name: Setup pnpm
16-
uses: pnpm/action-setup@v2
17-
with:
18-
version: 8
19-
2015
- name: Setup node
21-
uses: actions/setup-node@v2
16+
uses: actions/setup-node@v4
2217
with:
23-
node-version: "16"
24-
cache: "pnpm"
18+
node-version: 20
19+
cache: npm
2520

2621
- name: Install dependencies
27-
run: |
28-
pnpm -v
29-
pnpm config set enable-pre-post-scripts true
30-
pnpm i --frozen-lockfile
31-
env:
32-
CI: true
22+
run: npm ci
3323

3424
- name: Test /w coverage
35-
run: pnpm t -- --coverage
25+
run: npm run test -- --coverage
3626
env:
37-
CI: true
27+
NODE_OPTIONS: --experimental-vm-modules
3828

3929
- name: Submit coverage to codecov.io
4030
uses: codecov/codecov-action@v2

.github/workflows/release.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@ jobs:
1515
- name: Setup node
1616
uses: actions/setup-node@v4
1717
with:
18-
node-version: 18
18+
node-version: 20
1919
cache: npm
2020

2121
- name: Install dependencies
2222
run: npm ci
23-
env:
24-
CI: true
2523

2624
- name: Release
2725
run: npm run release

__tests__/__snapshots__/index.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ exports[`basic resolvers: css 1`] = `
184184
}
185185
186186
.foo3 {
187-
background-image: url("/pubpath/bg.png?query#hash");
187+
background-image: url("./bg.png?query#hash");
188188
}
189189
@import url("https://fonts.googleapis.com/css?family=Gudea:400,700");
190190
.bar {
@@ -235,7 +235,7 @@ exports[`basic resolvers-hash: css 1`] = `
235235
}
236236
237237
.foo3 {
238-
background-image: url("/pubpath/bg-bd25d3fd.png?query#hash");
238+
background-image: url("./bg.png?query#hash");
239239
}
240240
@import url("https://fonts.googleapis.com/css?family=Gudea:400,700");
241241
.bar {
@@ -286,7 +286,7 @@ exports[`basic resolvers-url-inline: css 1`] = `
286286
}
287287
288288
.foo3 {
289-
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGYAAABmBAMAAADL8flRAAAAG1BMVEXMzMyWlpacnJy+vr6jo6PFxcW3t7eqqqqxsbHbm8QuAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAArUlEQVRYhe3QIQ+CUBTF8cPTB8RHsKMTqQQ/gMqmVRkj4+ZmZQRnNBD42F7Afp3N7fxIN/zH2wGIiIiI6J8ZBKk95NMRo23KdaYksz36oKtv47F14et59HdKY69I7AoX9PMMlTPnIrZOe5sHJ18Hc5fDeXKH2n+mpmzgLz6NPWmJNIlNNkA4NvK2ov6ikQ1kqWKYYdggVxNpgtREER6ygTyzbZaRugERERER/eYNUMwTiwsgIHkAAAAASUVORK5CYII=");
289+
background-image: url("./bg.png?query#hash");
290290
}
291291
@import url("https://fonts.googleapis.com/css?family=Gudea:400,700");
292292
.bar {

__tests__/fixtures/resolvers/style.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
font-family: "Demo";
88
font-style: normal;
99
font-weight: 400;
10-
src: local("Demo"), local("Demo-Regular"), url("fonts/Demo-webfont.woff") format("woff");
10+
src:
11+
local("Demo"),
12+
local("Demo-Regular"),
13+
url("fonts/Demo-webfont.woff") format("woff");
1114
}
1215

1316
.ignore-data-uri {
File renamed without changes.

__tests__/helpers/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import { Plugin, rollup, InputOptions, OutputOptions } from "rollup";
66
import styles from "../../src";
77
import { Options } from "../../src/types";
88
import { inferModeOption, inferSourceMapOption } from "../../src/utils/options";
9+
import { fileURLToPath } from "url";
10+
11+
const baseDir = path.dirname(fileURLToPath(import.meta.url));
912

1013
export interface WriteData {
1114
input: string | string[];
@@ -36,7 +39,7 @@ async function pathExistsAll(files: string[]): Promise<boolean> {
3639
}
3740

3841
export const fixture = (...args: string[]): string =>
39-
path.normalize(path.join(__dirname, "..", "fixtures", ...args));
42+
path.normalize(path.join(baseDir, "..", "fixtures", ...args));
4043

4144
export async function write(data: WriteData): Promise<WriteResult> {
4245
const outDir = fixture("dist", data.outDir ?? data.title ?? "");
@@ -48,7 +51,7 @@ export async function write(data: WriteData): Promise<WriteResult> {
4851
plugins: data.plugins ?? [styles(data.options)],
4952
onwarn: (warning, warn) => {
5053
if (warning.code === "EMPTY_BUNDLE") return;
51-
if (warning.plugin === "lit") return;
54+
if (warning.exporter === "lit") return;
5255
if (/Exported `\S+` as `\S+` in \S+/.test(warning.message)) return;
5356
warn(warning);
5457
},

__tests__/setup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
import { jest } from "@jest/globals";
12
export {}; // fixes "isolatedModules" warning
23
jest.setTimeout(30_000);

0 commit comments

Comments
 (0)