Skip to content

Commit

Permalink
fix: update deps, add graphql-tag-min
Browse files Browse the repository at this point in the history
  • Loading branch information
izatop committed Apr 10, 2024
1 parent 7ec72c1 commit 39abf26
Show file tree
Hide file tree
Showing 50 changed files with 307 additions and 159 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
},
"devDependencies": {
"@types/jest": "^29.5.12",
"@typescript-eslint/eslint-plugin": "^7.4.0",
"@typescript-eslint/parser": "^7.4.0",
"@typescript-eslint/eslint-plugin": "^7.6.0",
"@typescript-eslint/parser": "^7.6.0",
"coveralls": "^3.1.1",
"eslint": "^8.57.0",
"eslint-plugin-import": "^2.29.1",
Expand All @@ -39,7 +39,7 @@
"react": "^18.2.0",
"rimraf": "^5.0.5",
"ts-jest": "^29.1.2",
"typescript": "^5.4.3"
"typescript": "^5.4.4"
},
"license": "MIT",
"packageManager": "[email protected]"
Expand Down
8 changes: 4 additions & 4 deletions packages/bundle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
"@types/glob": "^8.1.0",
"dotenv": "^16.4.5",
"esbuild": "^0.20.2",
"glob": "^10.3.10",
"path-to-regexp": "^6.2.1",
"watcher": "^2.3.0"
"glob": "^10.3.12",
"path-to-regexp": "^6.2.2",
"watcher": "^2.3.1"
},
"devDependencies": {
"@types/node": "^20.11.30",
"@types/node": "^20.12.7",
"typescript-json-schema": "^0.63.0"
},
"publishConfig": {
Expand Down
34 changes: 34 additions & 0 deletions packages/graphql-tag-min/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "@reform/graphql-tag-min",
"version": "0.1",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"module": "dist/index.js",
"type": "module",
"files": [
"dist"
],
"repository": "https://github.com/izatop/reform",
"keywords": [
"esbuild",
"bundle",
"graphql",
"react",
"typescript"
],
"scripts": {
"build": "tsc"
},
"dependencies": {
"@reform/bundle": "^0.14.8",
"@types/node": "^20.12.7"
},
"publishConfig": {
"access": "public"
},
"author": {
"name": "Artur Bier",
"email": "[email protected]"
},
"license": "MIT"
}
34 changes: 34 additions & 0 deletions packages/graphql-tag-min/src/Plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {assignWithFilter, BuildContext, PluginAbstract} from "@reform/bundle";
import {readFile} from "fs/promises";

export type Config = {filter: RegExp};

const extensions = ["ts", "tsx"];
const defaultFilter = new RegExp(`\\.gql\\.(${extensions.join("|")})$`);

export class Plugin extends PluginAbstract<Config> {
public readonly name = "@reform/graphql-tag-min";

constructor(context: BuildContext, config?: Config) {
super(context, assignWithFilter({filter: defaultFilter}, config));
}

public configure(): void {
this
.on("load", this.config, async ({path}) => {
const contents = await readFile(path, {encoding: "utf-8"});

return {contents: this.#patch(contents), loader: "tsx"};
});
}

#patch(contents: string): string {
if (contents.includes("gql`")) {
return contents.replace(/gql`([^`]+)`;/g, (_, $1) => {
return `gql\`${$1.replace(/\s+/g, " ")}\`;`;
});
}

return contents;
}
}
3 changes: 3 additions & 0 deletions packages/graphql-tag-min/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import {Plugin} from "./Plugin.js";

export default Plugin;
15 changes: 15 additions & 0 deletions packages/graphql-tag-min/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "../../tsconfig.node.json",
"compilerOptions": {
"outDir": "dist",
"rootDir": "src"
},
"references": [
{
"path": "../bundle"
}
],
"include": [
"src"
]
}
2 changes: 1 addition & 1 deletion packages/graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@graphql-tools/graphql-file-loader": "^8.0.1",
"@graphql-tools/load": "^8.0.2",
"@reform/bundle": "^0.14.8",
"@types/node": "^20.11.30",
"@types/node": "^20.12.7",
"graphql": "^16.8.1",
"graphql-tag": "^2.12.6"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql/src/Plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const extensions = ["gql", "graphql"];
const defaultFilter = new RegExp(`\\.(${extensions.join("|")})$`);

