Skip to content

Commit

Permalink
Build generate-umd as well
Browse files Browse the repository at this point in the history
  • Loading branch information
rynobax committed May 10, 2020
1 parent d263a52 commit f7f5d6d
Show file tree
Hide file tree
Showing 5 changed files with 700 additions and 27 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"np": "^6.2.3",
"prettier": "^2.0.2",
"rollup": "^2.9.0",
"rollup-plugin-node-builtins": "^2.1.2",
"typescript": "^3.8.3"
},
"husky": {
Expand Down
64 changes: 43 additions & 21 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,52 @@
import commonjs from "@rollup/plugin-commonjs";
import resolve from "@rollup/plugin-node-resolve";
import babel from "@rollup/plugin-babel";
import builtins from "rollup-plugin-node-builtins";

const extensions = [".ts", ".js", ".json"];

export default {
input: "src/cli.ts",
output: [
{
export default [
// cjs
{
input: "src/cli.ts",
output: {
dir: "build",
format: "cjs",
},
],
plugins: [
babel({ babelHelpers: "bundled", extensions }),
resolve({ extensions, rootDir: "src" }),
commonjs({ extensions }),
],
external: [
/node_modules/,
"graphql",
"glob",
"@oclif/command",
"@graphql-toolkit/graphql-tag-pluck",
"lodash",
"prettier",
"@oclif/errors/handle",
],
};
plugins: [
babel({ babelHelpers: "bundled", extensions }),
resolve({ extensions, rootDir: "src" }),
commonjs({ extensions }),
],
// Prevent rollup from including node_modules
// I don't feel like including every package explicitly is the right way
// to do this, but it works for now
external: [
/node_modules/,
"graphql",
"glob",
"@oclif/command",
"@graphql-toolkit/graphql-tag-pluck",
"lodash/capitalize",
"lodash/flatMap",
"lodash/uniq",
"prettier",
"@oclif/errors/handle",
],
},
// UMD for demo web page
{
input: "src/generate.ts",
output: {
file: "build/generate-umd.js",
format: "umd",
name: "ts-graphql-gen",
},
plugins: [
babel({ babelHelpers: "bundled", extensions }),
resolve({ extensions, rootDir: "src" }),
commonjs({ extensions }),
builtins(),
],
},
];
3 changes: 2 additions & 1 deletion src/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import {
SelectionSetNode,
GraphQLError,
} from "graphql";
import { capitalize, flatMap } from "lodash";
import capitalize from "lodash/capitalize";
import flatMap from "lodash/flatMap";

import {
Document,
Expand Down
2 changes: 1 addition & 1 deletion src/print.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EOL } from "os";
import { uniq } from "lodash";
import uniq from "lodash/uniq";

import {
SchemaTypeSummary,
Expand Down
Loading

0 comments on commit f7f5d6d

Please sign in to comment.