-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better build flow for GraphiQL (#60)
- Loading branch information
1 parent
2a3848f
commit 9d6adb7
Showing
12 changed files
with
1,773 additions
and
721 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"graphql-helix": patch | ||
--- | ||
|
||
Improve build flow for GraphiQL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ node_modules | |
!.prettierignore | ||
!.prettierrc | ||
!.eslintrc.json | ||
!.eslintignore | ||
!.eslintignore | ||
yarn-error.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* eslint-disable no-console */ | ||
const { build } = require("esbuild"); | ||
const { readFileSync, writeFileSync } = require("fs"); | ||
|
||
const templateFile = "../core/lib/render-graphiql.template.ts"; | ||
const outputFile = "../core/lib/render-graphiql.ts"; | ||
|
||
function escapeString(str) { | ||
return JSON.stringify(str); | ||
} | ||
|
||
(async function main() { | ||
console.info(`Compiling GraphiQL TypeScript...`); | ||
const jsBuild = await build({ | ||
entryPoints: ["src/index.tsx"], | ||
bundle: true, | ||
globalName: "GraphQLHelixGraphiQL", | ||
write: false, | ||
target: ["es2018"], | ||
minify: true, | ||
minifyWhitespace: true, | ||
legalComments: "none", | ||
define: { | ||
"process.env.NODE_ENV": JSON.stringify("production"), | ||
"process.env.NODE_DEBUG": "undefined", | ||
setImmediate: "setTimeout", | ||
global: "window", | ||
}, | ||
}); | ||
|
||
console.info(`Compiling GraphiQL CSS...`); | ||
const cssBuild = await build({ | ||
entryPoints: ["src/css/graphiql.css"], | ||
bundle: true, | ||
write: false, | ||
minify: true, | ||
legalComments: "none", | ||
}); | ||
|
||
console.info(`Loading GraphiQL template from ${templateFile}`); | ||
const tempalteFile = readFileSync(templateFile, "utf8"); | ||
|
||
console.info(`Building GraphiQL static files...`); | ||
const output = tempalteFile | ||
.replace(`"{CSS}"`, () => escapeString(cssBuild.outputFiles[0].text)) | ||
.replace(`"{JS}"`, () => escapeString(jsBuild.outputFiles[0].text)); | ||
|
||
console.info(`Writing GraphiQL render file to ${templateFile}`); | ||
writeFileSync(outputFile, output); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.