@mochi-css/next 1.1.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/chunk-nOFOJqeH.js +30 -0
- package/dist/index.d.mts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +39 -0
- package/dist/index.mjs +42 -0
- package/dist/loader.d.mts +12 -0
- package/dist/loader.d.ts +11 -0
- package/dist/loader.js +35 -0
- package/dist/loader.mjs +32 -0
- package/package.json +47 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
|
|
25
|
+
Object.defineProperty(exports, '__toESM', {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return __toESM;
|
|
29
|
+
}
|
|
30
|
+
});
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NextConfig } from "next";
|
|
2
|
+
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
type MochiNextOptions = {
|
|
5
|
+
manifestPath?: string;
|
|
6
|
+
};
|
|
7
|
+
declare function withMochi(nextConfig: NextConfig, opts?: MochiNextOptions): NextConfig;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { MochiNextOptions, withMochi };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NextConfig } from "next";
|
|
2
|
+
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
type MochiNextOptions = {
|
|
5
|
+
manifestPath?: string;
|
|
6
|
+
};
|
|
7
|
+
declare function withMochi(nextConfig: NextConfig, opts?: MochiNextOptions): NextConfig;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { MochiNextOptions, withMochi };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-nOFOJqeH.js');
|
|
2
|
+
let path = require("path");
|
|
3
|
+
path = require_chunk.__toESM(path);
|
|
4
|
+
|
|
5
|
+
//#region src/index.ts
|
|
6
|
+
const MOCHI_DIR = ".mochi";
|
|
7
|
+
const MANIFEST_FILE = "manifest.json";
|
|
8
|
+
function withMochi(nextConfig, opts) {
|
|
9
|
+
const manifestPath = opts?.manifestPath ?? path.default.resolve(MOCHI_DIR, MANIFEST_FILE);
|
|
10
|
+
const loaderPath = require.resolve("@mochi-css/next/loader");
|
|
11
|
+
const loaderRule = {
|
|
12
|
+
test: /\.(ts|tsx|js|jsx)$/,
|
|
13
|
+
use: [{
|
|
14
|
+
loader: loaderPath,
|
|
15
|
+
options: { manifestPath }
|
|
16
|
+
}]
|
|
17
|
+
};
|
|
18
|
+
const turbopack = nextConfig["turbopack"] ?? {};
|
|
19
|
+
const turboRules = turbopack["rules"] ?? {};
|
|
20
|
+
turboRules["*.{ts,tsx,js,jsx}"] = { loaders: [{
|
|
21
|
+
loader: loaderPath,
|
|
22
|
+
options: { manifestPath }
|
|
23
|
+
}] };
|
|
24
|
+
turbopack["rules"] = turboRules;
|
|
25
|
+
const existingWebpack = nextConfig["webpack"];
|
|
26
|
+
return {
|
|
27
|
+
...nextConfig,
|
|
28
|
+
turbopack,
|
|
29
|
+
webpack(config, context) {
|
|
30
|
+
const moduleConfig = config["module"];
|
|
31
|
+
if (moduleConfig?.rules) moduleConfig.rules.push(loaderRule);
|
|
32
|
+
if (existingWebpack) return existingWebpack(config, context);
|
|
33
|
+
return config;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
exports.withMochi = withMochi;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
//#region rolldown:runtime
|
|
5
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/index.ts
|
|
9
|
+
const MOCHI_DIR = ".mochi";
|
|
10
|
+
const MANIFEST_FILE = "manifest.json";
|
|
11
|
+
function withMochi(nextConfig, opts) {
|
|
12
|
+
const manifestPath = opts?.manifestPath ?? path.resolve(MOCHI_DIR, MANIFEST_FILE);
|
|
13
|
+
const loaderPath = __require.resolve("@mochi-css/next/loader");
|
|
14
|
+
const loaderRule = {
|
|
15
|
+
test: /\.(ts|tsx|js|jsx)$/,
|
|
16
|
+
use: [{
|
|
17
|
+
loader: loaderPath,
|
|
18
|
+
options: { manifestPath }
|
|
19
|
+
}]
|
|
20
|
+
};
|
|
21
|
+
const turbopack = nextConfig["turbopack"] ?? {};
|
|
22
|
+
const turboRules = turbopack["rules"] ?? {};
|
|
23
|
+
turboRules["*.{ts,tsx,js,jsx}"] = { loaders: [{
|
|
24
|
+
loader: loaderPath,
|
|
25
|
+
options: { manifestPath }
|
|
26
|
+
}] };
|
|
27
|
+
turbopack["rules"] = turboRules;
|
|
28
|
+
const existingWebpack = nextConfig["webpack"];
|
|
29
|
+
return {
|
|
30
|
+
...nextConfig,
|
|
31
|
+
turbopack,
|
|
32
|
+
webpack(config, context) {
|
|
33
|
+
const moduleConfig = config["module"];
|
|
34
|
+
if (moduleConfig?.rules) moduleConfig.rules.push(loaderRule);
|
|
35
|
+
if (existingWebpack) return existingWebpack(config, context);
|
|
36
|
+
return config;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { withMochi };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/loader.d.ts
|
|
2
|
+
type LoaderContext = {
|
|
3
|
+
resourcePath: string;
|
|
4
|
+
getOptions(): {
|
|
5
|
+
manifestPath: string;
|
|
6
|
+
};
|
|
7
|
+
addDependency(path: string): void;
|
|
8
|
+
callback(err: Error | null, content?: string, sourceMap?: unknown): void;
|
|
9
|
+
};
|
|
10
|
+
declare function mochiLoader(this: LoaderContext, source: string): void;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { mochiLoader as default };
|
package/dist/loader.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/loader.d.ts
|
|
2
|
+
type LoaderContext = {
|
|
3
|
+
resourcePath: string;
|
|
4
|
+
getOptions(): {
|
|
5
|
+
manifestPath: string;
|
|
6
|
+
};
|
|
7
|
+
addDependency(path: string): void;
|
|
8
|
+
callback(err: Error | null, content?: string, sourceMap?: unknown): void;
|
|
9
|
+
};
|
|
10
|
+
declare function mochiLoader(this: LoaderContext, source: string): void;
|
|
11
|
+
export = mochiLoader;
|
package/dist/loader.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-nOFOJqeH.js');
|
|
2
|
+
let path = require("path");
|
|
3
|
+
path = require_chunk.__toESM(path);
|
|
4
|
+
let fs = require("fs");
|
|
5
|
+
fs = require_chunk.__toESM(fs);
|
|
6
|
+
|
|
7
|
+
//#region src/loader.ts
|
|
8
|
+
function injectImports(ctx, manifest, source) {
|
|
9
|
+
const cssPath = manifest.files[ctx.resourcePath];
|
|
10
|
+
if (!cssPath) return source;
|
|
11
|
+
const imports = [];
|
|
12
|
+
const absoluteCssPath = path.default.resolve(cssPath);
|
|
13
|
+
imports.push(`import ${JSON.stringify(absoluteCssPath)};`);
|
|
14
|
+
ctx.addDependency(absoluteCssPath);
|
|
15
|
+
if (manifest.global) {
|
|
16
|
+
const absoluteGlobalPath = path.default.resolve(manifest.global);
|
|
17
|
+
imports.push(`import ${JSON.stringify(absoluteGlobalPath)};`);
|
|
18
|
+
ctx.addDependency(absoluteGlobalPath);
|
|
19
|
+
}
|
|
20
|
+
return imports.join("\n") + "\n" + source;
|
|
21
|
+
}
|
|
22
|
+
function mochiLoader(source) {
|
|
23
|
+
const { manifestPath } = this.getOptions();
|
|
24
|
+
this.addDependency(manifestPath);
|
|
25
|
+
if (!fs.default.existsSync(manifestPath)) {
|
|
26
|
+
this.callback(null, source);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const content = fs.default.readFileSync(manifestPath, "utf-8");
|
|
30
|
+
const manifest = JSON.parse(content);
|
|
31
|
+
this.callback(null, injectImports(this, manifest, source));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
module.exports = mochiLoader;
|
package/dist/loader.mjs
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
|
|
4
|
+
//#region src/loader.ts
|
|
5
|
+
function injectImports(ctx, manifest, source) {
|
|
6
|
+
const cssPath = manifest.files[ctx.resourcePath];
|
|
7
|
+
if (!cssPath) return source;
|
|
8
|
+
const imports = [];
|
|
9
|
+
const absoluteCssPath = path.resolve(cssPath);
|
|
10
|
+
imports.push(`import ${JSON.stringify(absoluteCssPath)};`);
|
|
11
|
+
ctx.addDependency(absoluteCssPath);
|
|
12
|
+
if (manifest.global) {
|
|
13
|
+
const absoluteGlobalPath = path.resolve(manifest.global);
|
|
14
|
+
imports.push(`import ${JSON.stringify(absoluteGlobalPath)};`);
|
|
15
|
+
ctx.addDependency(absoluteGlobalPath);
|
|
16
|
+
}
|
|
17
|
+
return imports.join("\n") + "\n" + source;
|
|
18
|
+
}
|
|
19
|
+
function mochiLoader(source) {
|
|
20
|
+
const { manifestPath } = this.getOptions();
|
|
21
|
+
this.addDependency(manifestPath);
|
|
22
|
+
if (!fs.existsSync(manifestPath)) {
|
|
23
|
+
this.callback(null, source);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const content = fs.readFileSync(manifestPath, "utf-8");
|
|
27
|
+
const manifest = JSON.parse(content);
|
|
28
|
+
this.callback(null, injectImports(this, manifest, source));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { mochiLoader as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mochi-css/next",
|
|
3
|
+
"repository": "git@github.com:Niikelion/mochi-css.git",
|
|
4
|
+
"version": "1.1.0",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.mjs",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"/dist"
|
|
11
|
+
],
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": {
|
|
15
|
+
"types": "./dist/index.d.mts",
|
|
16
|
+
"import": "./dist/index.mjs"
|
|
17
|
+
},
|
|
18
|
+
"require": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"require": "./dist/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"./loader": {
|
|
24
|
+
"import": {
|
|
25
|
+
"types": "./dist/loader.d.mts",
|
|
26
|
+
"import": "./dist/loader.mjs"
|
|
27
|
+
},
|
|
28
|
+
"require": {
|
|
29
|
+
"types": "./dist/loader.d.ts",
|
|
30
|
+
"require": "./dist/loader.js"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsc --noEmit && tsdown"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@arethetypeswrong/cli": "^0.18.2",
|
|
39
|
+
"@gamedev-sensei/ts-config": "^2.1.0",
|
|
40
|
+
"@gamedev-sensei/tsdown-config": "^2.1.0",
|
|
41
|
+
"@types/node": "^24.8.1",
|
|
42
|
+
"tsdown": "^0.15.7"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"next": "^14 || ^15 || ^16"
|
|
46
|
+
}
|
|
47
|
+
}
|