@rushstack/heft-web-rig 0.7.2 → 0.9.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.
@@ -4,32 +4,133 @@
4
4
  {
5
5
  "$schema": "https://developer.microsoft.com/json-schemas/heft/heft.schema.json",
6
6
 
7
+ /**
8
+ * Optionally specifies another JSON config file that this file extends from. This provides a way for standard
9
+ * settings to be shared across multiple projects.
10
+ */
11
+ // "extends": "base-project/config/heft.json",
12
+
7
13
  "eventActions": [
14
+ // {
15
+ // /**
16
+ // * (Required) The kind of built-in operation that should be performed.
17
+ // * The "deleteGlobs" action deletes files or folders that match the specified glob patterns.
18
+ // */
19
+ // "actionKind": "deleteGlobs",
20
+ //
21
+ // /**
22
+ // * (Required) The Heft stage when this action should be performed. Note that heft.json event actions
23
+ // * are scheduled after any plugin tasks have processed the event. For example, a "compile" event action
24
+ // * will be performed after the TypeScript compiler has been invoked.
25
+ // *
26
+ // * Options: "clean", "pre-compile", "compile", "bundle", "post-build"
27
+ // */
28
+ // "heftEvent": "clean",
29
+ //
30
+ // /**
31
+ // * (Required) A user-defined tag whose purpose is to allow configs to replace/delete handlers that
32
+ // * were added by other configs.
33
+ // */
34
+ // "actionId": "my-example-action",
35
+ //
36
+ // /**
37
+ // * (Required) Glob patterns to be deleted. The paths are resolved relative to the project folder.
38
+ // * Documentation for supported glob syntaxes: https://www.npmjs.com/package/fast-glob
39
+ // */
40
+ // "globsToDelete": [
41
+ // "dist",
42
+ // "lib",
43
+ // "lib-esnext",
44
+ // "temp"
45
+ // ]
46
+ // },
47
+ //
48
+ // {
49
+ // /**
50
+ // * (Required) The kind of built-in operation that should be performed.
51
+ // * The "copyFiles" action copies files that match the specified patterns.
52
+ // */
53
+ // "actionKind": "copyFiles",
54
+ //
55
+ // /**
56
+ // * (Required) The Heft stage when this action should be performed. Note that heft.json event actions
57
+ // * are scheduled after any plugin tasks have processed the event. For example, a "compile" event action
58
+ // * will be performed after the TypeScript compiler has been invoked.
59
+ // *
60
+ // * Options: "pre-compile", "compile", "bundle", "post-build"
61
+ // */
62
+ // "heftEvent": "pre-compile",
63
+ //
64
+ // /**
65
+ // * (Required) A user-defined tag whose purpose is to allow configs to replace/delete handlers that
66
+ // * were added by other configs.
67
+ // */
68
+ // "actionId": "my-example-action",
69
+ //
70
+ // /**
71
+ // * (Required) An array of copy operations to run perform during the specified Heft event.
72
+ // */
73
+ // "copyOperations": [
74
+ // {
75
+ // /**
76
+ // * (Required) The base folder that files will be copied from, relative to the project root.
77
+ // * Settings such as "includeGlobs" and "excludeGlobs" will be resolved relative
78
+ // * to this folder.
79
+ // * NOTE: Assigning "sourceFolder" does not by itself select any files to be copied.
80
+ // */
81
+ // "sourceFolder": "src",
82
+ //
83
+ // /**
84
+ // * (Required) One or more folders that files will be copied into, relative to the project root.
85
+ // * If you specify more than one destination folder, Heft will read the input files only once, using
86
+ // * streams to efficiently write multiple outputs.
87
+ // */
88
+ // "destinationFolders": ["dist/assets"],
89
+ //
90
+ // /**
91
+ // * If specified, this option recursively scans all folders under "sourceFolder" and includes any files
92
+ // * that match the specified extensions. (If "fileExtensions" and "includeGlobs" are both
93
+ // * specified, their selections are added together.)
94
+ // */
95
+ // "fileExtensions": [".jpg", ".png"],
96
+ //
97
+ // /**
98
+ // * A list of glob patterns that select files to be copied. The paths are resolved relative
99
+ // * to "sourceFolder".
100
+ // * Documentation for supported glob syntaxes: https://www.npmjs.com/package/fast-glob
101
+ // */
102
+ // "includeGlobs": ["assets/*.md"],
103
+ //
104
+ // /**
105
+ // * A list of glob patterns that exclude files/folders from being copied. The paths are resolved relative
106
+ // * to "sourceFolder". These exclusions eliminate items that were selected by the "includeGlobs"
107
+ // * or "fileExtensions" setting.
108
+ // */
109
+ // "excludeGlobs": [],
110
+ //
111
+ // /**
112
+ // * Normally, when files are selected under a child folder, a corresponding folder will be created in
113
+ // * the destination folder. Specify flatten=true to discard the source path and copy all matching files
114
+ // * to the same folder. If two files have the same name an error will be reported.
115
+ // * The default value is false.
116
+ // */
117
+ // "flatten": false,
118
+ //
119
+ // /**
120
+ // * If true, filesystem hard links will be created instead of copying the file. Depending on the
121
+ // * operating system, this may be faster. (But note that it may cause unexpected behavior if a tool
122
+ // * modifies the link.) The default value is false.
123
+ // */
124
+ // "hardlink": false
125
+ // }
126
+ // ]
127
+ // }
128
+
8
129
  {
9
- /**
10
- * The kind of built-in operation that should be performed.
11
- * The "deleteGlobs" action deletes files or folders that match the
12
- * specified glob patterns.
13
- */
14
130
  "actionKind": "deleteGlobs",
15
-
16
- /**
17
- * The stage of the Heft run during which this action should occur. Note that actions specified in heft.json
18
- * occur at the end of the stage of the Heft run.
19
- */
20
131
  "heftEvent": "clean",
21
-
22
- /**
23
- * A user-defined tag whose purpose is to allow configs to replace/delete handlers that were added by other
24
- * configs.
25
- */
26
132
  "actionId": "defaultClean",
27
-
28
- /**
29
- * Glob patterns to be deleted. The paths are resolved relative to the project folder.
30
- * Recommend exactly matching with "projectOutputFolderNames" in rush-project.json.
31
- */
32
- "globsToDelete": ["dist", "lib", "lib-commonjs", "temp"]
133
+ "globsToDelete": ["dist", "lib", "lib-amd", "lib-commonjs", "lib-es6", "temp"]
33
134
  }
34
135
  ],
35
136
 
@@ -37,22 +138,19 @@
37
138
  * The list of Heft plugins to be loaded.
38
139
  */
39
140
  "heftPlugins": [
40
- {
41
- /**
42
- * The path to the plugin package.
43
- */
44
- "plugin": "@rushstack/heft-webpack4-plugin"
45
-
46
- /**
47
- * An optional object that provides additional settings that may be defined by the plugin.
48
- */
49
- // "options": { }
50
- },
51
- {
52
- "plugin": "@rushstack/heft-jest-plugin"
53
- },
54
- {
55
- "plugin": "@rushstack/heft-sass-plugin"
56
- }
141
+ // {
142
+ // /**
143
+ // * The path to the plugin package.
144
+ // */
145
+ // "plugin": "path/to/my-plugin",
146
+ //
147
+ // /**
148
+ // * An optional object that provides additional settings that may be defined by the plugin.
149
+ // */
150
+ // // "options": { }
151
+ // }
152
+ { "plugin": "@rushstack/heft-jest-plugin" },
153
+ { "plugin": "@rushstack/heft-sass-plugin" },
154
+ { "plugin": "@rushstack/heft-webpack5-plugin" }
57
155
  ]
58
156
  }
