@nlabs/lex 1.31.0 → 1.32.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/LexConfig.js CHANGED
@@ -66,24 +66,10 @@ class LexConfig {
66
66
  sourceFullPath: path.resolve(cwd, "./src"),
67
67
  sourcePath: "./src",
68
68
  targetEnvironment: "web",
69
+ useGraphQl: false,
69
70
  useTypescript: false,
70
71
  webpack: {}
71
72
  };
72
- static updateConfig(updatedConfig) {
73
- const { outputFullPath, outputPath, sourcePath, sourceFullPath, useTypescript } = updatedConfig;
74
- const cwd2 = process.cwd();
75
- if (useTypescript !== void 0) {
76
- LexConfig.useTypescript = useTypescript;
77
- }
78
- if (outputPath !== void 0 && outputFullPath === void 0) {
79
- updatedConfig.outputFullPath = path.resolve(cwd2, outputPath);
80
- }
81
- if (sourcePath !== void 0 && sourceFullPath === void 0) {
82
- updatedConfig.sourceFullPath = path.resolve(cwd2, sourcePath);
83
- }
84
- LexConfig.config = __spreadValues(__spreadValues({}, LexConfig.config), updatedConfig);
85
- return LexConfig.config;
86
- }
87
73
  static set useTypescript(value) {
88
74
  LexConfig.config.useTypescript = value;
89
75
  const { sourceFullPath } = LexConfig.config;
@@ -98,6 +84,21 @@ class LexConfig {
98
84
  }
99
85
  }
100
86
  }
87
+ static updateConfig(updatedConfig) {
88
+ const { outputFullPath, outputPath, sourcePath, sourceFullPath, useGraphQl, useTypescript } = updatedConfig;
89
+ const cwd2 = process.cwd();
90
+ if (useTypescript !== void 0) {
91
+ LexConfig.useTypescript = useTypescript;
92
+ }
93
+ if (outputPath !== void 0 && outputFullPath === void 0) {
94
+ updatedConfig.outputFullPath = path.resolve(cwd2, outputPath);
95
+ }
96
+ if (sourcePath !== void 0 && sourceFullPath === void 0) {
97
+ updatedConfig.sourceFullPath = path.resolve(cwd2, sourcePath);
98
+ }
99
+ LexConfig.config = __spreadValues(__spreadValues({}, LexConfig.config), updatedConfig);
100
+ return LexConfig.config;
101
+ }
101
102
  static addConfigParams(cmd, params) {
102
103
  const nameProperty = "_name";
103
104
  const { environment, outputPath, sourcePath, typescript } = cmd;
@@ -45,6 +45,8 @@ __export(build_exports, {
45
45
  buildWithEsBuild: () => buildWithEsBuild,
46
46
  buildWithWebpack: () => buildWithWebpack
47
47
  });
48
+ var import_esbuild_graphql_loader = __toESM(require("@luckycatfactory/esbuild-graphql-loader"));
49
+ var import_esbuild = require("esbuild");
48
50
  var import_execa = __toESM(require("execa"));
49
51
  var path = __toESM(require("path"));
50
52
  var import_LexConfig = require("../LexConfig");
@@ -59,28 +61,33 @@ const buildWithEsBuild = async (spinner, cmd, callback) => {
59
61
  } = cmd;
60
62
  const {
61
63
  targetEnvironment = "node14",
64
+ useGraphQl,
62
65
  useTypescript
63
66
  } = import_LexConfig.LexConfig.config;
64
- const nodePath = path.resolve(__dirname, "../../node_modules");
65
- const esbuildPath = (0, import_utils.relativeFilePath)("esbuild/bin/esbuild", nodePath);
66
- const esbuildOptions = [
67
- "--bundle",
68
- sourcePath,
69
- "--color=true",
70
- "--loader:.js=js",
71
- `--outdir=${outputPath}`,
72
- "--platform=node",
73
- "--sourcemap=inline",
74
- `--target=${targetEnvironment}`
75
- ];
67
+ const loader = {
68
+ ".js": "js"
69
+ };
76
70
  if (useTypescript) {
77
- esbuildOptions.push("--loader:.ts=ts", "--loader:.tsx=tsx");
71
+ loader[".ts"] = "ts";
72
+ loader[".tsx"] = "tsx";
78
73
  }
79
- if (watch) {
80
- esbuildOptions.push("--watch");
74
+ const plugins = [];
75
+ if (useGraphQl) {
76
+ plugins.push((0, import_esbuild_graphql_loader.default)());
81
77
  }
82
78
  try {
83
- await (0, import_execa.default)(esbuildPath, esbuildOptions, { encoding: "utf-8" });
79
+ await (0, import_esbuild.build)({
80
+ bundle: true,
81
+ color: true,
82
+ entryPoints: [sourcePath],
83
+ loader,
84
+ outdir: outputPath,
85
+ platform: "node",
86
+ plugins,
87
+ sourcemap: "inline",
88
+ target: targetEnvironment,
89
+ watch
90
+ });
84
91
  spinner.succeed("Build completed successfully!");
85
92
  } catch (error) {
86
93
  (0, import_utils.log)(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nlabs/lex",
3
- "version": "1.31.0",
3
+ "version": "1.32.0",
4
4
  "description": "Lex",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -46,6 +46,7 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@hot-loader/react-dom": "17.0.2",
49
+ "@luckycatfactory/esbuild-graphql-loader": "^3.7.0",
49
50
  "@nlabs/gothamjs": "^0.8.2",
50
51
  "@nlabs/webpack-plugin-static-site": "^0.1.1",
51
52
  "acorn": "^8.7.0",
@@ -65,6 +66,7 @@
65
66
  "cssnano": "^5.0.16",
66
67
  "dotenv-webpack": "^7.1.0",
67
68
  "download-npm-package": "^3.1.12",
69
+ "esbuild": "^0.14.18",
68
70
  "esbuild-jest": "^0.5.0",
69
71
  "esbuild-loader": "^2.18.0",
70
72
  "execa": "5",
@@ -74,6 +76,7 @@
74
76
  "find-file-up": "^2.0.1",
75
77
  "fs-extra": "^10.0.0",
76
78
  "glob": "^7.2.0",
79
+ "graphql": "^16.3.0",
77
80
  "graphql-tag": "^2.12.6",
78
81
  "html-loader": "^3.1.0",
79
82
  "html-webpack-plugin": "^5.5.0",
@@ -144,5 +147,5 @@
144
147
  "eslint-config-styleguidejs": "^1.5.4",
145
148
  "lerna": "^4.0.0"
146
149
  },
147
- "gitHead": "4f93d9421e7f03819a61e71c6e51af5597dbf4ce"
150
+ "gitHead": "3b0984b831a687a1d274bb8ebf14f2cbb2a66c8a"
148
151
  }