requirejs-esm 2.0.0 → 2.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/README.md CHANGED
@@ -35,7 +35,7 @@ Reference ESM source files files via the `esm!` plugin prefix:
35
35
  ```javascript
36
36
  define(['esm!your-esm-module'], function (module) {
37
37
  // ...
38
- });
38
+ })
39
39
  ```
40
40
 
41
41
  You can use the ESM module format in modules loaded by the `esm!` plugin including the keyword `import` for loading nested dependencies. The plugin `esm!` has to be used only in the topmost `require` or `define` statement.
@@ -51,18 +51,22 @@ if (!args.length) {
51
51
  }
52
52
  for (const file of files) {
53
53
  const text = await readFile(file, 'utf8')
54
- const code = transform(text, file, {
54
+ const { code, updated } = transform(text, file, {
55
55
  /*ecmaVersion,*/
56
56
  pluginName,
57
57
  sourceMap,
58
58
  verbose
59
59
  })
60
- if (outputFile) {
61
- await writeFile(outputFile, code)
62
- } else if (rewrite) {
63
- await writeFile(file, code)
60
+ if (updated) {
61
+ if (outputFile) {
62
+ await writeFile(outputFile, code)
63
+ } else if (rewrite) {
64
+ await writeFile(file, code)
65
+ } else {
66
+ console.log(`// ${file}\n\n${code}`)
67
+ }
64
68
  } else {
65
- console.log(`// ${file}\n\n${code}`)
69
+ console.log(`// ${file}\n\nnot updated`)
66
70
  }
67
71
  }
68
72
  } catch (error) {