@studyportals/webpack-helper 7.0.1-5 → 8.0.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/README.md CHANGED
@@ -1,316 +1,389 @@
1
- # WebpackHelper
2
-
3
- WebpackHelper is a utility that makes it easy to set up a webpack configuration for Studyportals' projects that adhere to our [Webpack quality criteria](https://knowledge-vault.studyportals.xyz/quality-standards/front-end/webpack-quality-criteria.html).
4
-
5
- ## Table of Contents
6
-
7
- - [Webpack version](#webpack-version)
8
- - [Notes on updating Webpack from v4 to v5](#notes-on-updating-webpack-from-v4-to-v5)
9
- - [Quick Start](#quick-start)
10
- - [Chunks Retry](#chunks-retry)
11
- - [Defaults](#defaults)
12
- - [Setup](#setup)
13
- - [Limitations](#limitations)
14
- - [Configuration](#configuration)
15
- - [entry](#entry-required)
16
- - [output](#output-required)
17
- - [preset](#preset)
18
- - [bob](#bob)
19
- - [common](#common)
20
- - [development](#development)
21
- - [production](#production)
22
- - [Presets](#presets)
23
- - [javascript](#javascript)
24
- - [typescript](#typescript)
25
- - [vue-typescript](#vue-typescript)
26
- - [DoD compliance with Babel and Browserslist](#dod-compliance-with-babel-and-browserslist)
27
-
28
- ## Webpack version
29
-
30
- This version of WebpackHelper is based on webpack 5. Some earlier WebpackHelper versions used earlier versions of Webpack. If you get syntax errors when updating to the latest version of WebpackHelper, please check out the [Webpack documentation](https://webpack.js.org/configuration/).
31
-
32
- ### Notes on updating Webpack from v4 to v5
33
-
34
- Below are some notes that might be helpful when you're upgrading a microservice from webpack-helper v2 (based on Webpack v4) to v3 (based on Webpack v5).
35
-
36
- #### Exporting
37
-
38
- Webpack-helper **v2 and below**: Your `webpack.config.js` file ended with the following:
39
-
40
- ```javascript
41
- module.exports = mode => configuration.get(mode);
42
- ```
43
-
44
- Webpack-helper **v3 and beyond**: Your `webpack.config.js` file should end with the following (as is also mentioned further below):
45
-
46
- ```javascript
47
- module.exports = (env, details) => configuration.get(details.mode);
48
- ```
49
-
50
- ## Quick Start
51
-
52
- ```bash
53
- npm i -D @studyportals/webpack-helper
54
- ```
55
-
56
- After installation, getting started is quite easy. Just set up a `webpack.config.js` file in the root of your project, require Webpack Helper and set up a configuration using it's `create` method like so:
57
-
58
- ```javascript
59
- const path = require('path');
60
- const WebpackHelper = require("@studyportals/webpack-helper");
61
-
62
- const configuration = WebpackHelper.create({
63
- entry: [
64
- "./src/main.ts"
65
- ],
66
- output: {
67
- path: path.resolve(__dirname, './dist'),
68
- fileName: 'bundle',
69
- hash: true,
70
- // Use this if you want to control hashing for js and css separately
71
- hash: {
72
- js: true,
73
- css: false
74
- }
75
- },
76
- preset: "vue-typescript",
77
- bob: {
78
- name: 'MicroService',
79
- html: '<div id=\"MicroServicePlaceholder\"></div>',
80
- baseURL: '/dist',
81
- defer: ['style'],
82
- dllPackages: [
83
- {
84
- name: "package-dll",
85
- manifest: require("@studyportals/package-dll/dist/manifest.json")
86
- }
87
- ]
88
- },
89
- common: {
90
- //any config
91
- },
92
- production: {
93
- //any config
94
- }
95
- });
96
- ```
97
-
98
- When your configuration is created you can get an instance of it for the correct environment and export it for webpack to use like so:
99
-
100
- ```javascript
101
- module.exports = (env, details) => configuration.get(details.mode);
102
- ```
103
-
104
- ## Chunks Retry
105
-
106
- Webpack Helpers has a default configuration to retry chunks which cannot get loaded on the first try (for whatever reason, network or otherwise).
107
-
108
- It has an Exponential Backoff to calculate the delay between retries of a maximum of `2` seconds.
109
-
110
- The functionality is implemented thru a plugin called `webpack-retry-chunk-load-plugin` <https://www.npmjs.com/package/webpack-retry-chunk-load-plugin>.
111
-
112
- ### Defaults
113
-
114
- By default it is enabled if the selected preset is `vue-typescript` and it uses `6` as the number of retries it does and it uses the `rollbar` instance on the `window` object (Portal instance) to log an error when it reaches the threshold of retries without being able to load the chunk (`new Error('Failed to load chunk for after retries')`).
115
-
116
- ### Setup
117
-
118
- To configure the functionality you can provide an object following this interface
119
-
120
- ```js
121
- interface IChunksRetryPluginConfig {
122
- inject: boolean; //if you want the plugin injected
123
-
124
- threshold: number; //amount of retries
125
-
126
- thresholdReachedCallBack?: string; //a function (body of it as string) to be called when the amount of retries has been exhausted
127
-
128
- rollbarInstanceIdentifier?: string; //a key of a Rollbar instance present on the 'window' object e.g if you want to use window['rollbar_PQ'] to track the error in the Profile Questionnaire project in Rollbar then you send 'rollbar_PQ'
129
-
130
- disableDefaultRollbarError?: boolean; //if you don't want to log by default when the threshold has been reached
131
- }
132
- ```
133
-
134
- and you can provide this thru the `webpack` config of your service like so
135
-
136
- ```js
137
- const configuration = WebpackHelper.create({
138
- chunksRetryConfig: {
139
- threshold: 10,
140
- thresholdReachedCallBack: `console.log("hello")`,
141
- },
142
- ...
143
- ```
144
-
145
- ### Limitations
146
-
147
- We have some limitations in this implementation based on the plugin we used and that the code will be part of the webpack exported code
148
-
149
- ### Only use ES5
150
-
151
- You can only write ES5 code inside the `thresholdReachedCallBack`
152
-
153
- ### String as function
154
-
155
- The function `thresholdReachedCallBack` must be a string (aka the body of the function) and we cannot change that to be a function while retaining the simplicity of the code.
156
-
157
- ## Configuration
158
-
159
- Webpack Helper offers a compact but flexible configuration interface. Below you will find every option available.
160
-
161
- ### entry **(required)**
162
-
163
- The entrypoint for your webpack bundle. This can either be configured as an object with the bundle name as a key and the path as a value or as an array of paths if your project requires multiple entry points.
164
-
165
- ```javascript
166
- entry: [
167
- "./src/main.ts"
168
- ]
169
-
170
- //or
171
-
172
- entry: {
173
- bundle: "./src/main.ts"
174
- }
175
- ```
176
-
177
- ### Working with packaged components & libraries
178
-
179
- When working with packaged components and libraries it is required to keep the bundle name in line with the major version of the package. This helps to prevent reference issues when multiple versions of a package load on a single page.
180
-
181
- ```javascript
182
- // version 1
183
- entry: {
184
- multiselect_v1: "./src/main.ts"
185
- }
186
-
187
- // version 2
188
- entry: {
189
- multiselect_v2: "./src/main.ts"
190
- }
191
- ```
192
-
193
- #### DLL
194
-
195
- When working with a packaged component as a DLL, both the JS bundle and CSS bundle from the core package must be referenced, as below:
196
-
197
- ```javascript
198
-
199
- entry: {
200
- multiselect_v2: [
201
- '@studyportals/multiselect/dist/multiselect.js',
202
- '@studyportals/multiselect/dist/multiselect.css'
203
- ]
204
- }
205
-
206
- ```
207
-
208
- ### output **(required)**
209
-
210
- The output object has some options that define how your bundle will be output. It has the following properties:
211
-
212
- - `path`**(required)**: The target directory for all output files.
213
- - `library`: The name of the exported library, which will also be used to namespace sourcemaps. This will default to `null`.
214
- - `publicPath`: The url to the output directory resolved relative to the HTML page. This will default to `null`.
215
- - `fileName`: A custom filename for your bundle. This will default to `[name]` which refers to the name you've given your entrypoint.
216
- - `hash`: Whether or not to add build hashes to your filenames. This will default to `true`. Whenever you want different values for your js and css you can pass an object with separate properties and values as in the example below.
217
- - `crossOriginLoading`: Tells webpack to enable cross-origin loading of chunks. Can either be set to `anonymous` or `user-credentials`.
218
-
219
- ```javascript
220
- output: {
221
- path: path.resolve(__dirname, './dist'),
222
- library: 'test-microservice',
223
- publicPath: '/assets/',
224
- fileName: 'application',
225
- crossOriginLoading: 'anonymous',
226
- hash: false,
227
- //or
228
- hash: {
229
- js: true,
230
- css: false
231
- }
232
- }
233
- ```
234
-
235
- ### preset
236
-
237
- The preset property determines which preset to load into your webpack configuration.
238
-
239
- ```javascript
240
- preset: "vue-typescript | typescript | javascript"
241
- ```
242
-
243
- ### bob
244
-
245
- The bob object adds all necessary configuration to have your project generate a manifest file to be used by [Bob](https://github.com/studyportals/Bob).
246
-
247
- - `name`**(required)**: The name of your microservice.
248
- - `html`**(required)**: The HTML that needs to be output by your microservice. Can be a path to a document or a snippet.
249
- - `baseURL`: The baseURL for your microservice assets.
250
- - `async`: An array of JS filenames to be loaded async.
251
- - `defer`: An array of CSS filenames to be lazy-loaded.
252
- - `exclude`: An array of filenames (CSS and JS) that should be excluded from your manifest file.
253
- - `dllPackages`: An array of objects that reference your Dll dependencies. They all require a name and a Dll manifest in the form of a json file.
254
-
255
- ```javascript
256
- bob: {
257
- name: 'MicroService',
258
- html: '<div id=\"MicroServicePlaceholder\"></div>',
259
- baseURL: '/dist',
260
- defer: ['style'],
261
- exclude: ['demo-assets'],
262
- dllPackages: [
263
- {
264
- name: "package-dll",
265
- manifest: require("@studyportals/package-dll/dist/manifest.json")
266
- }
267
- ]
268
- }
269
- ```
270
-
271
- WebpackHelper uses [BobManifestGenerator](https://github.com/studyportals/BobManifestGenerator) to generate a manifest file.
272
-
273
- ### common
274
-
275
- Extra Webpack configuration to be used for all environments can be passed in the `common` object. This configuration needs to adhere to Webpack's configuration interface and will be merged in with the other configuration through [webpack-merge](https://github.com/survivejs/webpack-merge).
276
-
277
- ### development
278
-
279
- Extra Webpack configuration to be used for all development builds can be passed in the `development` object. This configuration needs to adhere to Webpack's configuration interface and will be merged in with the other configuration through [webpack-merge](https://github.com/survivejs/webpack-merge).
280
-
281
- **NOTE**: Some default configuration for development builds will be added automatically. Details can be found [here](src/defaults/defaults.md).
282
-
283
- ### production
284
-
285
- Extra Webpack configuration to be used for all production builds can be passed in the `production` object. This configuration needs to adhere to Webpack's configuration interface and will be merged in with the other configuration through [webpack-merge](https://github.com/survivejs/webpack-merge).
286
-
287
- **NOTE**: Some default configuration for production builds will be added automatically. Details can be found [here](src/defaults/defaults.md).
288
-
289
- ## Presets
290
-
291
- In order to make your life as easy as possible, Webpack Helper ships with a set of presets that will take care of putting some essential plugins and loaders in your configuration. The different presets are listed below.
292
-
293
- More in depth information on what configuration these presets will add to your project can be found [here](src/presets/presets.md).
294
-
295
- ### javascript
296
-
297
- The javascript preset will resolve all `.js` and `.json` files and transpiles them with Babel. If your project has styling, it will separate that out in a separate `.css` file.
298
-
299
- ### typescript
300
-
301
- The typescript preset will resolve all `.ts`, `.tsx`, `.js` and `.json` files. It transpiles them using tsc and Babel. Be aware that you will need to include a `tsconfig.json` in your project for it to work properly. If your project has styling, it will separate that out in a separate `.css` file.
302
-
303
- ### vue-typescript
304
-
305
- The vue-typescript preset will resolve all `.vue`, `.ts`, `.tsx`, `.js` and `.json` files. It transpiles them using vue-loader, tsc and Babel. Be aware that you will need to include a `tsconfig.json` in your project for it to work properly. If your project has styling, it will separate that out in a separate `.css` file.
306
-
307
- ## DoD compliance with Babel and Browserslist
308
-
309
- In order to comply to [Studyportals' definition of done](https://knowledge-vault.studyportals.xyz/definitions-of-done/product/) we use `babel` to transpile our front-end code according to the browsers we need to support. To do this your project needs some configuration. When Webpack Helper is installed it will put standard configuration in the root of your project which consists of 2 files:
310
-
311
- - `.babelrc`: A standard configuration for babel that loads the `babel-env` and `babel-typescripts` presets. You might need to add more plugins for your specific project.
312
- - `.browserslistrc`: A configuration file for browserslist. This is used by `babel-env` to determine which browsers to transpile the code for. Within this file the configuration for student facing products will be loaded by default but other configurations can be easily loaded by uncommenting some lines.
313
-
314
- ## Unit testing
315
-
316
- From version `6.0.0` onwards test dependencies are no longer included and should be installed separately. It's also recommended to replace jest with vitest due the complex nature of package jungle. A upgrade guide can be find [here](docs/jest-to-vitest-upgrade-guide.md)
1
+ # WebpackHelper
2
+
3
+ WebpackHelper is a utility that makes it easy to set up a webpack configuration for Studyportals' projects that adhere to our [Webpack quality criteria](https://knowledge-vault.studyportals.xyz/quality-standards/front-end/webpack-quality-criteria.html).
4
+
5
+ ## Table of Contents
6
+
7
+ - [Webpack version](#webpack-version)
8
+ - [Notes on updating Webpack from v4 to v5](#notes-on-updating-webpack-from-v4-to-v5)
9
+ - [Quick Start](#quick-start)
10
+ - [SCSS Migration](#scss-migration-from-153x-to--1540)
11
+ - [Minimum compiler that shows each warning](#minimum-compiler-that-shows-each-warning)
12
+ - [Migration](#migration)
13
+ - [List of changes](#list-of-changes)
14
+ - [Chunks Retry](#chunks-retry)
15
+ - [Defaults](#defaults)
16
+ - [Setup](#setup)
17
+ - [Limitations](#limitations)
18
+ - [Configuration](#configuration)
19
+ - [entry](#entry-required)
20
+ - [output](#output-required)
21
+ - [preset](#preset)
22
+ - [bob](#bob)
23
+ - [common](#common)
24
+ - [development](#development)
25
+ - [production](#production)
26
+ - [Presets](#presets)
27
+ - [javascript](#javascript)
28
+ - [typescript](#typescript)
29
+ - [vue-typescript](#vue-typescript)
30
+ - [DoD compliance with Babel and Browserslist](#dod-compliance-with-babel-and-browserslist)
31
+
32
+ ## Webpack version
33
+
34
+ This version of WebpackHelper is based on webpack 5. Some earlier WebpackHelper versions used earlier versions of Webpack. If you get syntax errors when updating to the latest version of WebpackHelper, please check out the [Webpack documentation](https://webpack.js.org/configuration/).
35
+
36
+ ### Notes on updating Webpack from v4 to v5
37
+
38
+ Below are some notes that might be helpful when you're upgrading a microservice from webpack-helper v2 (based on Webpack v4) to v3 (based on Webpack v5).
39
+
40
+ #### Exporting
41
+
42
+ Webpack-helper **v2 and below**: Your `webpack.config.js` file ended with the following:
43
+
44
+ ```javascript
45
+ module.exports = mode => configuration.get(mode);
46
+ ```
47
+
48
+ Webpack-helper **v3 and beyond**: Your `webpack.config.js` file should end with the following (as is also mentioned further below):
49
+
50
+ ```javascript
51
+ module.exports = (env, details) => configuration.get(details.mode);
52
+ ```
53
+
54
+ ## Quick Start
55
+
56
+ ```bash
57
+ npm i -D @studyportals/webpack-helper
58
+ ```
59
+
60
+ After installation, getting started is quite easy. Just set up a `webpack.config.js` file in the root of your project, require Webpack Helper and set up a configuration using it's `create` method like so:
61
+
62
+ ```javascript
63
+ const path = require('path');
64
+ const WebpackHelper = require("@studyportals/webpack-helper");
65
+
66
+ const configuration = WebpackHelper.create({
67
+ entry: [
68
+ "./src/main.ts"
69
+ ],
70
+ output: {
71
+ path: path.resolve(__dirname, './dist'),
72
+ fileName: 'bundle',
73
+ hash: true,
74
+ // Use this if you want to control hashing for js and css separately
75
+ hash: {
76
+ js: true,
77
+ css: false
78
+ }
79
+ },
80
+ preset: "vue-typescript",
81
+ bob: {
82
+ name: 'MicroService',
83
+ html: '<div id=\"MicroServicePlaceholder\"></div>',
84
+ baseURL: '/dist',
85
+ defer: ['style'],
86
+ dllPackages: [
87
+ {
88
+ name: "package-dll",
89
+ manifest: require("@studyportals/package-dll/dist/manifest.json")
90
+ }
91
+ ]
92
+ },
93
+ common: {
94
+ //any config
95
+ },
96
+ production: {
97
+ //any config
98
+ }
99
+ });
100
+ ```
101
+
102
+ When your configuration is created you can get an instance of it for the correct environment and export it for webpack to use like so:
103
+
104
+ ```javascript
105
+ module.exports = (env, details) => configuration.get(details.mode);
106
+ ```
107
+
108
+ ## SCSS Migration from 1.53.x to >= 1.54.0
109
+
110
+ This package is used by other services that build with `sass`. Each `sass` release is a JavaScript build of the same-numbered Dart Sass compiler, so bumping from 1.53.x to 1.54.0 silently enables a raft of breaking-change warnings. Eventually when Dart Sass 3 is released, these warnings become hard errors that will break downstream builds.
111
+
112
+ | Dependency in *package.json* | Real compiler behind the scenes | Notes |
113
+ | ---------------------------- | ------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------- |
114
+ | `"sass": "^1.89.2"` | Dart Sass 1.89.2 (JS build) | Running `npx sass --version` shows the exact Dart Sass version. |
115
+ | `"sass-loader": "^16"` | Webpack loader that invokes **whatever Sass implementation you installed** (defaults to the `sass` package above). | |
116
+
117
+ ### Minimum compiler that shows each warning
118
+
119
+ | Change (see checklist below) | First **warns** in | Becomes an **error** |
120
+ | ---------------------------------------------- | ------------------ | -------------------- |
121
+ | Invalid combinators (`> >`, leading `+`, etc.) | 1.54.0 | already errors |
122
+ | Media-Query Level 4 logic | 1.54.0 | 1.56.0 |
123
+ | Strict unary `+ -` spacing | 1.55.0 | already errors |
124
+ | Duplicate `!default`/`!global` flags | 1.62.0 | already errors |
125
+ | Reserved `type()` function | 1.86.0 | next major |
126
+ | `/` division → `math.div()` | 1.33.0 | next major |
127
+ | `@import` → module system | 1.80.0 | Dart Sass 3 |
128
+
129
+ ### Migration
130
+
131
+ To help us migrate, there is a package called `sass-migrator` that you can use to resolve the majority of the issues.
132
+
133
+ ```bash
134
+ npm install --save-dev sass-migrator
135
+ ```
136
+
137
+ Then run
138
+
139
+ ```bash
140
+ # migrate @import → @use/@forward
141
+ npx sass-migrator module --migrate-deps "src/**/*.scss"
142
+
143
+ # replace “/” division with math.div()
144
+ npx sass-migrator division --migrate-deps "src/**/*.scss"
145
+
146
+ # add the required space for ambiguous + / - operators
147
+ npx sass-migrator strict-unary --migrate-deps "src/**/*.scss"
148
+
149
+ # swap legacy color helpers (lighten(), darken(), …) for sass:color APIs
150
+ npx sass-migrator color --migrate-deps "src/**/*.scss"
151
+ ```
152
+
153
+ #### List of changes
154
+
155
+ | # | Change you must make | **Before — old SCSS** | **After — new SCSS** | Why it matters |
156
+ | -- | ----------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
157
+ | 1 | Replace **`@import` → `@use/@forward`** | A) `@import "tools/colors";`<br>B) `@import "theme/light";`<br>    `@import "components/button";` | A) `@use "tools/colors" as colors;`<br>B) `@use "theme/light" as *;`<br>    `@use "components/button";` | `@import` builds a huge global namespace and re-parses files; removed in Dart Sass 3.0. |
158
+ | 2 | Slash-division → **`math.div()`** | A) `width: 100%/3;`<br>B) `$col: 940px/12;` | `@use "sass:math";`<br>A) `width: math.div(100%, 3);`<br>B) `$col: math.div(940px, 12);` | `/` is being re-defined as a list separator. |
159
+ | 3 | Make unary `+` / `-` unambiguous | A) `gap: 10px -$space;`<br>B) `margin: +$n ($n*2);` | A) `gap: 10px - $space;` or `gap: 10px (-$space);`<br>B) `margin: + $n (#{$n*2});` | Compiler now errors on ambiguous signs. |
160
+ | 4 | Rename a custom **`type()`** function | A) `@function type($x) {…}`<br>B) `$v: type(42);` | A) `@function kind($x) {…}`<br>B) `$v: kind(42);` | CSS adds its own reserved `type()`. |
161
+ | 5 | Swap legacy colour helpers for **`sass:color`** | A) `$hover: lighten($brand, 10%);`<br>B) `$new: adjust-hue($brand, 20deg);` | `@use "sass:color";`<br>A) `$hover: color.adjust($brand, $lightness: 10%);`<br>B) `$new: color.adjust($brand, $hue: 20deg);` | Old helpers assume sRGB only. |
162
+ | 6 | Remove duplicate flags | A) `$pad: 1rem !default !default;`<br>B) `$debug: null !global !global;` | `$pad: 1rem !default;`<br>`$debug: null !global;` | A second `!default`/`!global` is now an error. |
163
+ | 7 | Delete **`meta.feature-exists()`** | A) `@use "sass:meta";`<br>  `@if meta.feature-exists("global-variable-shadowing") {…}`<br>B) `$has: feature-exists(calc);` | Usually just delete — all features it checks are always present. | Function is obsolete. |
164
+ | 8 | Fix stray / doubled combinators | A) `+ .alert {…}`<br>B) `nav > > li {…}` | A) `.alert {…}`<br>B) `nav > li {…}` | Invalid CSS selectors now error. |
165
+ | 9 | Keep declarations **before** nested rules | `.card {`<br>  `color:#333;`<br>  `&__header {…}`<br>  `font-weight:bold;`<br>`}` | `.card {`<br>  `color:#333;`<br>  `&__header {…}`<br>  `& { font-weight:bold; }`<br>`}` | Mirrors CSS Nesting source-order rules. |
166
+ | 10 | Use CSS-4 logic in **`@media`** | A) `@media (not (prefers-reduced-motion)) {…}`<br>B) `@media ((hover) and (pointer:fine)) {…}` | `@media not (prefers-reduced-motion) {…}`<br>`@media (hover) and (pointer:fine) {…}` | Old parenthesised syntax conflicts with MQ L4. |
167
+ | 11 | Always interpolate custom-prop values | A) `--accent: $brand;`<br>B) `--size: $gap * 1.5;` | `--accent: #{$brand};`<br>`--size: #{$gap * 1.5};` | Stops Sass mistaking raw CSS tokens for vars. |
168
+ | 12 | Give colour funcs the right units | A) `hsl(0.5turn,100%,50%);`<br>B) `$deg: 90grad; hue($c,$deg);` | A) `hsl(180deg,100%,50%);`<br>B) `$deg: 90deg; color.adjust($c,$hue:$deg);` | Functions now enforce CSS-spec units. |
169
+ | 13 | Use **`math.abs()`** for percentages | A) `$pos: abs(-10%);`<br>B) `padding: abs(5%);` | `@use "sass:math";`<br>A) `$pos: math.abs(-10%);`<br>B) `padding: math.abs(5%);` | Global `abs()` drops `%` support. |
170
+ | 14 | Rename any name starting **`--`** | A) `@mixin --theme($c){…}`<br>B) `@function --shadow(){…}` | `@mixin _theme($c){…}`<br>`@function _shadow(){…}` | `--` reserved for future native CSS mixins. |
171
+ | 15 | Remove special **`@-moz-document`** parser | `@-moz-document url-prefix("https://") { … }`<br>`@-moz-document domain(mozilla.org) { … }` | *(Delete or treat as an unknown at-rule; only `@-moz-document url-prefix()` hack still compiles.)* | Feature gone from Firefox → dropped from Sass. |
172
+ | 16 | **Don’t `@extend` a compound selector** | A) `.notice { @extend .msg.info; }`<br>B) `.alert { @extend .box.error; }` | `.notice { @extend .msg, .info; }`<br>`.alert { @extend .box, .error; }` | Dart Sass forbids extending `.foo.bar`. |
173
+ | 17 | **You can’t overwrite a mixin or function that came in via `@use`** | `@import "~@studyportals/styles-abstracts/abstracts.scss";`<br>`@include TextStyle($name);`<br>`font-weight: 700;`| `@use "~@studyportals/styles-abstracts/abstracts.scss" as *;`<br>`@include TextStyle($name);`| Error immediately since `@use` (1.23) — name collisions are blocked ([sass-lang.com][1]) |
174
+
175
+ [1]: https://sass-lang.com/blog/the-module-system-is-launched/ "Sass: The Module System is Launched"
176
+
177
+ ## Chunks Retry
178
+
179
+ Webpack Helpers has a default configuration to retry chunks which cannot get loaded on the first try (for whatever reason, network or otherwise).
180
+
181
+ It has an Exponential Backoff to calculate the delay between retries of a maximum of `2` seconds.
182
+
183
+ The functionality is implemented thru a plugin called `webpack-retry-chunk-load-plugin` <https://www.npmjs.com/package/webpack-retry-chunk-load-plugin>.
184
+
185
+ ### Defaults
186
+
187
+ By default it is enabled if the selected preset is `vue-typescript` and it uses `6` as the number of retries it does and it uses the `rollbar` instance on the `window` object (Portal instance) to log an error when it reaches the threshold of retries without being able to load the chunk (`new Error('Failed to load chunk for after retries')`).
188
+
189
+ ### Setup
190
+
191
+ To configure the functionality you can provide an object following this interface
192
+
193
+ ```js
194
+ interface IChunksRetryPluginConfig {
195
+ inject: boolean; //if you want the plugin injected
196
+
197
+ threshold: number; //amount of retries
198
+
199
+ thresholdReachedCallBack?: string; //a function (body of it as string) to be called when the amount of retries has been exhausted
200
+
201
+ rollbarInstanceIdentifier?: string; //a key of a Rollbar instance present on the 'window' object e.g if you want to use window['rollbar_PQ'] to track the error in the Profile Questionnaire project in Rollbar then you send 'rollbar_PQ'
202
+
203
+ disableDefaultRollbarError?: boolean; //if you don't want to log by default when the threshold has been reached
204
+ }
205
+ ```
206
+
207
+ and you can provide this thru the `webpack` config of your service like so
208
+
209
+ ```js
210
+ const configuration = WebpackHelper.create({
211
+ chunksRetryConfig: {
212
+ threshold: 10,
213
+ thresholdReachedCallBack: `console.log("hello")`,
214
+ },
215
+ ...
216
+ ```
217
+
218
+ ### Limitations
219
+
220
+ We have some limitations in this implementation based on the plugin we used and that the code will be part of the webpack exported code
221
+
222
+ ### Only use ES5
223
+
224
+ You can only write ES5 code inside the `thresholdReachedCallBack`
225
+
226
+ ### String as function
227
+
228
+ The function `thresholdReachedCallBack` must be a string (aka the body of the function) and we cannot change that to be a function while retaining the simplicity of the code.
229
+
230
+ ## Configuration
231
+
232
+ Webpack Helper offers a compact but flexible configuration interface. Below you will find every option available.
233
+
234
+ ### entry **(required)**
235
+
236
+ The entrypoint for your webpack bundle. This can either be configured as an object with the bundle name as a key and the path as a value or as an array of paths if your project requires multiple entry points.
237
+
238
+ ```javascript
239
+ entry: [
240
+ "./src/main.ts"
241
+ ]
242
+
243
+ //or
244
+
245
+ entry: {
246
+ bundle: "./src/main.ts"
247
+ }
248
+ ```
249
+
250
+ ### Working with packaged components & libraries
251
+
252
+ When working with packaged components and libraries it is required to keep the bundle name in line with the major version of the package. This helps to prevent reference issues when multiple versions of a package load on a single page.
253
+
254
+ ```javascript
255
+ // version 1
256
+ entry: {
257
+ multiselect_v1: "./src/main.ts"
258
+ }
259
+
260
+ // version 2
261
+ entry: {
262
+ multiselect_v2: "./src/main.ts"
263
+ }
264
+ ```
265
+
266
+ #### DLL
267
+
268
+ When working with a packaged component as a DLL, both the JS bundle and CSS bundle from the core package must be referenced, as below:
269
+
270
+ ```javascript
271
+
272
+ entry: {
273
+ multiselect_v2: [
274
+ '@studyportals/multiselect/dist/multiselect.js',
275
+ '@studyportals/multiselect/dist/multiselect.css'
276
+ ]
277
+ }
278
+
279
+ ```
280
+
281
+ ### output **(required)**
282
+
283
+ The output object has some options that define how your bundle will be output. It has the following properties:
284
+
285
+ - `path`**(required)**: The target directory for all output files.
286
+ - `library`: The name of the exported library, which will also be used to namespace sourcemaps. This will default to `null`.
287
+ - `publicPath`: The url to the output directory resolved relative to the HTML page. This will default to `null`.
288
+ - `fileName`: A custom filename for your bundle. This will default to `[name]` which refers to the name you've given your entrypoint.
289
+ - `hash`: Whether or not to add build hashes to your filenames. This will default to `true`. Whenever you want different values for your js and css you can pass an object with separate properties and values as in the example below.
290
+ - `crossOriginLoading`: Tells webpack to enable cross-origin loading of chunks. Can either be set to `anonymous` or `user-credentials`.
291
+
292
+ ```javascript
293
+ output: {
294
+ path: path.resolve(__dirname, './dist'),
295
+ library: 'test-microservice',
296
+ publicPath: '/assets/',
297
+ fileName: 'application',
298
+ crossOriginLoading: 'anonymous',
299
+ hash: false,
300
+ //or
301
+ hash: {
302
+ js: true,
303
+ css: false
304
+ }
305
+ }
306
+ ```
307
+
308
+ ### preset
309
+
310
+ The preset property determines which preset to load into your webpack configuration.
311
+
312
+ ```javascript
313
+ preset: "vue-typescript | typescript | javascript"
314
+ ```
315
+
316
+ ### bob
317
+
318
+ The bob object adds all necessary configuration to have your project generate a manifest file to be used by [Bob](https://github.com/studyportals/Bob).
319
+
320
+ - `name`**(required)**: The name of your microservice.
321
+ - `html`**(required)**: The HTML that needs to be output by your microservice. Can be a path to a document or a snippet.
322
+ - `baseURL`: The baseURL for your microservice assets.
323
+ - `async`: An array of JS filenames to be loaded async.
324
+ - `defer`: An array of CSS filenames to be lazy-loaded.
325
+ - `exclude`: An array of filenames (CSS and JS) that should be excluded from your manifest file.
326
+ - `dllPackages`: An array of objects that reference your Dll dependencies. They all require a name and a Dll manifest in the form of a json file.
327
+
328
+ ```javascript
329
+ bob: {
330
+ name: 'MicroService',
331
+ html: '<div id=\"MicroServicePlaceholder\"></div>',
332
+ baseURL: '/dist',
333
+ defer: ['style'],
334
+ exclude: ['demo-assets'],
335
+ dllPackages: [
336
+ {
337
+ name: "package-dll",
338
+ manifest: require("@studyportals/package-dll/dist/manifest.json")
339
+ }
340
+ ]
341
+ }
342
+ ```
343
+
344
+ WebpackHelper uses [BobManifestGenerator](https://github.com/studyportals/BobManifestGenerator) to generate a manifest file.
345
+
346
+ ### common
347
+
348
+ Extra Webpack configuration to be used for all environments can be passed in the `common` object. This configuration needs to adhere to Webpack's configuration interface and will be merged in with the other configuration through [webpack-merge](https://github.com/survivejs/webpack-merge).
349
+
350
+ ### development
351
+
352
+ Extra Webpack configuration to be used for all development builds can be passed in the `development` object. This configuration needs to adhere to Webpack's configuration interface and will be merged in with the other configuration through [webpack-merge](https://github.com/survivejs/webpack-merge).
353
+
354
+ **NOTE**: Some default configuration for development builds will be added automatically. Details can be found [here](src/defaults/defaults.md).
355
+
356
+ ### production
357
+
358
+ Extra Webpack configuration to be used for all production builds can be passed in the `production` object. This configuration needs to adhere to Webpack's configuration interface and will be merged in with the other configuration through [webpack-merge](https://github.com/survivejs/webpack-merge).
359
+
360
+ **NOTE**: Some default configuration for production builds will be added automatically. Details can be found [here](src/defaults/defaults.md).
361
+
362
+ ## Presets
363
+
364
+ In order to make your life as easy as possible, Webpack Helper ships with a set of presets that will take care of putting some essential plugins and loaders in your configuration. The different presets are listed below.
365
+
366
+ More in depth information on what configuration these presets will add to your project can be found [here](src/presets/presets.md).
367
+
368
+ ### javascript
369
+
370
+ The javascript preset will resolve all `.js` and `.json` files and transpiles them with Babel. If your project has styling, it will separate that out in a separate `.css` file.
371
+
372
+ ### typescript
373
+
374
+ The typescript preset will resolve all `.ts`, `.tsx`, `.js` and `.json` files. It transpiles them using tsc and Babel. Be aware that you will need to include a `tsconfig.json` in your project for it to work properly. If your project has styling, it will separate that out in a separate `.css` file.
375
+
376
+ ### vue-typescript
377
+
378
+ The vue-typescript preset will resolve all `.vue`, `.ts`, `.tsx`, `.js` and `.json` files. It transpiles them using vue-loader, tsc and Babel. Be aware that you will need to include a `tsconfig.json` in your project for it to work properly. If your project has styling, it will separate that out in a separate `.css` file.
379
+
380
+ ## DoD compliance with Babel and Browserslist
381
+
382
+ In order to comply to [Studyportals' definition of done](https://knowledge-vault.studyportals.xyz/definitions-of-done/product/) we use `babel` to transpile our front-end code according to the browsers we need to support. To do this your project needs some configuration. When Webpack Helper is installed it will put standard configuration in the root of your project which consists of 2 files:
383
+
384
+ - `.babelrc`: A standard configuration for babel that loads the `babel-env` and `babel-typescripts` presets. You might need to add more plugins for your specific project.
385
+ - `.browserslistrc`: A configuration file for browserslist. This is used by `babel-env` to determine which browsers to transpile the code for. Within this file the configuration for student facing products will be loaded by default but other configurations can be easily loaded by uncommenting some lines.
386
+
387
+ ## Unit testing
388
+
389
+ From version `6.0.0` onwards test dependencies are no longer included and should be installed separately. It's also recommended to replace jest with vitest due the complex nature of package jungle. A upgrade guide can be find [here](docs/jest-to-vitest-upgrade-guide.md)
@@ -1,3 +1,3 @@
1
- #extends @studyportals/browserslist-config/clients
2
- #extends @studyportals/browserslist-config/internal
1
+ #extends @studyportals/browserslist-config/clients
2
+ #extends @studyportals/browserslist-config/internal
3
3
  extends @studyportals/browserslist-config/student
package/package.json CHANGED
@@ -1,55 +1,51 @@
1
- {
2
- "name": "@studyportals/webpack-helper",
3
- "version": "7.0.1-5",
4
- "description": "A collection of standard configurations and helpers for webpack.",
5
- "main": "src/main.js",
6
- "scripts": {
7
- "test": "vitest --watch=false --coverage",
8
- "build": "tsc",
9
- "prepublish": "npm run build",
10
- "postinstall": "cp ./assets/.browserslistrc ../../../",
11
- "deploy-beta": "npm version prerelease && npm run build && npm publish --tag beta --access=public --auth-type=legacy && rm -rf node_modules"
12
- },
13
- "files": [
14
- "src/**/*.js",
15
- "assets/*"
16
- ],
17
- "author": {
18
- "name": "Frank Kluijtmans",
19
- "email": "frank@studyportals.com"
20
- },
21
- "license": "ISC",
22
- "dependencies": {
23
- "@babel/core": "^7.27.4",
24
- "@studyportals/bob-manifest-generator": "^5.0.1",
25
- "@studyportals/browserslist-config": "^1.2.4",
26
- "@studyportals/dll-availability-tracker": "^2.0.0",
27
- "@studyportals/vue-config": "^5.0.3",
28
- "babel-loader": "^10.0.0",
29
- "css-loader": "^6.10.0",
30
- "css-minimizer-webpack-plugin": "^6.0.0",
31
- "esbuild-loader": "^4.0.3",
32
- "esbuild-plugin-browserslist": "^0.11.1",
33
- "file-loader": "^6.2.0",
34
- "fork-ts-checker-webpack-plugin": "^9.0.2",
35
- "mini-css-extract-plugin": "^2.8.0",
36
- "path": "^0.12.7",
37
- "prettier": "^2.8.8",
38
- "sass": "^1.71.1",
39
- "sass-loader": "^14.1.1",
40
- "swc-loader": "^0.2.6",
41
- "terser-webpack-plugin": "^5.3.10",
42
- "ts-loader": "^9.5.2",
43
- "typescript": "^5.3.3",
44
- "vue-loader": "^17.4.2",
45
- "webpack": "^5.90.3",
46
- "webpack-cli": "^5.1.4",
47
- "webpack-dev-server": "^5.2.2",
48
- "webpack-merge": "^5.10.0"
49
- },
50
- "devDependencies": {
51
- "@types/node": "^20.11.20",
52
- "@vitest/coverage-v8": "^1.3.1",
53
- "vitest": "^1.3.1"
54
- }
55
- }
1
+ {
2
+ "name": "@studyportals/webpack-helper",
3
+ "version": "8.0.0",
4
+ "description": "A collection of standard configurations and helpers for webpack.",
5
+ "main": "src/main.js",
6
+ "scripts": {
7
+ "test": "vitest --watch=false --coverage",
8
+ "build": "tsc",
9
+ "prepublish": "npm run build",
10
+ "postinstall": "cp ./assets/.browserslistrc ../../../ || true",
11
+ "deploy-beta": "npm version prerelease && npm run build && npm publish --tag beta --access=public --auth-type=legacy && rm -rf node_modules"
12
+ },
13
+ "files": [
14
+ "src/**/*.js",
15
+ "assets/*"
16
+ ],
17
+ "author": {
18
+ "name": "Frank Kluijtmans",
19
+ "email": "frank@studyportals.com"
20
+ },
21
+ "license": "ISC",
22
+ "dependencies": {
23
+ "@studyportals/bob-manifest-generator": "^5.0.1",
24
+ "@studyportals/browserslist-config": "^1.2.4",
25
+ "@studyportals/dll-availability-tracker": "^2.0.0",
26
+ "@studyportals/vue-config": "^5.0.3",
27
+ "css-loader": "^6.10.0",
28
+ "css-minimizer-webpack-plugin": "^6.0.0",
29
+ "esbuild-loader": "^4.0.3",
30
+ "esbuild-plugin-browserslist": "^0.11.1",
31
+ "file-loader": "^6.2.0",
32
+ "fork-ts-checker-webpack-plugin": "^9.0.2",
33
+ "mini-css-extract-plugin": "^2.8.0",
34
+ "path": "^0.12.7",
35
+ "prettier": "^2.8.8",
36
+ "sass": "^1.89.2",
37
+ "sass-loader": "^16.0.5",
38
+ "terser-webpack-plugin": "^5.3.10",
39
+ "typescript": "^5.3.3",
40
+ "vue-loader": "^17.4.2",
41
+ "webpack": "^5.90.3",
42
+ "webpack-cli": "^5.1.4",
43
+ "webpack-dev-server": "^5.2.2",
44
+ "webpack-merge": "^5.10.0"
45
+ },
46
+ "devDependencies": {
47
+ "@types/node": "^20.11.20",
48
+ "@vitest/coverage-v8": "^1.3.1",
49
+ "vitest": "^1.3.1"
50
+ }
51
+ }
@@ -4,7 +4,6 @@ exports.Preset = void 0;
4
4
  var Preset;
5
5
  (function (Preset) {
6
6
  Preset["VUE_TYPESCRIPT"] = "vue-typescript";
7
- Preset["VUE_TYPESCRIPT_SWC"] = "vue-typescript-swc";
8
7
  Preset["TYPESCRIPT"] = "typescript";
9
8
  Preset["JAVASCRIPT"] = "javascript";
10
9
  })(Preset || (exports.Preset = Preset = {}));
@@ -20,12 +20,12 @@ class ChunksRetryPluginFactory {
20
20
  static CustomRetryChunksPlugin(preset) {
21
21
  const { retryChunksConfig } = preset;
22
22
  return new RetryChunkLoadPlugin({
23
- cacheBust: `function() {
24
- return Date.now();
23
+ cacheBust: `function() {
24
+ return Date.now();
25
25
  }`,
26
- retryDelay: `function(retryAttempt) {
27
- return Math.min(2000, Math.pow(2, retryAttempt) * 100);
28
- }
26
+ retryDelay: `function(retryAttempt) {
27
+ return Math.min(2000, Math.pow(2, retryAttempt) * 100);
28
+ }
29
29
  `,
30
30
  maxRetries: retryChunksConfig.threshold,
31
31
  lastResortScript: ChunksRetryPluginFactory.CreateLastResortScript(preset)
@@ -35,18 +35,18 @@ class ChunksRetryPluginFactory {
35
35
  const { retryChunksConfig } = preset;
36
36
  let lastResortScript = ``;
37
37
  if (retryChunksConfig.thresholdReachedCallBack) {
38
- lastResortScript += `
39
- ${retryChunksConfig.thresholdReachedCallBack}
38
+ lastResortScript += `
39
+ ${retryChunksConfig.thresholdReachedCallBack}
40
40
  `;
41
41
  }
42
42
  if (!retryChunksConfig.disableDefaultRollbarError) {
43
43
  const rollbarInstanceIdentifier = retryChunksConfig.rollbarInstanceIdentifier || 'rollbar';
44
- lastResortScript += `
45
- if (!window || !window['${rollbarInstanceIdentifier}'] || !window['${rollbarInstanceIdentifier}'].error) {
46
- return;
47
- }
48
-
49
- window['${rollbarInstanceIdentifier}'].error(new Error('Failed to load chunk for after retries'));
44
+ lastResortScript += `
45
+ if (!window || !window['${rollbarInstanceIdentifier}'] || !window['${rollbarInstanceIdentifier}'].error) {
46
+ return;
47
+ }
48
+
49
+ window['${rollbarInstanceIdentifier}'].error(new Error('Failed to load chunk for after retries'));
50
50
  `;
51
51
  }
52
52
  return lastResortScript;
@@ -16,7 +16,6 @@ const mode_1 = require("../enums/mode");
16
16
  const production_config_1 = require("../defaults/production.config");
17
17
  const development_config_1 = require("../defaults/development.config");
18
18
  const chunks_retry_plugin_factory_1 = __importDefault(require("../factories/chunks-retry-plugin-factory"));
19
- const vue_typescript_swc_preset_1 = require("../presets/vue-typescript-swc.preset");
20
19
  const ManifestGenerator = require("@studyportals/bob-manifest-generator").ManifestGenerator;
21
20
  const DllReferencePlugin = require("@studyportals/bob-manifest-generator").DllReferencePlugin;
22
21
  const { merge } = require('webpack-merge');
@@ -70,8 +69,6 @@ class Configuration {
70
69
  case preset_1.Preset.VUE_TYPESCRIPT:
71
70
  this.injectPreset(new vue_typescript_preset_1.VueTypeScriptPreset(mode, this.chunksRetryConfig, this.customElementTags));
72
71
  break;
73
- case preset_1.Preset.VUE_TYPESCRIPT_SWC:
74
- this.injectPreset(new vue_typescript_swc_preset_1.VueTypescriptSwcPreset(mode, this.chunksRetryConfig, this.customElementTags));
75
72
  case preset_1.Preset.TYPESCRIPT:
76
73
  this.injectPreset(new typescript_preset_1.TypeScriptPreset(mode, this.chunksRetryConfig));
77
74
  break;
@@ -17,8 +17,8 @@ class RetryChunkLoadPlugin {
17
17
  ? maxRetryValueFromOptions
18
18
  : 1;
19
19
  const getCacheBustString = () => this.options.cacheBust
20
- ? `
21
- (${this.options.cacheBust})();
20
+ ? `
21
+ (${this.options.cacheBust})();
22
22
  `
23
23
  : '"cache-bust=true"';
24
24
  mainTemplate.hooks.localVars.tap({ name: pluginName, stage: 1 }, (source, chunk) => {
@@ -30,41 +30,41 @@ class RetryChunkLoadPlugin {
30
30
  : `function() { return ${this.options.retryDelay || 0} }`;
31
31
  if (!addRetryCode)
32
32
  return source;
33
- const script = runtimeTemplate.iife('', `
34
- if(typeof ${RuntimeGlobals.require} !== "undefined") {
35
- var oldGetScript = ${RuntimeGlobals.getChunkScriptFilename};
36
- var oldLoadScript = ${RuntimeGlobals.ensureChunk};
37
- var queryMap = {};
38
- var countMap = {};
39
- var getRetryDelay = ${getRetryDelay}
40
- ${RuntimeGlobals.getChunkScriptFilename} = function(chunkId){
41
- var result = oldGetScript(chunkId);
42
- return result + (queryMap.hasOwnProperty(chunkId) ? '?' + queryMap[chunkId] : '');
43
- };
44
- ${RuntimeGlobals.ensureChunk} = function(chunkId){
45
- var result = oldLoadScript(chunkId);
46
- return result.catch(function(error){
47
- var retries = countMap.hasOwnProperty(chunkId) ? countMap[chunkId] : ${maxRetries};
48
- if (retries < 1) {
49
- var realSrc = oldGetScript(chunkId);
50
- error.message = 'Loading chunk ' + chunkId + ' failed after ${maxRetries} retries.\\n(' + realSrc + ')';
33
+ const script = runtimeTemplate.iife('', `
34
+ if(typeof ${RuntimeGlobals.require} !== "undefined") {
35
+ var oldGetScript = ${RuntimeGlobals.getChunkScriptFilename};
36
+ var oldLoadScript = ${RuntimeGlobals.ensureChunk};
37
+ var queryMap = {};
38
+ var countMap = {};
39
+ var getRetryDelay = ${getRetryDelay}
40
+ ${RuntimeGlobals.getChunkScriptFilename} = function(chunkId){
41
+ var result = oldGetScript(chunkId);
42
+ return result + (queryMap.hasOwnProperty(chunkId) ? '?' + queryMap[chunkId] : '');
43
+ };
44
+ ${RuntimeGlobals.ensureChunk} = function(chunkId){
45
+ var result = oldLoadScript(chunkId);
46
+ return result.catch(function(error){
47
+ var retries = countMap.hasOwnProperty(chunkId) ? countMap[chunkId] : ${maxRetries};
48
+ if (retries < 1) {
49
+ var realSrc = oldGetScript(chunkId);
50
+ error.message = 'Loading chunk ' + chunkId + ' failed after ${maxRetries} retries.\\n(' + realSrc + ')';
51
51
  error.request = realSrc;${this.options.lastResortScript
52
52
  ? this.options.lastResortScript
53
- : ''}
54
- throw error;
55
- }
56
- return new Promise(function (resolve) {
57
- var retryAttempt = ${maxRetries} - retries + 1;
58
- setTimeout(function () {
59
- var retryAttemptString = '&retry-attempt=' + retryAttempt;
60
- var cacheBust = ${getCacheBustString()} + retryAttemptString;
61
- queryMap[chunkId] = cacheBust;
62
- countMap[chunkId] = retries - 1;
63
- resolve(${RuntimeGlobals.ensureChunk}(chunkId));
64
- }, getRetryDelay(retryAttempt))
65
- })
66
- });
67
- };
53
+ : ''}
54
+ throw error;
55
+ }
56
+ return new Promise(function (resolve) {
57
+ var retryAttempt = ${maxRetries} - retries + 1;
58
+ setTimeout(function () {
59
+ var retryAttemptString = '&retry-attempt=' + retryAttempt;
60
+ var cacheBust = ${getCacheBustString()} + retryAttemptString;
61
+ queryMap[chunkId] = cacheBust;
62
+ countMap[chunkId] = retries - 1;
63
+ resolve(${RuntimeGlobals.ensureChunk}(chunkId));
64
+ }, getRetryDelay(retryAttempt))
65
+ })
66
+ });
67
+ };
68
68
  }`);
69
69
  return (source +
70
70
  prettier.format(script, {
@@ -1,75 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TypeScriptPreset = void 0;
4
- const browser_list_to_esbuild_target_factory_1 = require("../factories/browser-list-to-esbuild-target-factory");
5
- const MiniCssExtractPlugin = require('mini-css-extract-plugin');
6
- class TypeScriptPreset {
7
- constructor(mode, retryChunksConfig) {
8
- this.mode = mode;
9
- this.retryChunksConfig = retryChunksConfig;
10
- }
11
- getPlugins(filename) {
12
- return [
13
- new MiniCssExtractPlugin({
14
- filename
15
- }),
16
- ];
17
- }
18
- getModule() {
19
- return {
20
- rules: [
21
- {
22
- test: /\.css$/,
23
- use: [
24
- MiniCssExtractPlugin.loader,
25
- 'css-loader'
26
- ],
27
- },
28
- {
29
- test: /\.scss$/,
30
- use: [
31
- MiniCssExtractPlugin.loader,
32
- 'css-loader',
33
- {
34
- loader: 'sass-loader',
35
- options: {
36
- api: 'modern-compiler'
37
- }
38
- }
39
- ],
40
- },
41
- {
42
- test: /\.[jt]sx?$/,
43
- loader: 'esbuild-loader',
44
- options: {
45
- target: new browser_list_to_esbuild_target_factory_1.BrowserListToEsbuildTargetFactory().createTarget(),
46
- supported: {
47
- 'class-static-blocks': false,
48
- 'optional-chain': false,
49
- }
50
- },
51
- resolve: {
52
- fullySpecified: false
53
- },
54
- exclude: /node_modules\/(?!@studyportals\/).*/,
55
- },
56
- {
57
- test: /\.(png|jpg|gif|svg)$/,
58
- loader: 'file-loader',
59
- options: {
60
- name: '[name].[ext]?[fullhash]'
61
- }
62
- }
63
- ]
64
- };
65
- }
66
- getExtensions() {
67
- return [
68
- '*',
69
- '.ts',
70
- '.js',
71
- '.json'
72
- ];
73
- }
74
- }
75
- exports.TypeScriptPreset = TypeScriptPreset;
@@ -1,106 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VueTypescriptSwcPreset = void 0;
4
- const mode_1 = require("../enums/mode");
5
- const webpack = require("webpack");
6
- const MiniCssExtractPlugin = require('mini-css-extract-plugin');
7
- const VueLoaderPlugin = require('vue-loader').VueLoaderPlugin;
8
- const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
9
- class VueTypescriptSwcPreset {
10
- constructor(mode, retryChunksConfig, customElementTags) {
11
- this.mode = mode;
12
- this.retryChunksConfig = retryChunksConfig;
13
- this.customElementTags = customElementTags;
14
- console.log(`[VueTypescriptSwcPreset] Constructor called for mode: ${mode}`);
15
- }
16
- getPlugins(filename) {
17
- return [
18
- new ForkTsCheckerWebpackPlugin(),
19
- new webpack.DllReferencePlugin({
20
- manifest: require(`@studyportals/vue-config/dist/vue3_library_v5${this.mode === mode_1.Mode.PRODUCTION ? '.min' : ''}.json`)
21
- }),
22
- new MiniCssExtractPlugin({
23
- filename,
24
- ignoreOrder: true
25
- }),
26
- new VueLoaderPlugin()
27
- ];
28
- }
29
- getModule() {
30
- return {
31
- rules: [
32
- {
33
- test: /\.css$/,
34
- use: [
35
- MiniCssExtractPlugin.loader,
36
- 'css-loader'
37
- ],
38
- },
39
- {
40
- test: /\.scss$/,
41
- use: [
42
- MiniCssExtractPlugin.loader,
43
- 'css-loader',
44
- 'sass-loader'
45
- ],
46
- },
47
- {
48
- test: /\.vue$/,
49
- loader: 'vue-loader',
50
- options: {
51
- loaders: {
52
- 'scss': [
53
- 'vue-style-loader',
54
- 'css-loader',
55
- 'sass-loader'
56
- ]
57
- },
58
- hotReload: false,
59
- }
60
- },
61
- {
62
- test: /\.(ts|js)x?$/,
63
- exclude: /node_modules/,
64
- use: {
65
- loader: 'swc-loader',
66
- options: {
67
- jsc: {
68
- keepClassNames: true,
69
- parser: {
70
- syntax: 'typescript',
71
- tsx: true,
72
- decorators: true,
73
- },
74
- transform: {
75
- legacyDecorator: true,
76
- decoratorMetadata: true
77
- },
78
- target: 'es6'
79
- },
80
- module: {
81
- type: 'es6'
82
- }
83
- }
84
- }
85
- },
86
- {
87
- test: /\.(png|jpg|gif|svg)$/,
88
- loader: 'file-loader',
89
- options: {
90
- name: '[name].[ext]?[fullhash]'
91
- }
92
- },
93
- ]
94
- };
95
- }
96
- getExtensions() {
97
- return [
98
- '*',
99
- '.ts',
100
- '.js',
101
- '.vue',
102
- '.json'
103
- ];
104
- }
105
- }
106
- exports.VueTypescriptSwcPreset = VueTypescriptSwcPreset;