export class Plugin extends PluginAbstract<Config> {
public readonly name = "@reform/bundle-graphql";
public readonly name = "@reform/graphql";

constructor(context: BuildContext, config?: Config) {
super(context, assignWithFilter({filter: defaultFilter}, config));
Expand Down
2 changes: 1 addition & 1 deletion packages/html/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"dependencies": {
"@reform/bundle": "^0.14.8",
"@types/node": "^20.11.30",
"@types/node": "^20.12.7",
"@types/parse5": "^7.0.0",
"esbuild": "^0.20.2",
"parse5": "^7.1.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/html/src/Plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const artifacts = "^.+$";
export const attach: AttachFileType[] = ["stylesheet"];

export class Plugin extends PluginAbstract<Config> {
public readonly name = "@reform/bundle-html-entry";
public readonly name = "@reform/html";

readonly #documents = new Map<string, DocFile>();

Expand Down
2 changes: 1 addition & 1 deletion packages/sass/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"dependencies": {
"@reform/bundle": "^0.14.8",
"@types/node": "^20.11.30",
"@types/node": "^20.12.7",
"@types/node-sass": "^4.11.7",
"node-sass": "^9.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/sass/src/Plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type Config = {filter: RegExp; resolves?: string[]; compress?: boolean};
const stripRe = /[?#].+$/;

export class Plugin extends PluginAbstract<Config> {
public readonly name = "@reform/bundle-sass";
public readonly name = "@reform/sass";

constructor(context: BuildContext, config?: Config) {
super(context, assignWithFilter({filter: /\.(scss|sass)$/}, config));
Expand Down
3 changes: 2 additions & 1 deletion packages/test/bundle.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"base": "src",
"plugins": {
"@reform/sass": {},
"@reform/html": {}
"@reform/html": {},
"@reform/graphql-tag-min": {}
},
"bundle": true,
"format": "esm",
Expand Down
7 changes: 4 additions & 3 deletions packages/test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"test": "yarn build"
},
"devDependencies": {
"@fortawesome/fontawesome-free": "^6.5.1",
"@fortawesome/fontawesome-free": "^6.5.2",
"@reform/bundle": "^0.14.8",
"esbuild": "^0.20.2",
"graphql": "^16.8.1"
Expand All @@ -20,8 +20,9 @@
"private": true,
"license": "MIT",
"dependencies": {
"@types/react": "^18.2.71",
"@types/react-dom": "^18.2.22",
"@types/react": "^18.2.75",
"@types/react-dom": "^18.2.24",
"graphql-tag": "^2.12.6",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
Expand Down
5 changes: 4 additions & 1 deletion packages/test/src/page/Hello.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import icon from "../icons/icon.png";
import svg from "../icons/icon.svg";
import {HelloQuery} from "../query";
import {HelloQuery, InlineQuery1, InlineQuery2} from "../query";
import {Card} from "./Card";

export const Hello: React.FC = () => {
Expand All @@ -24,6 +24,9 @@ export const Hello: React.FC = () => {
<section>
<pre>{JSON.stringify(HelloQuery, null, 2)}</pre>
</section>
<section>
<pre>{JSON.stringify({InlineQuery1, InlineQuery2}, null, 2)}</pre>
</section>
</div>
);
};
2 changes: 2 additions & 0 deletions packages/test/src/query/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

import HelloQuery from "./HelloQuery.graphql";

export * from "./inline.gql";
export {HelloQuery};
9 changes: 9 additions & 0 deletions packages/test/src/query/inline.gql.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import gql from "graphql-tag";

export const InlineQuery1 = gql`query InlineQuery1 {
message
}`;

export const InlineQuery2 = gql`query InlineQuery2 {
message
}`;
3 changes: 3 additions & 0 deletions packages/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
{
"path": "graphql"
},
{
"path": "graphql-tag-min"
},
{
"path": "html"
}
Expand Down
Loading

0 comments on commit 39abf26

Please sign in to comment.