karma-requirejs-esm-preprocessor 1.1.0 → 2.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.
Files changed (3) hide show
  1. package/README.md +6 -4
  2. package/index.js +3 -3
  3. package/package.json +7 -7
package/README.md CHANGED
@@ -1,9 +1,5 @@
1
1
  # karma-requirejs-esm-preprocessor
2
2
 
3
- [![Latest version](https://img.shields.io/npm/v/karma-requirejs-esm-preprocessor)
4
- ![Dependency status](https://img.shields.io/librariesio/release/npm/karma-requirejs-esm-preprocessor)
5
- ](https://www.npmjs.com/package/karma-requirejs-esm-preprocessor)
6
-
7
3
  [Karma] preprocessor for converting ES modules to AMD in [RequireJS] projects. Uses [requirejs-esm-preprocessor].
8
4
 
9
5
  ## Synopsis
@@ -38,6 +34,12 @@ isScript(path: string): boolean
38
34
 
39
35
  Allows further filtering the files before passing them to the preprocessor. If the patterns are inconvenient to specify what files should be preprocessed, a simple pattern can be used to capture all files and the final filtering be done by `isScript` returning `true` only for the paths to files which need preprocessing. The default is `undefined` - no extra filtering.
40
36
 
37
+ ```ts
38
+ useStrict: boolean
39
+ ```
40
+
41
+ Controls inserting `"use strict"` expression to the AMD code output. ESM modules are parsed in the strict mode by default, while AMD modules need the `"use strict"` statement. You can set this flag to `false` to relax the parse mode of the output AMD modules. The default is `true`.
42
+
41
43
  ```ts
42
44
  sourceMap: boolean
43
45
  ```
package/index.js CHANGED
@@ -2,8 +2,8 @@ const { preprocess } = require('requirejs-esm-preprocessor')
2
2
 
3
3
  function createPreprocessor(args, config, helper) {
4
4
  const { basePath, logLevel, LOG_DEBUG, LOG_DISABLE, requirejsEsmPreprocessor } = config
5
- const defaults = { sourceMap: true }
6
- const { isScript, sourceMap } = helper.merge(defaults, args, requirejsEsmPreprocessor || {})
5
+ const defaults = { useStrict: true, sourceMap: true }
6
+ const { isScript, useStrict, sourceMap } = helper.merge(defaults, args, requirejsEsmPreprocessor || {})
7
7
  const verbose = logLevel === LOG_DEBUG
8
8
  const silent = logLevel === LOG_DISABLE
9
9
  const { length: basePathLen } = basePath
@@ -12,7 +12,7 @@ function createPreprocessor(args, config, helper) {
12
12
  let { originalPath: path } = file
13
13
  if (path.startsWith(basePath)) path = path.substring(basePathLen)
14
14
  if (!isScript || isScript(path)) {
15
- contents = preprocess({ path, contents, isScript, sourceMap, verbose, silent })
15
+ contents = preprocess({ path, contents, isScript, useStrict, sourceMap, verbose, silent })
16
16
  }
17
17
  done(null, contents)
18
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "karma-requirejs-esm-preprocessor",
3
- "version": "1.1.0",
3
+ "version": "2.0.0",
4
4
  "description": "Karma preprocessor for converting ES modules to AMD in RequireJS projects.",
5
5
  "author": "Ferdinand Prantl <prantlf@gmail.com>",
6
6
  "license": "MIT",
@@ -37,19 +37,19 @@
37
37
  "reporter": []
38
38
  },
39
39
  "peerDependencies": {
40
- "requirejs-esm-preprocessor": "^2.1.1"
40
+ "requirejs-esm-preprocessor": "^3.0.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@eslint/js": "^9.26.0",
43
+ "@eslint/js": "^9.39.1",
44
44
  "c8": "^10.1.3",
45
- "eslint": "^9.26.0",
46
- "globals": "^16.1.0",
47
- "jasmine-core": "^5.7.1",
45
+ "eslint": "^9.39.1",
46
+ "globals": "^16.5.0",
47
+ "jasmine-core": "^5.12.1",
48
48
  "karma": "^6.4.4",
49
49
  "karma-brief-reporter": "^0.2.2",
50
50
  "karma-chrome-launcher": "^3.2.0",
51
51
  "karma-jasmine": "^5.1.0",
52
- "requirejs-esm-preprocessor": "^2.1.1"
52
+ "requirejs-esm-preprocessor": "^3.0.0"
53
53
  },
54
54
  "keywords": [
55
55
  "karma-preprocessor",