@compiled/webpack-loader 0.14.1 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__fixtures__/lib/other-css.d.ts +1 -0
- package/dist/__fixtures__/lib/other-css.js +7 -0
- package/dist/__fixtures__/lib/other-css.js.map +1 -0
- package/dist/__fixtures__/non-compiled-import-source.d.ts +2 -0
- package/dist/__fixtures__/non-compiled-import-source.js +10 -0
- package/dist/__fixtures__/non-compiled-import-source.js.map +1 -0
- package/dist/compiled-loader.js +5 -4
- package/dist/compiled-loader.js.map +1 -1
- package/package.json +2 -2
- package/src/__fixtures__/lib/other-css.ts +1 -0
- package/src/__fixtures__/non-compiled-import-source.tsx +6 -0
- package/src/__tests__/compiled-loader.test.ts +34 -1
- package/src/__tests__/test-utils.ts +4 -0
- package/src/compiled-loader.ts +5 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { css, jsx } from '@compiled/react';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.jsx = exports.css = void 0;
|
|
4
|
+
var react_1 = require("@compiled/react");
|
|
5
|
+
Object.defineProperty(exports, "css", { enumerable: true, get: function () { return react_1.css; } });
|
|
6
|
+
Object.defineProperty(exports, "jsx", { enumerable: true, get: function () { return react_1.jsx; } });
|
|
7
|
+
//# sourceMappingURL=other-css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"other-css.js","sourceRoot":"","sources":["../../../src/__fixtures__/lib/other-css.ts"],"names":[],"mappings":";;;AAAA,yCAA2C;AAAlC,4FAAA,GAAG,OAAA;AAAE,4FAAA,GAAG,OAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.App = void 0;
|
|
4
|
+
/** @jsx jsx */
|
|
5
|
+
// @ts-expect-error -- fake package
|
|
6
|
+
const css_1 = require("@other/css");
|
|
7
|
+
// @ts-expect-error -- fake package
|
|
8
|
+
const App = () => (0, css_1.jsx)("div", { css: { margin: 0 } });
|
|
9
|
+
exports.App = App;
|
|
10
|
+
//# sourceMappingURL=non-compiled-import-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"non-compiled-import-source.js","sourceRoot":"","sources":["../../src/__fixtures__/non-compiled-import-source.tsx"],"names":[],"mappings":";;;AAAA,eAAe;AACf,mCAAmC;AACnC,oCAAiC;AAEjC,mCAAmC;AAC5B,MAAM,GAAG,GAAG,GAAgB,EAAE,CAAC,wBAAK,GAAG,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,GAAI,CAAC;AAArD,QAAA,GAAG,OAAkD"}
|
package/dist/compiled-loader.js
CHANGED
|
@@ -111,14 +111,15 @@ function getLoaderOptions(context) {
|
|
|
111
111
|
async function compiledLoader(code) {
|
|
112
112
|
var _a, _b, _c, _d;
|
|
113
113
|
const callback = this.async();
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
const _e = getLoaderOptions(this), { resolve } = _e, options = __rest(_e, ["resolve"]);
|
|
115
|
+
const importSources = ['@compiled/react', ...(options.importSources || [])];
|
|
116
|
+
// Bail early if we're looking at Compiled runtime code or Compiled (via an importSource) isn't in the module
|
|
117
|
+
if (this.resourcePath.includes('/node_modules/@compiled/react') ||
|
|
118
|
+
!importSources.some((name) => code.includes(name))) {
|
|
117
119
|
return callback(null, code);
|
|
118
120
|
}
|
|
119
121
|
try {
|
|
120
122
|
const includedFiles = [];
|
|
121
|
-
const _e = getLoaderOptions(this), { resolve } = _e, options = __rest(_e, ["resolve"]);
|
|
122
123
|
// Transform to an AST using the local babel config.
|
|
123
124
|
const ast = await (0, core_1.parseAsync)(code, {
|
|
124
125
|
filename: this.resourcePath,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compi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,OAAO;qBACd;oBACD,uBAAuB,EAAE;wBACvB,IAAI,EAAE,OAAO;qBACd;oBACD,CAAC,2BAAU,CAAC,EAAE;wBACZ,IAAI,EAAE,SAAS;qBAChB;oBACD,GAAG,EAAE;wBACH,IAAI,EAAE,SAAS;qBAChB;oBACD,WAAW,EAAE;wBACX,IAAI,EAAE,SAAS;qBAChB;oBACD,gBAAgB,EAAE;wBAChB,IAAI,EAAE,SAAS;qBAChB;oBACD,uBAAuB,EAAE;wBACvB,IAAI,EAAE,QAAQ;qBACf;oBACD,wBAAwB,EAAE;wBACxB,IAAI,EAAE,QAAQ;qBACf;oBACD,QAAQ,EAAE;wBACR,IAAI,EAAE,QAAQ;qBACf;oBACD,aAAa,EAAE;wBACb,IAAI,EAAE,OAAO;qBACd;iBACF;aACF,CAAC,CAAC;IAEP,OAAO;QACL,IAAI;QACJ,OAAO;QACP,WAAW;QACX,KAAK;QACL,OAAO;QACP,UAAU;QACV,kBAAkB;QAClB,uBAAuB;QACvB,CAAC,2BAAU,CAAC,EAAE,eAAe;QAC7B,GAAG;QACH,WAAW;QACX,gBAAgB;QAChB,uBAAuB;QACvB,wBAAwB;QACxB,QAAQ;QACR,aAAa;KACd,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACY,KAAK,UAAU,cAAc,CAE1C,IAAY;;IAEZ,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"compiled-loader.js","sourceRoot":"","sources":["../src/compiled-loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+BAAiC;AAEjC,sCAAgE;AAChE,2CAAuF;AACvF,+CAA0C;AAG1C,uEAAkE;AAClE,qDAA8D;AAG9D,IAAI,UAAU,GAAG,KAAK,CAAC;AAEvB;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,OAA6C;IACrE,MAAM,EACJ,IAAI,GAAG,IAAI,EACX,OAAO,GAAG,KAAK,EACf,WAAW,GAAG,SAAS,EAC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iBAAS,CAAC;SACpB,CAAC,CAAC;QAEH,aAAa,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAC7B,IAAI,CAAC,aAAa,CAAC,IAAA,gBAAS,EAAC,IAAI,CAAC,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;QAEH,QAAQ,CAAC,IAAI,EAAE,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,KAAI,EAAE,EAAE,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,GAAG,mCAAI,SAAS,CAAC,CAAC;KAC9D;IAAC,OAAO,CAAU,EAAE;QACnB,+CAA+C;QAC/C,MAAM,KAAK,GAAG,IAAA,mBAAW,EAAC,iBAAiB,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC7E,QAAQ,CAAC,KAAK,CAAC,CAAC;KACjB;AACH,CAAC;AA/ED,iCA+EC;AAED,SAAgB,KAAK;IACnB,MAAM,OAAO,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACvC,IAAI,CAAC,UAAU,IAAI,OAAO,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,2BAAU,CAAC,EAAE;QAC1D,IAAI,CAAC,SAAS,CACZ,IAAA,mBAAW,EAAC,gBAAgB,CAAC,CAC3B,gLAAgL,CACjL,CACF,CAAC;QAEF,4FAA4F;QAC5F,UAAU,GAAG,IAAI,CAAC;KACnB;AACH,CAAC;AAZD,sBAYC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@compiled/webpack-loader",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "A familiar and performant compile time CSS-in-JS library for React.",
|
|
5
5
|
"homepage": "https://compiledcssinjs.com/docs/pkg-webpack-loader",
|
|
6
6
|
"bugs": "https://github.com/atlassian-labs/compiled/issues/new?assignees=&labels=bug&template=bug_report.md",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@babel/core": "^7.21.8",
|
|
24
24
|
"@babel/parser": "^7.21.8",
|
|
25
|
-
"@compiled/babel-plugin": "^0.
|
|
25
|
+
"@compiled/babel-plugin": "^0.30.0",
|
|
26
26
|
"@compiled/babel-plugin-strip-runtime": "^0.29.0",
|
|
27
27
|
"@compiled/css": "^0.14.0",
|
|
28
28
|
"@compiled/utils": "^0.11.2",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { css, jsx } from '@compiled/react';
|
|
@@ -20,7 +20,7 @@ describe.each<'development' | 'production'>(['development', 'production'])(
|
|
|
20
20
|
mode,
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
it('does not transform files that do not contain
|
|
23
|
+
it('does not transform files that do not contain styles', async () => {
|
|
24
24
|
const assets = await bundle(join(fixturesPath, 'no-compiled-styles.ts'));
|
|
25
25
|
|
|
26
26
|
if (mode === 'development') {
|
|
@@ -30,6 +30,39 @@ describe.each<'development' | 'production'>(['development', 'production'])(
|
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
+
it('does not transform files that do not contain @compiled/react', async () => {
|
|
34
|
+
const assets = await bundle(join(fixturesPath, 'non-compiled-import-source.tsx'));
|
|
35
|
+
|
|
36
|
+
if (mode === 'development') {
|
|
37
|
+
// This appears to just default to eval mode—I can't test much about it…
|
|
38
|
+
expect(assets['main.js']).toInclude('eval()');
|
|
39
|
+
expect(assets['main.js']).toInclude('React.createElement');
|
|
40
|
+
expect(assets['main.js']).not.toMatch(/\{[\s]*margin(-[a-z]+)?:[\s]*0[\s]*\}/);
|
|
41
|
+
expect(assets['main.js']).toInclude(
|
|
42
|
+
'__webpack_require__("./packages/webpack-loader/src/__fixtures__/non-compiled-import-source.tsx");'
|
|
43
|
+
);
|
|
44
|
+
} else {
|
|
45
|
+
expect(assets['main.js']).toMatch(
|
|
46
|
+
/@compiled\/react[\\n\s]+Code was executed when it shouldn't have\./
|
|
47
|
+
);
|
|
48
|
+
expect(assets['main.js']).toInclude('{margin:0}');
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('transforms a file that does not contain @compiled/react, but contains an importSource', async () => {
|
|
53
|
+
const assets = await bundle(join(fixturesPath, 'non-compiled-import-source.tsx'), {
|
|
54
|
+
importSources: ['@other/css'],
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
expect(assets['main.js']).not.toInclude('{margin:0}');
|
|
58
|
+
expect(assets['main.js']).toIncludeMultiple([
|
|
59
|
+
'._19pkidpf{margin-top:0}',
|
|
60
|
+
'._2hwxidpf{margin-right:0}',
|
|
61
|
+
'._otyridpf{margin-bottom:0}',
|
|
62
|
+
'._18u0idpf{margin-left:0}',
|
|
63
|
+
]);
|
|
64
|
+
});
|
|
65
|
+
|
|
33
66
|
it('transforms local styles', async () => {
|
|
34
67
|
const assets = await bundle(join(fixturesPath, 'local-styles.tsx'));
|
|
35
68
|
|
|
@@ -17,6 +17,7 @@ export interface BundleOptions {
|
|
|
17
17
|
mode: 'development' | 'production';
|
|
18
18
|
resolve?: ResolveOptions;
|
|
19
19
|
resolver?: string;
|
|
20
|
+
importSources?: string[];
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
export function bundle(
|
|
@@ -29,6 +30,7 @@ export function bundle(
|
|
|
29
30
|
mode,
|
|
30
31
|
resolve = {},
|
|
31
32
|
resolver,
|
|
33
|
+
importSources,
|
|
32
34
|
}: BundleOptions
|
|
33
35
|
): Promise<Record<string, string>> {
|
|
34
36
|
const outputPath = join(__dirname, 'dist');
|
|
@@ -56,6 +58,7 @@ export function bundle(
|
|
|
56
58
|
options: {
|
|
57
59
|
extract,
|
|
58
60
|
importReact: false,
|
|
61
|
+
importSources,
|
|
59
62
|
optimizeCss: false,
|
|
60
63
|
resolve,
|
|
61
64
|
resolver,
|
|
@@ -86,6 +89,7 @@ export function bundle(
|
|
|
86
89
|
resolve: {
|
|
87
90
|
alias: {
|
|
88
91
|
'webpack-alias': join(__dirname, '..', '__fixtures__', 'lib', 'webpack-alias.ts'),
|
|
92
|
+
'@other/css': join(__dirname, '..', '__fixtures__', 'lib', 'other-css.ts'),
|
|
89
93
|
},
|
|
90
94
|
extensions: ['.tsx', '.ts', '.jsx', '.js'],
|
|
91
95
|
},
|
package/src/compiled-loader.ts
CHANGED
|
@@ -124,18 +124,19 @@ export default async function compiledLoader(
|
|
|
124
124
|
code: string
|
|
125
125
|
): Promise<void> {
|
|
126
126
|
const callback = this.async();
|
|
127
|
+
const { resolve, ...options } = getLoaderOptions(this);
|
|
128
|
+
const importSources = ['@compiled/react', ...(options.importSources || [])];
|
|
127
129
|
|
|
128
|
-
// Bail early if
|
|
130
|
+
// Bail early if we're looking at Compiled runtime code or Compiled (via an importSource) isn't in the module
|
|
129
131
|
if (
|
|
130
|
-
|
|
131
|
-
|
|
132
|
+
this.resourcePath.includes('/node_modules/@compiled/react') ||
|
|
133
|
+
!importSources.some((name) => code.includes(name))
|
|
132
134
|
) {
|
|
133
135
|
return callback(null, code);
|
|
134
136
|
}
|
|
135
137
|
|
|
136
138
|
try {
|
|
137
139
|
const includedFiles: string[] = [];
|
|
138
|
-
const { resolve, ...options } = getLoaderOptions(this);
|
|
139
140
|
|
|
140
141
|
// Transform to an AST using the local babel config.
|
|
141
142
|
const ast = await parseAsync(code, {
|