@@ -1,3 +1,12 @@
1
1
  {
2
- "projectOutputFolderNames": ["dist", "lib", "lib-commonjs", "temp"]
2
+ "operationSettings": [
3
+ {
4
+ "operationName": "_phase:build",
5
+ "outputFolderNames": ["dist", "lib", "lib-amd", "lib-commonjs", "lib-es6", "temp"]
6
+ },
7
+ {
8
+ "operationName": "build",
9
+ "outputFolderNames": ["dist", "lib", "lib-amd", "lib-commonjs", "lib-es6", "temp"]
10
+ }
11
+ ]
3
12
  }
@@ -1,47 +1,65 @@
1
1
  /**
2
- * Configures the Sass Typings plugin for the Heft build system.
2
+ * Configuration for @rushstack/heft-sass-plugin
3
3
  *
4
4
  * This optional additional file customizes Sass parsing, module resolution, and emitting of
5
- * typings files for the Typescript compiler.
5
+ * Typescript .d.ts files.
6
6
  */
7
7
  {
8
- "$schema": "https://developer.microsoft.com/json-schemas/heft/sass.schema.json"
8
+ "$schema": "https://developer.microsoft.com/json-schemas/heft/heft-sass-plugin.schema.json",
9
9
 
10
10
  /**
11
- * Source code root directory.
12
- * This is where .css, .sass, and .scss files will be searched for to generate typings.
11
+ * Optionally specifies another JSON config file that this file extends from. This provides a way for standard
12
+ * settings to be shared across multiple projects.
13
13
  */
14
- // "srcFolder": "src",
14
+ // "extends": "base-project/config/serve-command.json",
15
+
16
+ /**
17
+ * The root directory for project source code.
18
+ *
19
+ * Default value: "src/"
20
+ */
21
+ // "srcFolder": "src/",
15
22
 
16
23
  /**
17
24
  * Output directory for generated Sass typings.
25
+ *
26
+ * Default value: "temp/sass-ts/"
27
+ */
28
+ // "generatedTsFolder": "temp/sass-ts/",
29
+
30
+ /**
31
+ * Determines whether export values are wrapped in a default property, or not.
32
+ *
33
+ * Default value: true
18
34
  */
19
- // "generatedTsFolder": "temp/sass-ts",
35
+ // "exportAsDefault": false,
20
36
 
21
37
  /**
22
- * Determines if export values are wrapped in a default property, or not.
38
+ * If specified, folders where compiled CSS files will be emitted to. They will be named by appending
39
+ * ".css" to the source file name for ease of reference translation.
40
+ *
41
+ * Default value: undefined
23
42
  */
24
- // "exportAsDefault": true,
43
+ // "cssOutputFolders": ["lib", "lib-commonjs"],
25
44
 
26
45
  /**
27
46
  * Files with these extensions will pass through the Sass transpiler for typings generation.
47
+ *
48
+ * Default value: [".sass", ".scss", ".css"]
28
49
  */
29
- // "fileExtensions": [
30
- // ".sass",
31
- // ".scss",
32
- // ".css
33
- // ],
50
+ "fileExtensions": [".sass", ".scss"]
34
51
 
35
52
  /**
36
- * A list of paths used when resolving Sass imports.
53
+ * A list of paths used when resolving Sass imports. The paths should be relative to the project root.
54
+ *
55
+ * Default value: ["node_modules", "src"]
37
56
  */
38
- // "importIncludePaths": [
39
- // "node_modules",
40
- // "src"
41
- // ],
57
+ // "importIncludePaths": ["node_modules", "src"],
42
58
 
43
59
  /**
44
60
  * A list of file paths relative to the "src" folder that should be excluded from typings generation.
61
+ *
62
+ * Default value: undefined
45
63
  */
46
64
  // "excludeFiles": []
47
65
  }
