next-with-linaria 0.4.0 → 0.5.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/README.md
CHANGED
|
@@ -100,16 +100,6 @@ export default function RootLayout({
|
|
|
100
100
|
|
|
101
101
|
This convention is needed because the loader needs to know which files contain global styles and which don't.
|
|
102
102
|
|
|
103
|
-
## Config
|
|
104
|
-
|
|
105
|
-
For details on the config options, see the [Linaria Config](https://github.com/callstack/linaria/blob/master/docs/CONFIGURATION.md).
|
|
106
|
-
|
|
107
|
-
### Plugin specific config
|
|
108
|
-
|
|
109
|
-
`enableInMemoryCache` (default: `true`).
|
|
110
|
-
|
|
111
|
-
If set to `true`, the loader will generate a hash for the file content and store the transformed code in memory and only re-run the transformation if the file has changed. This can increase performance when working with large files. However, hashing the file content, even though it is pretty fast compared to the transformation, can still take some time. If you are experiencing performance or memory issues, you can disable this feature.
|
|
112
|
-
|
|
113
103
|
## Good to know
|
|
114
104
|
|
|
115
105
|
Because webpack 5 caches modules, the virtual CSS Modules need to be cached as well (so at that point the are not really virtual anymore, are they? Anyway...). They are placed in the same directory as where webpack puts its cache files. If the `next-with-linaria` cache is not in sync with the webpack cache anymore, it will cause errors due to missing CSS Modules. If you encounter such an error, you can delete the `.next/cache/webpack` folder and restart the dev server.
|
|
@@ -7,7 +7,6 @@ export declare const regexLinariaModuleCSS: RegExp;
|
|
|
7
7
|
export declare const regexLinariaGlobalCSS: RegExp;
|
|
8
8
|
export declare const regexLinariaCSS: RegExp;
|
|
9
9
|
export type LinariaLoaderOptions = {
|
|
10
|
-
enableInMemoryCache?: boolean;
|
|
11
10
|
moduleStore: VirtualModuleStore;
|
|
12
11
|
preprocessor?: Preprocessor;
|
|
13
12
|
sourceMap?: boolean;
|
|
@@ -16,7 +16,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.regexLinariaCSS = exports.regexLinariaGlobalCSS = exports.regexLinariaModuleCSS = exports.LINARIA_GLOBAL_EXTENSION = exports.LINARIA_MODULE_EXTENSION = void 0;
|
|
18
18
|
const babel_preset_1 = require("@linaria/babel-preset");
|
|
19
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
20
19
|
const path_1 = __importDefault(require("path"));
|
|
21
20
|
exports.LINARIA_MODULE_EXTENSION = '.linaria.module';
|
|
22
21
|
exports.LINARIA_GLOBAL_EXTENSION = '.linaria.global';
|
|
@@ -30,19 +29,9 @@ function convertSourceMap(value, filename) {
|
|
|
30
29
|
}
|
|
31
30
|
return Object.assign(Object.assign({}, value), { file: (_a = value.file) !== null && _a !== void 0 ? _a : filename, mappings: (_b = value.mappings) !== null && _b !== void 0 ? _b : '', names: (_c = value.names) !== null && _c !== void 0 ? _c : [], sources: (_d = value.sources) !== null && _d !== void 0 ? _d : [], version: (_e = value.version) !== null && _e !== void 0 ? _e : 3 });
|
|
32
31
|
}
|
|
33
|
-
const cache = new Map();
|
|
34
32
|
const transformLoader = function (content, inputSourceMap) {
|
|
35
|
-
const _a = this.getOptions() || {}, { sourceMap = undefined, preprocessor = undefined, moduleStore, enableInMemoryCache = true } = _a, rest = __rest(_a, ["sourceMap", "preprocessor", "moduleStore", "enableInMemoryCache"]);
|
|
36
|
-
let contentHash;
|
|
37
|
-
if (enableInMemoryCache) {
|
|
38
|
-
contentHash = crypto_1.default.createHash('md5').update(content).digest('hex');
|
|
39
|
-
const cacheEntry = cache.get(this.resourcePath);
|
|
40
|
-
if ((cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.hash) === contentHash) {
|
|
41
|
-
this.callback(null, cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.code, cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.sourceMap);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
33
|
this.async();
|
|
34
|
+
const _a = this.getOptions() || {}, { sourceMap = undefined, preprocessor = undefined, moduleStore } = _a, rest = __rest(_a, ["sourceMap", "preprocessor", "moduleStore"]);
|
|
46
35
|
const asyncResolve = (token, importer) => {
|
|
47
36
|
const context = path_1.default.isAbsolute(importer)
|
|
48
37
|
? path_1.default.dirname(importer)
|
|
@@ -69,7 +58,7 @@ const transformLoader = function (content, inputSourceMap) {
|
|
|
69
58
|
pluginOptions: rest,
|
|
70
59
|
preprocessor,
|
|
71
60
|
}, asyncResolve).then(async (result) => {
|
|
72
|
-
var _a, _b;
|
|
61
|
+
var _a, _b, _c, _d;
|
|
73
62
|
if (result.cssText) {
|
|
74
63
|
let { cssText } = result;
|
|
75
64
|
if (sourceMap) {
|
|
@@ -86,29 +75,14 @@ const transformLoader = function (content, inputSourceMap) {
|
|
|
86
75
|
moduleStore.addModule(fullPathToModule, cssText),
|
|
87
76
|
moduleStore.addModuleDependencies(fullPathToModule, this.getDependencies()),
|
|
88
77
|
]);
|
|
89
|
-
|
|
90
|
-
if (enableInMemoryCache) {
|
|
91
|
-
cache.set(this.resourcePath, {
|
|
92
|
-
code,
|
|
93
|
-
hash: contentHash,
|
|
94
|
-
sourceMap: result.sourceMap,
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
this.callback(null, code, result.sourceMap || undefined);
|
|
78
|
+
this.callback(null, `${result.code}\n\nrequire("./${cssModuleName}");`, (_c = result.sourceMap) !== null && _c !== void 0 ? _c : undefined);
|
|
98
79
|
}
|
|
99
80
|
catch (err) {
|
|
100
81
|
this.callback(err);
|
|
101
82
|
}
|
|
102
83
|
return;
|
|
103
84
|
}
|
|
104
|
-
|
|
105
|
-
cache.set(this.resourcePath, {
|
|
106
|
-
code: result.code,
|
|
107
|
-
hash: contentHash,
|
|
108
|
-
sourceMap: result.sourceMap,
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
this.callback(null, result.code, result.sourceMap || undefined);
|
|
85
|
+
this.callback(null, result.code, (_d = result.sourceMap) !== null && _d !== void 0 ? _d : undefined);
|
|
112
86
|
}, (err) => this.callback(err));
|
|
113
87
|
};
|
|
114
88
|
exports.default = transformLoader;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformLoader.js","sourceRoot":"","sources":["../../src/loaders/transformLoader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"transformLoader.js","sourceRoot":"","sources":["../../src/loaders/transformLoader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAcA,wDAAkD;AAClD,gDAAwB;AAKX,QAAA,wBAAwB,GAAG,iBAAiB,CAAC;AAC7C,QAAA,wBAAwB,GAAG,iBAAiB,CAAC;AAE7C,QAAA,qBAAqB,GAAG,yBAAyB,CAAC;AAClD,QAAA,qBAAqB,GAAG,yBAAyB,CAAC;AAClD,QAAA,eAAe,GAAG,kCAAkC,CAAC;AAUlE,SAAS,gBAAgB,CACvB,KAAgC,EAChC,QAAgB;;IAEhB,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,EAAE;QACvC,OAAO,SAAS,CAAC;KAClB;IAED,uCACK,KAAK,KACR,IAAI,EAAE,MAAA,KAAK,CAAC,IAAI,mCAAI,QAAQ,EAC5B,QAAQ,EAAE,MAAA,KAAK,CAAC,QAAQ,mCAAI,EAAE,EAC9B,KAAK,EAAE,MAAA,KAAK,CAAC,KAAK,mCAAI,EAAE,EACxB,OAAO,EAAE,MAAA,KAAK,CAAC,OAAO,mCAAI,EAAE,EAC5B,OAAO,EAAE,MAAA,KAAK,CAAC,OAAO,mCAAI,CAAC,IAC3B;AACJ,CAAC;AAED,MAAM,eAAe,GAAe,UAAU,OAAO,EAAE,cAAc;IAEnE,IAAI,CAAC,KAAK,EAAE,CAAC;IAEb,MAAM,KAKF,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,EALrB,EACJ,SAAS,GAAG,SAAS,EACrB,YAAY,GAAG,SAAS,EACxB,WAAW,OAEc,EADtB,IAAI,cAJH,4CAKL,CAA0B,CAAC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C,CAAC;aAC7B;YAED,OAAO;SACR;QAED,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,MAAA,MAAM,CAAC,SAAS,mCAAI,SAAS,CAAC,CAAC;IAClE,CAAC,EACD,CAAC,GAAU,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CACnC,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,eAAe,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-with-linaria",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Linaria support for Next.js 13 app directory feature",
|
|
5
5
|
"main": "lib/webpackConfig.js",
|
|
6
6
|
"scripts": {
|
|
@@ -11,20 +11,20 @@
|
|
|
11
11
|
"test": "pnpm test --filter ./tests/example",
|
|
12
12
|
"prepublish": "pnpm run clean && pnpm run build"
|
|
13
13
|
},
|
|
14
|
-
"packageManager": "pnpm@7.
|
|
14
|
+
"packageManager": "pnpm@7.27.1",
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@linaria/babel-preset": "4.4.
|
|
17
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
18
|
-
"@typescript-eslint/parser": "5.
|
|
19
|
-
"eslint": "8.
|
|
16
|
+
"@linaria/babel-preset": "4.4.3",
|
|
17
|
+
"@typescript-eslint/eslint-plugin": "5.53.0",
|
|
18
|
+
"@typescript-eslint/parser": "5.53.0",
|
|
19
|
+
"eslint": "8.34.0",
|
|
20
20
|
"eslint-config-prettier": "8.6.0",
|
|
21
21
|
"eslint-plugin-prettier": "4.2.1",
|
|
22
22
|
"eslint-plugin-simple-import-sort": "10.0.0",
|
|
23
23
|
"eslint-plugin-typescript-sort-keys": "2.1.0",
|
|
24
24
|
"eslint-plugin-unused-imports": "2.0.0",
|
|
25
25
|
"is-ci": "3.0.1",
|
|
26
|
-
"lint-staged": "13.1.
|
|
27
|
-
"next": "13.1
|
|
26
|
+
"lint-staged": "13.1.2",
|
|
27
|
+
"next": "13.2.1",
|
|
28
28
|
"prettier": "2.8.4",
|
|
29
29
|
"simple-git-hooks": "2.8.1",
|
|
30
30
|
"typescript": "4.9.5",
|