Skip to content

Commit 3554b58

Browse files
committed
add third-party package (@emotion/react) tests
1 parent d7272ad commit 3554b58

File tree

6 files changed

+75
-2
lines changed

6 files changed

+75
-2
lines changed

tests/js/@emotion/bar.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import { css } from './foo';

tests/js/@emotion/emotion.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const pluginTransform = require("../../pluginTransform");
2+
const ospath = require("path");
3+
4+
describe("third-party package (@emotion/react) transformation for ESM", () => {
5+
test("transformation of @emotion/react", () => {
6+
const pluginOptions = { executorName: "jest" };
7+
expect(
8+
pluginTransform(
9+
'import { css } from "./foo";',
10+
__filename,
11+
pluginOptions
12+
)
13+
).toBe([
14+
`import { css } from \"@emotion\\react\\dist\\emotion-react.esm.js";`,
15+
].join("\n").replaceAll("\\","\\\\"));
16+
});
17+
18+
});

tests/js/@emotion/foo/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from '@emotion/react';

tests/js/@emotion/package.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "emotion-webpack",
3+
"version": "1.0.0",
4+
"main": "bar.js",
5+
"license": "MIT",
6+
"devDependencies": {
7+
"@babel/core": "^7.24.6",
8+
"babel-jest": "^29.7.0",
9+
"babel-loader": "^9.1.3",
10+
"jest": "^29.7.0",
11+
"webpack": "^5.95.0",
12+
"webpack-cli": "^5.1.4"
13+
},
14+
"scripts": {
15+
"build": "npx webpack",
16+
"test": "jest --config=../../jest.config.js"
17+
},
18+
"dependencies": {
19+
"@emotion/react": "^11.13.3"
20+
}
21+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const path = require('path');
2+
3+
module.exports = {
4+
mode: "production",
5+
devtool: false,
6+
optimization: {
7+
usedExports: true,
8+
sideEffects: true,
9+
},
10+
entry: "./bar.js",
11+
resolve: {
12+
},
13+
module: {
14+
rules: [
15+
{
16+
test: /\.(js|mjs|jsx|ts|tsx)$/,
17+
exclude: /node_modules/,
18+
loader: require.resolve("babel-loader"),
19+
options: {
20+
plugins: [["../../../", { executorName: "webpack", logging: {type: "file"} }]],
21+
},
22+
},
23+
],
24+
},
25+
};

tests/package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,23 @@
66
"devDependencies": {
77
"@babel/core": "^7.24.6",
88
"babel-jest": "^29.7.0",
9+
"babel-loader": "^9.2.1",
910
"jest": "^29.7.0",
10-
"mock-fs": "^5.2.0"
11+
"mock-fs": "^5.2.0",
12+
"webpack": "^5.95.0",
13+
"webpack-cli": "^5.1.4"
1114
},
1215
"scripts": {
1316
"test": "jest --clearCache && jest --config=jest.config.js"
1417
},
1518
"dependencies": {
1619
"@ant-design/icons": "^5.3.3",
20+
"@emotion/react": "^11.13.3",
1721
"@mui/icons-material": "^5.15.20",
18-
"graphql": "^16.9.0"
22+
"graphql": "^16.9.0",
23+
"preact": "^10.24.1",
24+
"remark-rehype": "^10.1.0",
25+
"style-to-object": "^0.4.2"
1926
},
2027
"workspaces": [
2128
"./*"

0 commit comments

Comments
 (0)