@companion-module/tools 1.0.2 → 1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.2.0](https://github.com/bitfocus/companion-module-tools/compare/v1.1.0...v1.2.0) (2023-03-06)
4
+
5
+
6
+ ### Features
7
+
8
+ * flatten directory structure for extra files ([edfff7d](https://github.com/bitfocus/companion-module-tools/commit/edfff7dc2d41d8215cde2b9d9158a08cbecb62e3))
9
+
10
+ ## [1.1.0](https://github.com/bitfocus/companion-module-tools/compare/v1.0.2...v1.1.0) (2023-02-22)
11
+
12
+
13
+ ### Features
14
+
15
+ * add `--dev` parameter to produce a `development` webpack build ([ffb36bc](https://github.com/bitfocus/companion-module-tools/commit/ffb36bcd9cb5109eed0bbb05da22b4ea00745b34))
16
+ * allow modules to specify additional webpack plugins ([3dc1f5f](https://github.com/bitfocus/companion-module-tools/commit/3dc1f5f0da879c31dab0395ac6d012ad810ad4ad))
17
+
3
18
  ## [1.0.2](https://github.com/bitfocus/companion-module-tools/compare/v1.0.1...v1.0.2) (2023-02-19)
4
19
 
5
20
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@companion-module/tools",
3
- "version": "1.0.2",
3
+ "version": "1.2.0",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "license": "MIT",
package/scripts/build.js CHANGED
@@ -30,9 +30,12 @@ console.log(`Framework path: ${frameworkDir}`)
30
30
  // clean old
31
31
  await fs.remove('pkg')
32
32
 
33
+ const webpackArgs = []
34
+ if (argv.dev) webpackArgs.push('--env', 'dev')
35
+
33
36
  // build the code
34
37
  const webpackConfig = path.join(toolsDir, 'webpack.config.cjs').replace(/\\/g, '/') // Fix slashes because windows is a pain
35
- await $`yarn webpack -c ${webpackConfig}`
38
+ await $`yarn webpack -c ${webpackConfig} ${webpackArgs}`
36
39
 
37
40
  // copy in the metadata
38
41
  await fs.copy('companion', 'pkg/companion')
@@ -104,8 +107,7 @@ if (fs.existsSync(webpackExtPath)) {
104
107
  if (Array.isArray(webpackExt.extraFiles)) {
105
108
  const files = await globby(webpackExt.extraFiles)
106
109
  for (const file of files) {
107
- await fs.copy(file, path.join('pkg', file), {
108
- recursive: true,
110
+ await fs.copy(file, path.join('pkg', path.basename(file)), {
109
111
  overwrite: false,
110
112
  })
111
113
  }
@@ -18,40 +18,45 @@ let externalsExt = []
18
18
  if (Array.isArray(webpackExt.externals)) externalsExt = webpackExt.externals
19
19
  else if (webpackExt.externals) externalsExt = [webpackExt.externals]
20
20
 
21
- module.exports = {
22
- entry: {
23
- main: './' + pkgJson.main, // path.join(frameworkDir, 'dist/entrypoint.js'),
24
- // Allow for custom entrypoints
25
- ...webpackExt.entry,
26
- },
27
- mode: 'production',
28
- // devtool: 'source-map', // TODO - this would be nice, but I think the files have to be uploaded directly to sentry which is problematic...
29
- // mode: 'development',
30
- output: {
31
- path: path.resolve(process.cwd(), 'pkg'),
32
- },
33
- context: path.resolve(process.cwd(), '.'),
34
- target: 'node',
35
- externals: [
36
- // Allow for custom externals
37
- ...externalsExt,
38
- ],
39
- experiments: {
40
- topLevelAwait: true,
41
- },
42
- module: {
43
- rules: [
44
- // {
45
- // test: /\.json$/,
46
- // type: 'asset/source',
47
- // },
48
- // {
49
- // test: /BUILD$/,
50
- // type: 'asset/resource',
51
- // generator: {
52
- // filename: 'BUILD',
53
- // },
54
- // },
21
+ module.exports = async (env) => {
22
+ return {
23
+ entry: {
24
+ main: './' + pkgJson.main, // path.join(frameworkDir, 'dist/entrypoint.js'),
25
+ // Allow for custom entrypoints
26
+ ...webpackExt.entry,
27
+ },
28
+ mode: env.dev ? 'development' : 'production',
29
+ // devtool: env.dev ? undefined : 'source-map', // TODO - this would be nice, but I think the files have to be uploaded directly to sentry which is problematic...
30
+ output: {
31
+ path: path.resolve(process.cwd(), 'pkg'),
32
+ },
33
+ context: path.resolve(process.cwd(), '.'),
34
+ target: 'node',
35
+ externals: [
36
+ // Allow for custom externals
37
+ ...externalsExt,
55
38
  ],
56
- },
39
+ experiments: {
40
+ topLevelAwait: true,
41
+ },
42
+ module: {
43
+ rules: [
44
+ // {
45
+ // test: /\.json$/,
46
+ // type: 'asset/source',
47
+ // },
48
+ // {
49
+ // test: /BUILD$/,
50
+ // type: 'asset/resource',
51
+ // generator: {
52
+ // filename: 'BUILD',
53
+ // },
54
+ // },
55
+ ],
56
+ },
57
+ plugins: [
58
+ // Let modules define additional plugins. Hopefully this won't conflict with anything we add
59
+ ...(webpackExt.plugins || []),
60
+ ],
61
+ }
57
62
  }