@@ -4,24 +4,45 @@
4
4
  {
5
5
  "$schema": "https://developer.microsoft.com/json-schemas/heft/typescript.schema.json",
6
6
 
7
+ /**
8
+ * Optionally specifies another JSON config file that this file extends from. This provides a way for standard
9
+ * settings to be shared across multiple projects.
10
+ */
11
+ // "extends": "base-project/config/typescript.json",
12
+
7
13
  /**
8
14
  * If provided, emit these module kinds in addition to the modules specified in the tsconfig.
9
15
  * Note that this option only applies to the main tsconfig.json configuration.
10
16
  */
11
17
  "additionalModuleKindsToEmit": [
18
+ // {
19
+ // /**
20
+ // * (Required) Must be one of "commonjs", "amd", "umd", "system", "es2015", "esnext"
21
+ // */
22
+ // "moduleKind": "amd",
23
+ //
24
+ // /**
25
+ // * (Required) The name of the folder where the output will be written.
26
+ // */
27
+ // "outFolderName": "lib-amd"
28
+ // }
29
+
12
30
  {
13
- /**
14
- * (Required) Must be one of "commonjs", "amd", "umd", "system", "es2015", "esnext"
15
- */
16
31
  "moduleKind": "commonjs",
17
-
18
- /**
19
- * (Required) The name of the folder where the output will be written.
20
- */
21
32
  "outFolderName": "lib-commonjs"
22
33
  }
23
34
  ],
24
35
 
36
+ /**
37
+ * If true, emit CommonJS module output to the folder specified in the tsconfig "outDir" compiler option with the .cjs extension alongside (or instead of, if TSConfig specifies CommonJS) the default compilation output.
38
+ */
39
+ // "emitCjsExtensionForCommonJS": true,
40
+
41
+ /**
42
+ * If true, emit ESNext module output to the folder specified in the tsconfig "outDir" compiler option with the .mjs extension alongside (or instead of, if TSConfig specifies ESNext) the default compilation output.
43
+ */
44
+ // "emitMjsExtensionForESModule": true,
45
+
25
46
  /**
26
47
  * Specifies the intermediary folder that tests will use. Because Jest uses the
27
48
  * Node.js runtime to execute tests, the module format must be CommonJS.
@@ -42,13 +63,36 @@
42
63
  // "maxWriteParallelism": 50,
43
64
 
44
65
  /**
45
- * Describes the way files should be statically coped from src to TS output folders
66
+ * Configures additional file types that should be copied into the TypeScript compiler's emit folders, for example
67
+ * so that these files can be resolved by import statements.
46
68
  */
47
69
  "staticAssetsToCopy": {
48
70
  /**
49
71
  * File extensions that should be copied from the src folder to the destination folder(s).
50
72
  */
51
- "fileExtensions": [".json"]
73
+ "fileExtensions": [
74
+ ".aac",
75
+ ".css",
76
+ ".eot",
77
+ ".gif",
78
+ ".jpeg",
79
+ ".jpg",
80
+ ".json",
81
+ ".m4a",
82
+ ".mp3",
83
+ ".mp4",
84
+ ".oga",
85
+ ".otf",
86
+ ".png",
87
+ ".scss",
88
+ ".svg",
89
+ ".ttf",
90
+ ".wav",
91
+ ".webm",
92
+ ".webp",
93
+ ".woff",
94
+ ".woff2"
95
+ ]
52
96
 
53
97
  /**
54
98
  * Glob patterns that should be explicitly included.
@@ -14,9 +14,11 @@
14
14
  "inlineSources": true,
15
15
  "experimentalDecorators": true,
16
16
  "strict": true,
17
+ "useUnknownInCatchVariables": false,
17
18
  "esModuleInterop": true,
18
19
  "noEmitOnError": false,
19
20
  "allowUnreachableCode": false,
21
+ "importHelpers": true,
20
22
 
21
23
  "types": [],
22
24
 
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+ const createWebpackConfigCommon = require('../../shared/webpack-base.config');
5
+
6
+ module.exports = function createWebpackConfig({ env, argv, projectRoot, configOverride }) {
7
+ // Example: "@my-company/my-library"
8
+ const packageName = require(path.join(projectRoot, 'package.json')).name;
9
+ // Example: "my-library"
10
+ const packageNameWithoutScope = packageName.split('/').pop();
11
+
12
+ // Documentation: https://webpack.js.org/configuration/
13
+ const libraryOverrides = {
14
+ target: ['web', 'es5'],
15
+ entry: {
16
+ // Rush Stack convention is that the entry point for libraries is "src/index.ts"
17
+ // whereas the entry point for apps is "src/start.ts"
18
+ [packageNameWithoutScope]: path.resolve(projectRoot, 'lib', 'index.js')
19
+ },
20
+ output: {
21
+ // For libraries, the filename is unhashed so that the package.json "main" field can refer to it
22
+ filename: `[name].js`,
23
+ library: {
24
+ // Use the full package name as the module-id name for AMD
25
+ amd: packageName
26
+ },
27
+ libraryTarget: 'umd',
28
+
29
+ // https://webpack.js.org/configuration/output/#outputlibraryumdnameddefine
30
+ // Give the amd module a globally unique id so that non AMD aware bundlers can concatenate the module
31
+ umdNamedDefine: true,
32
+
33
+ // From: https://webpack.js.org/configuration/output/#outputglobalobject
34
+ // To make UMD build available on both browsers and Node.js, set output.globalObject option to 'this'
35
+ globalObject: 'this'
36
+ },
37
+ devtool: 'source-map'
38
+ };
39
+
40
+ return createWebpackConfigCommon({
41
+ env: env,
42
+ argv: argv,
43
+ projectRoot: projectRoot,
44
+ configOverride: createWebpackConfigCommon.merge(libraryOverrides, configOverride)
45
+ });
46
+ };