canopy-webpack-config 4.1.1 → 4.2.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/CODEOWNERS ADDED
@@ -0,0 +1 @@
1
+ * @CanopyTax/frontend-leads
package/README.md CHANGED
@@ -81,3 +81,17 @@ canopy-webpack-config assumes a few things about your project and provides defau
81
81
  the webpack config for canopy-webpack-config will always create the output bundle in the directory that the webpack process was started in. This
82
82
  is different than how webpack configs normally work -- they usually create the output bundle in relation to the directory in which the webpack config
83
83
  file is placed.
84
+
85
+ ## Optional modifiers
86
+ We support a few config options for builds, including typescript and an externals submodule.
87
+ ```
88
+ module.exports = canopyWebpackConfig('login-ui', {}, {
89
+ typescript: true,
90
+ externals: true
91
+ })
92
+ ```
93
+ ### Typescript `<bool>`
94
+ Pass an options object with `{typescript: true}` when your service uss typescript.
95
+
96
+ ### Externals `<bool>`
97
+ Pass an options object with `{externals: true}` when you are looking to export a submodule from `/src/externals.{js|ts}`. This should be for exports that must be imported synchronously such as hooks or queries that do not have other internal dependencies (to avoid circular dependencies).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "canopy-webpack-config",
3
- "version": "4.1.1",
3
+ "version": "4.2.0",
4
4
  "description": "Some defaults for webpack configs at canopy",
5
5
  "main": "src/canopy-webpack-config.js",
6
6
  "repository": "git@github.com:CanopyTax/canopy-webpack-config.git",
@@ -24,7 +24,8 @@ const port =
24
24
  ? process.argv[portIndex + 1]
25
25
  : "8080";
26
26
 
27
- module.exports = function (name, overridesConfig = {}, typescript) {
27
+ module.exports = function (name, overridesConfig = {}, options = {}) {
28
+ const { typescript, externals } = options;
28
29
  if (typeof name !== "string") {
29
30
  throw new Error(
30
31
  "canopy-webpack-config expects a string name as the first argument"
@@ -47,9 +48,14 @@ module.exports = function (name, overridesConfig = {}, typescript) {
47
48
  }
48
49
 
49
50
  const defaultCanopyConfig = {
50
- entry: `./src/${name}.${typescript ? "ts" : "js"}`,
51
+ entry: {
52
+ [name]: `./src/${name}.${typescript ? "ts" : "js"}`,
53
+ ...(externals && {
54
+ externals: `./src/externals.${typescript ? "ts" : "js"}`,
55
+ }),
56
+ },
51
57
  output: {
52
- filename: `${name}.js`,
58
+ filename: (pathData) => `${pathData.chunk.name}.js`,
53
59
  publicPath: "",
54
60
  uniqueName: name,
55
61
  library: {