Skip to content

Commit 281347c

Browse files
fix: support for ESM
1 parent f659533 commit 281347c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+350
-10
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

example/cjs/jest.config.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const fs = require('node:fs');
2+
const path = require('node:path');
3+
const { createJestStencilPreset } = require('jest-stencil-runner');
4+
5+
// Resolve symlinks to their actual paths
6+
const srcPath = path.resolve(__dirname, 'src');
7+
const realSrcPath = fs.existsSync(srcPath) ? fs.realpathSync(srcPath) : srcPath;
8+
9+
module.exports = {
10+
...createJestStencilPreset({
11+
rootDir: __dirname,
12+
}),
13+
// Add the real path to the roots so Jest can find files through symlinks
14+
roots: [__dirname, realSrcPath],
15+
// Disable watchman as it doesn't handle symlinks well
16+
watchman: false,
17+
};

example/cjs/package.json

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"name": "example-cjs",
3+
"version": "0.0.1",
4+
"description": "Stencil Component Starter",
5+
"type": "commonjs",
6+
"license": "MIT",
7+
"repository": {
8+
"type": "git",
9+
"url": "https://github.com/stenciljs/component-starter.git"
10+
},
11+
"files": [
12+
"dist/",
13+
"loader/"
14+
],
15+
"main": "dist/index.cjs.js",
16+
"module": "dist/index.js",
17+
"types": "dist/types/index.d.ts",
18+
"collection": "dist/collection/collection-manifest.json",
19+
"collection:main": "dist/collection/index.js",
20+
"exports": {
21+
".": {
22+
"require": "./dist/example/example.cjs.js",
23+
"import": "./dist/example/example.esm.js"
24+
},
25+
"./my-component": {
26+
"types": "./dist/components/my-component.d.ts",
27+
"import": "./dist/components/my-component.js"
28+
},
29+
"./loader": {
30+
"types": "./loader/index.d.ts",
31+
"require": "./loader/index.cjs",
32+
"import": "./loader/index.js"
33+
}
34+
},
35+
"unpkg": "dist/example/example.esm.js",
36+
"scripts": {
37+
"build": "stencil build",
38+
"start": "stencil build --dev --watch --serve",
39+
"test": "jest",
40+
"test.watch": "jest --watchAll",
41+
"generate": "stencil generate"
42+
},
43+
"devDependencies": {
44+
"@stencil/core": "^4.27.1",
45+
"@types/jest": "^30.0.0",
46+
"@types/node": "^22.13.5",
47+
"jest": "^30.0.2",
48+
"jest-cli": "^30.0.2",
49+
"jest-stencil-runner": "workspace:*",
50+
"puppeteer": "^24.3.0",
51+
"ts-jest": "^29.4.0"
52+
}
53+
}

example/cjs/src

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../esm/src
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)