@compiled/webpack-loader 0.6.17 → 0.7.3
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/CHANGELOG.md +45 -0
- package/dist/{__tests__/fixtures/async.d.ts → __fixtures__/async-styles.d.ts} +0 -0
- package/dist/{__tests__/fixtures/async.js → __fixtures__/async-styles.js} +2 -2
- package/dist/__fixtures__/async-styles.js.map +1 -0
- package/dist/__fixtures__/babel.d.ts +2 -0
- package/dist/__fixtures__/babel.js +14 -0
- package/dist/__fixtures__/babel.js.map +1 -0
- package/dist/{__tests__/fixtures → __fixtures__}/binding-not-found.d.ts +1 -1
- package/dist/{__tests__/fixtures → __fixtures__}/binding-not-found.js +6 -9
- package/dist/__fixtures__/binding-not-found.js.map +1 -0
- package/dist/__fixtures__/common/colors.d.ts +7 -0
- package/dist/{__tests__/fixtures/imports → __fixtures__/common}/colors.js +5 -4
- package/dist/__fixtures__/common/colors.js.map +1 -0
- package/dist/__fixtures__/common/css-prop.d.ts +2 -0
- package/dist/__fixtures__/common/css-prop.js +9 -0
- package/dist/__fixtures__/common/css-prop.js.map +1 -0
- package/dist/__fixtures__/compiled-error.d.ts +2 -0
- package/dist/__fixtures__/compiled-error.js +10 -0
- package/dist/__fixtures__/compiled-error.js.map +1 -0
- package/dist/__fixtures__/important-styles.d.ts +3 -0
- package/dist/__fixtures__/important-styles.js +7 -0
- package/dist/__fixtures__/important-styles.js.map +1 -0
- package/dist/__fixtures__/lib/loader-alias.d.ts +1 -0
- package/dist/__fixtures__/lib/loader-alias.js +8 -0
- package/dist/__fixtures__/lib/loader-alias.js.map +1 -0
- package/dist/__fixtures__/lib/webpack-alias.d.ts +1 -0
- package/dist/__fixtures__/lib/webpack-alias.js +8 -0
- package/dist/__fixtures__/lib/webpack-alias.js.map +1 -0
- package/dist/__fixtures__/loader-alias.d.ts +2 -0
- package/dist/__fixtures__/loader-alias.js +12 -0
- package/dist/__fixtures__/loader-alias.js.map +1 -0
- package/dist/__fixtures__/local-styles.d.ts +2 -0
- package/dist/__fixtures__/local-styles.js +14 -0
- package/dist/__fixtures__/local-styles.js.map +1 -0
- package/dist/__fixtures__/no-compiled-styles.d.ts +0 -0
- package/dist/__fixtures__/no-compiled-styles.js +3 -0
- package/dist/__fixtures__/no-compiled-styles.js.map +1 -0
- package/dist/__fixtures__/relative-styles.d.ts +3 -0
- package/dist/__fixtures__/relative-styles.js +34 -0
- package/dist/__fixtures__/relative-styles.js.map +1 -0
- package/dist/__fixtures__/webpack-alias.d.ts +2 -0
- package/dist/__fixtures__/webpack-alias.js +12 -0
- package/dist/__fixtures__/webpack-alias.js.map +1 -0
- package/dist/compiled-loader.d.ts +4 -3
- package/dist/compiled-loader.js +53 -17
- package/dist/compiled-loader.js.map +1 -1
- package/dist/css-loader.d.ts +3 -3
- package/dist/css-loader.js +4 -1
- package/dist/css-loader.js.map +1 -1
- package/dist/extract-plugin.js +5 -5
- package/dist/extract-plugin.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/types.d.ts +4 -58
- package/dist/{utils/webpack.d.ts → utils.d.ts} +1 -1
- package/dist/{utils/webpack.js → utils.js} +1 -1
- package/dist/utils.js.map +1 -0
- package/package.json +10 -9
- package/src/__fixtures__/async-styles.ts +1 -0
- package/src/__fixtures__/babel.tsx +11 -0
- package/src/{__tests__/fixtures → __fixtures__}/binding-not-found.tsx +2 -1
- package/src/{__tests__/fixtures/imports/colors.js → __fixtures__/common/colors.ts} +4 -3
- package/src/__fixtures__/common/css-prop.tsx +8 -0
- package/src/__fixtures__/compiled-error.tsx +7 -0
- package/src/__fixtures__/important-styles.tsx +6 -0
- package/src/__fixtures__/lib/babel-cjs.d.ts +3 -0
- package/src/{__tests__/fixtures/node_modules → __fixtures__/lib}/babel-cjs.js +0 -0
- package/src/__fixtures__/lib/babel-esm.d.ts +3 -0
- package/src/{__tests__/fixtures/node_modules → __fixtures__/lib}/babel-esm.js +0 -0
- package/src/__fixtures__/lib/loader-alias.ts +5 -0
- package/src/__fixtures__/lib/webpack-alias.ts +5 -0
- package/src/__fixtures__/loader-alias.tsx +8 -0
- package/src/__fixtures__/local-styles.tsx +14 -0
- package/src/__fixtures__/no-compiled-styles.ts +1 -0
- package/src/__fixtures__/relative-styles.tsx +39 -0
- package/src/__fixtures__/webpack-alias.tsx +8 -0
- package/src/__tests__/compiled-loader.test.tsx +70 -39
- package/src/__tests__/extract-plugin.test.tsx +82 -48
- package/src/__tests__/test-utils.tsx +103 -0
- package/src/compiled-loader.tsx +70 -34
- package/src/css-loader.tsx +9 -5
- package/src/extract-plugin.tsx +4 -3
- package/src/index.tsx +1 -0
- package/src/types.tsx +5 -60
- package/src/{utils/webpack.tsx → utils.tsx} +1 -1
- package/dist/__tests__/fixtures/async.js.map +0 -1
- package/dist/__tests__/fixtures/babel.d.ts +0 -1
- package/dist/__tests__/fixtures/babel.js +0 -14
- package/dist/__tests__/fixtures/babel.js.map +0 -1
- package/dist/__tests__/fixtures/binding-not-found.js.map +0 -1
- package/dist/__tests__/fixtures/important-styles.d.ts +0 -2
- package/dist/__tests__/fixtures/important-styles.js +0 -6
- package/dist/__tests__/fixtures/important-styles.js.map +0 -1
- package/dist/__tests__/fixtures/imports/colors.d.ts +0 -6
- package/dist/__tests__/fixtures/imports/colors.js.map +0 -1
- package/dist/__tests__/fixtures/imports/css-prop.d.ts +0 -1
- package/dist/__tests__/fixtures/imports/css-prop.js +0 -8
- package/dist/__tests__/fixtures/imports/css-prop.js.map +0 -1
- package/dist/__tests__/fixtures/multiple.d.ts +0 -2
- package/dist/__tests__/fixtures/multiple.js +0 -28
- package/dist/__tests__/fixtures/multiple.js.map +0 -1
- package/dist/__tests__/fixtures/single.d.ts +0 -2
- package/dist/__tests__/fixtures/single.js +0 -6
- package/dist/__tests__/fixtures/single.js.map +0 -1
- package/dist/__tests__/utils/webpack.d.ts +0 -6
- package/dist/__tests__/utils/webpack.js +0 -81
- package/dist/__tests__/utils/webpack.js.map +0 -1
- package/dist/utils/webpack.js.map +0 -1
- package/src/__tests__/fixtures/async.js +0 -1
- package/src/__tests__/fixtures/babel.js +0 -11
- package/src/__tests__/fixtures/important-styles.js +0 -5
- package/src/__tests__/fixtures/imports/css-prop.js +0 -4
- package/src/__tests__/fixtures/multiple.js +0 -28
- package/src/__tests__/fixtures/single.js +0 -5
- package/src/__tests__/utils/webpack.tsx +0 -88
package/dist/extract-plugin.js
CHANGED
|
@@ -17,7 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.CompiledExtractPlugin = exports.styleSheetName = exports.pluginName = void 0;
|
|
18
18
|
const css_1 = require("@compiled/css");
|
|
19
19
|
const utils_1 = require("@compiled/utils");
|
|
20
|
-
const
|
|
20
|
+
const utils_2 = require("./utils");
|
|
21
21
|
exports.pluginName = 'CompiledExtractPlugin';
|
|
22
22
|
exports.styleSheetName = 'compiled-css';
|
|
23
23
|
/**
|
|
@@ -100,22 +100,22 @@ class CompiledExtractPlugin {
|
|
|
100
100
|
__classPrivateFieldSet(this, _options, options);
|
|
101
101
|
}
|
|
102
102
|
apply(compiler) {
|
|
103
|
-
const { RawSource } =
|
|
103
|
+
const { RawSource } = utils_2.getSources(compiler);
|
|
104
104
|
pushNodeModulesExtractLoader(compiler, __classPrivateFieldGet(this, _options));
|
|
105
105
|
forceCSSIntoOneStyleSheet(compiler);
|
|
106
106
|
compiler.hooks.compilation.tap(exports.pluginName, (compilation) => {
|
|
107
|
-
|
|
107
|
+
utils_2.getNormalModuleHook(compiler, compilation).tap(exports.pluginName, (loaderContext) => {
|
|
108
108
|
// We add some information here to tell loaders that the plugin has been configured.
|
|
109
109
|
// Bundling will throw if this is missing (i.e. consumers did not setup correctly).
|
|
110
110
|
loaderContext[exports.pluginName] = true;
|
|
111
111
|
});
|
|
112
|
-
|
|
112
|
+
utils_2.getOptimizeAssetsHook(compiler, compilation).tap(exports.pluginName, (assets) => {
|
|
113
113
|
const cssAssets = getCSSAssets(assets);
|
|
114
114
|
if (cssAssets.length === 0) {
|
|
115
115
|
return;
|
|
116
116
|
}
|
|
117
117
|
const [asset] = cssAssets;
|
|
118
|
-
const contents =
|
|
118
|
+
const contents = utils_2.getAssetSourceContents(asset.source);
|
|
119
119
|
const newSource = new RawSource(css_1.sort(contents));
|
|
120
120
|
compilation.updateAsset(asset.name, newSource, asset.info);
|
|
121
121
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-plugin.js","sourceRoot":"","sources":["../src/extract-plugin.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAAqC;AACrC,2CAAyD;
|
|
1
|
+
{"version":3,"file":"extract-plugin.js","sourceRoot":"","sources":["../src/extract-plugin.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAAqC;AACrC,2CAAyD;AAIzD,mCAKiB;AAEJ,QAAA,UAAU,GAAG,uBAAuB,CAAC;AACrC,QAAA,cAAc,GAAG,cAAc,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,YAAY,GAAG,CAAC,MAA6B,EAAE,EAAE;IACrD,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;SACvB,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE;QACpB,OAAO,SAAS,CAAC,QAAQ,CAAC,GAAG,sBAAc,MAAM,CAAC,CAAC;IACrD,CAAC,CAAC;SACD,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;AACpF,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,yBAAyB,GAAG,CAAC,QAAkB,EAAE,EAAE;IACvD,MAAM,UAAU,GAAG;QACjB,WAAW,EAAE;YACX,IAAI,EAAE,sBAAc;YACpB,IAAI,EAAE,kBAAkB;YACxB,MAAM,EAAE,KAAK;YACb,mCAAmC;Y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,CAAC;CACF;AAlCD,sDAkCC"}
|
package/dist/index.d.ts
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { RuleSetCondition } from 'webpack';
|
|
2
|
-
|
|
1
|
+
import type { ResolveOptions, RuleSetCondition } from 'webpack';
|
|
2
|
+
export type { ResolveOptions };
|
|
3
3
|
export interface CompiledLoaderOptions {
|
|
4
4
|
/**
|
|
5
5
|
* Converts your source code into a Compiled component.
|
|
@@ -21,64 +21,10 @@ export interface CompiledLoaderOptions {
|
|
|
21
21
|
* read [Security](https://compiledcssinjs.com/docs/security) for more information.
|
|
22
22
|
*/
|
|
23
23
|
nonce?: string;
|
|
24
|
-
}
|
|
25
|
-
export interface LoaderThis<TOptions = unknown> {
|
|
26
|
-
/**
|
|
27
|
-
* Query param passed to the loader.
|
|
28
|
-
*
|
|
29
|
-
* ```
|
|
30
|
-
* import '!loader-module?query=params';
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
resourceQuery: string;
|
|
34
|
-
/**
|
|
35
|
-
* Absolute path of this file.
|
|
36
|
-
*/
|
|
37
|
-
resourcePath: string;
|
|
38
|
-
/**
|
|
39
|
-
* Returns the passed in options from a user.
|
|
40
|
-
* Optionally validated with a `schema` object.
|
|
41
|
-
*/
|
|
42
|
-
getOptions?: (schema?: {
|
|
43
|
-
type: string;
|
|
44
|
-
properties: Required<{
|
|
45
|
-
[P in keyof TOptions]: {
|
|
46
|
-
type: string;
|
|
47
|
-
} | {
|
|
48
|
-
anyOf: Array<{
|
|
49
|
-
type: string;
|
|
50
|
-
}>;
|
|
51
|
-
};
|
|
52
|
-
}>;
|
|
53
|
-
}) => TOptions;
|
|
54
|
-
/**
|
|
55
|
-
* Notifies webpack that this loader run included another file.
|
|
56
|
-
* When the other file changes this file will be recompiled.
|
|
57
|
-
*/
|
|
58
|
-
addDependency(path: string): void;
|
|
59
|
-
/**
|
|
60
|
-
* Marks the loader async.
|
|
61
|
-
* Call the return value when the loader has completed.
|
|
62
|
-
*/
|
|
63
|
-
async(): (err: any, result?: string, map?: any) => void;
|
|
64
|
-
/**
|
|
65
|
-
* Internal access to the current webpack compiler.
|
|
66
|
-
*/
|
|
67
|
-
_compiler: any;
|
|
68
|
-
/**
|
|
69
|
-
* Internal access to the loaders for this run.
|
|
70
|
-
*/
|
|
71
|
-
loaders: any[];
|
|
72
|
-
/**
|
|
73
|
-
* Emits an error during the loader run.
|
|
74
|
-
*
|
|
75
|
-
* @param error
|
|
76
|
-
*/
|
|
77
|
-
emitError(error: Error): void;
|
|
78
24
|
/**
|
|
79
|
-
*
|
|
25
|
+
* Override the default `resolve` passed into webpack, which is used to statically evaluate import declarations
|
|
80
26
|
*/
|
|
81
|
-
|
|
27
|
+
resolve?: ResolveOptions;
|
|
82
28
|
}
|
|
83
29
|
export interface CompiledExtractPluginOptions {
|
|
84
30
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.tsx"],"names":[],"mappings":";;;AAEA;;;;GAIG;AACI,MAAM,mBAAmB,GAAG,CACjC,QAAkB,EAClB,WAA4B,EACoB,EAAE;IAClD,MAAM,EAAE,YAAY,EAAE;IACpB,iBAAiB;IACjB,QAAQ,CAAC,OAAO;QAChB,iBAAiB;QACjB,OAAO,CAAC,SAAS,CAAC,CAAC;IAErB,MAAM,gBAAgB,GACpB,YAAY,IAAI,OAAO,YAAY,CAAC,mBAAmB,KAAK,WAAW;QACrE,CAAC,CAAC,iBAAiB;YACjB,YAAY,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC,MAAM;QACtD,CAAC,CAAC,iBAAiB;YACjB,WAAW,CAAC,KAAK,CAAC,kBAAkB,CAAC;IAE3C,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAC;AAlBW,QAAA,mBAAmB,uBAkB9B;AAEF;;;;;GAKG;AACI,MAAM,sBAAsB,GAAG,CAAC,WAA2B,EAAU,EAAE;I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A,UAAU,cAarB;AAEF;;;;;;GAMG;AACI,MAAM,cAAc,GAAG,CAAC,IAAY,EAAU,EAAE;IACrD,MAAM,SAAS,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAEhE,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAJW,QAAA,cAAc,kBAIzB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@compiled/webpack-loader",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "A familiar and performant compile time CSS-in-JS library for React.",
|
|
5
5
|
"homepage": "https://compiledcssinjs.com",
|
|
6
6
|
"bugs": "https://github.com/atlassian-labs/compiled/issues/new?assignees=&labels=bug&template=bug_report.md",
|
|
@@ -21,20 +21,21 @@
|
|
|
21
21
|
"README.md"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@babel/core": "^7.
|
|
25
|
-
"@compiled/babel-plugin": "^0.
|
|
26
|
-
"@compiled/babel-plugin-strip-runtime": "^0.
|
|
27
|
-
"@compiled/css": "^0.7.
|
|
28
|
-
"@compiled/utils": "^0.6.
|
|
29
|
-
"
|
|
24
|
+
"@babel/core": "^7.16.0",
|
|
25
|
+
"@compiled/babel-plugin": "^0.11.1",
|
|
26
|
+
"@compiled/babel-plugin-strip-runtime": "^0.11.1",
|
|
27
|
+
"@compiled/css": "^0.7.1",
|
|
28
|
+
"@compiled/utils": "^0.6.12",
|
|
29
|
+
"enhanced-resolve": "^5.8.3",
|
|
30
|
+
"loader-utils": "^2.0.2",
|
|
30
31
|
"webpack-sources": "^1.4.3"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
|
-
"babel-loader": "^8.2.
|
|
34
|
+
"babel-loader": "^8.2.3",
|
|
34
35
|
"css-loader": "^5.2.7",
|
|
35
36
|
"memfs": "^3.2.4",
|
|
36
37
|
"mini-css-extract-plugin": "^1.5.0",
|
|
37
|
-
"webpack": "^5.
|
|
38
|
+
"webpack": "^5.61.0"
|
|
38
39
|
},
|
|
39
40
|
"peerDependencies": {
|
|
40
41
|
"webpack": ">= 4.46.0"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import('./common/css-prop');
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export const purple = 'purple';
|
|
2
|
-
export const blueviolet = 'blueviolet';
|
|
3
1
|
export const blue = 'blue';
|
|
4
|
-
export const
|
|
2
|
+
export const blueviolet = 'blueviolet';
|
|
3
|
+
export const coral = 'coral';
|
|
4
|
+
export const purple = 'purple';
|
|
5
5
|
export const orange = 'orange';
|
|
6
|
+
export const red = 'red';
|
|
6
7
|
export const yellow = 'yellow';
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
// @ts-ignore This is a bug where the meta is not updated for the new file import
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import { jsx, css } from '@compiled/react';
|
|
5
|
+
// @ts-expect-error
|
|
6
|
+
import { styles } from 'loader-alias';
|
|
7
|
+
|
|
8
|
+
export const App = (): JSX.Element => <div css={styles} />;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx, styled } from '@compiled/react';
|
|
3
|
+
import { Fragment } from 'react';
|
|
4
|
+
|
|
5
|
+
const Styled = styled.div({
|
|
6
|
+
color: 'blue',
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export const App = (): JSX.Element => (
|
|
10
|
+
<Fragment>
|
|
11
|
+
<div css={{ fontSize: 14 }} />
|
|
12
|
+
<Styled />
|
|
13
|
+
</Fragment>
|
|
14
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
console.log('Hello world!');
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx, css, styled } from '@compiled/react';
|
|
3
|
+
import { Fragment } from 'react';
|
|
4
|
+
|
|
5
|
+
import { blueviolet, blue, orange, purple, red, yellow } from './common/colors';
|
|
6
|
+
// @ts-expect-error ↓↓↓ This should not have their styles extracted ↓↓↓
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
8
|
+
import { Coral } from './common/css-prop';
|
|
9
|
+
|
|
10
|
+
export const Styled = styled.span`
|
|
11
|
+
color: ${blueviolet};
|
|
12
|
+
|
|
13
|
+
:focus {
|
|
14
|
+
color: ${purple};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
:hover {
|
|
18
|
+
color: ${blue};
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
const styles = css`
|
|
23
|
+
color: ${red};
|
|
24
|
+
|
|
25
|
+
:focus {
|
|
26
|
+
color: ${orange};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
:hover {
|
|
30
|
+
color: ${yellow};
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
export const App = (): JSX.Element => (
|
|
35
|
+
<Fragment>
|
|
36
|
+
<div css={styles} />
|
|
37
|
+
<Styled />
|
|
38
|
+
</Fragment>
|
|
39
|
+
);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
// @ts-expect-error This is a bug where the meta is not updated for the new file import
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import { jsx, css } from '@compiled/react';
|
|
5
|
+
// @ts-expect-error
|
|
6
|
+
import { styles } from 'webpack-alias';
|
|
7
|
+
|
|
8
|
+
export const App = (): JSX.Element => <div css={styles} />;
|
|
@@ -1,53 +1,84 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { join } from 'path';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
async: () => opts.callback,
|
|
6
|
-
resourcePath: '/projects/index.js',
|
|
7
|
-
addDependency: opts.addDependency,
|
|
8
|
-
getOptions: () => ({ importReact: false }),
|
|
9
|
-
});
|
|
3
|
+
import { bundle as bundleEntry } from './test-utils';
|
|
4
|
+
import type { BundleOptions } from './test-utils';
|
|
10
5
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
// We are testing in both modes, because the initial custom resolver implementation (i.e. this.getResolve) only works
|
|
7
|
+
// in production
|
|
8
|
+
describe.each<'development' | 'production'>(['development', 'production'])(
|
|
9
|
+
'webpack loader in %s mode',
|
|
10
|
+
(mode) => {
|
|
11
|
+
const fixturesPath = join(__dirname, '..', '__fixtures__');
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
const bundle = (entry: string, options: Omit<BundleOptions, 'mode'> = {}) =>
|
|
14
|
+
bundleEntry(entry, {
|
|
15
|
+
...options,
|
|
16
|
+
mode,
|
|
17
|
+
});
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
it('does not transform files that do not contain @compiled/react', async () => {
|
|
20
|
+
const assets = await bundle(join(fixturesPath, 'no-compiled-styles.ts'));
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
if (mode === 'development') {
|
|
23
|
+
expect(assets['main.js']).toInclude("console.log('Hello world!');");
|
|
24
|
+
} else {
|
|
25
|
+
expect(assets['main.js']).toMatchInlineSnapshot(`"console.log(\\"Hello world!\\");"`);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
25
28
|
|
|
26
|
-
|
|
29
|
+
it('transforms local styles', async () => {
|
|
30
|
+
const assets = await bundle(join(fixturesPath, 'local-styles.tsx'));
|
|
27
31
|
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
expect(assets['main.js']).toIncludeMultiple([
|
|
33
|
+
'._1wybdlk8{font-size:14px}',
|
|
34
|
+
'._syaz13q2{color:blue}',
|
|
35
|
+
]);
|
|
36
|
+
});
|
|
30
37
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const loader = getLoader({ addDependency: jest.fn(), callback });
|
|
38
|
+
it('transforms styles imported through a relative import', async () => {
|
|
39
|
+
const assets = await bundle(join(fixturesPath, 'relative-styles.tsx'));
|
|
34
40
|
|
|
35
|
-
|
|
41
|
+
expect(assets['main.js']).toIncludeMultiple([
|
|
42
|
+
'._syaz5scu{color:red}',
|
|
43
|
+
'._syazmu8g{color:blueviolet}',
|
|
44
|
+
'._f8pjruxl:focus{color:orange}',
|
|
45
|
+
'._f8pj1cnh:focus{color:purple}',
|
|
46
|
+
'._30l31gy6:hover{color:yellow}',
|
|
47
|
+
'._30l313q2:hover{color:blue}',
|
|
48
|
+
]);
|
|
36
49
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
50
|
+
// not.toIncludeMultiple does not work as intended
|
|
51
|
+
expect(assets['main.js']).not.toInclude('{border:2px solid coral}');
|
|
52
|
+
expect(assets['main.js']).not.toInclude('{color:coral}');
|
|
53
|
+
});
|
|
40
54
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
});
|
|
55
|
+
it('transforms styles imported through a webpack alias', async () => {
|
|
56
|
+
const assets = await bundle(join(fixturesPath, 'webpack-alias.tsx'));
|
|
44
57
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const loader = getLoader({ addDependency: jest.fn(), callback });
|
|
58
|
+
expect(assets['main.js']).toInclude('._syaz13q2{color:blue}');
|
|
59
|
+
});
|
|
48
60
|
|
|
49
|
-
|
|
61
|
+
it('transforms styles imported through an overridden resolve configuration', async () => {
|
|
62
|
+
const assets = await bundle(join(fixturesPath, 'loader-alias.tsx'), {
|
|
63
|
+
resolve: {
|
|
64
|
+
// This alias will be put into the compiled plugin options, but not the webpack resolve configuration
|
|
65
|
+
alias: {
|
|
66
|
+
'loader-alias': join(fixturesPath, 'lib', 'loader-alias.ts'),
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
});
|
|
50
70
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
71
|
+
expect(assets['main.js']).toInclude('._syaz1if8{color:indigo}');
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('fails when using unrecognised compiled syntax', async () => {
|
|
75
|
+
await expect(bundle(join(fixturesPath, 'compiled-error.tsx'))).rejects.toEqual([
|
|
76
|
+
expect.objectContaining({
|
|
77
|
+
message: expect.stringContaining(
|
|
78
|
+
"BooleanLiteral isn't a supported CSS type - try using an object or string"
|
|
79
|
+
),
|
|
80
|
+
}),
|
|
81
|
+
]);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
);
|