@runtime-type-inspector/plugin-parcel1 1.0.1 → 3.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 +16 -2
  2. package/index.cjs +1 -1
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
- This is the plugin for Parcel v1.
1
+ # Plugin for Parcel v1
2
2
 
3
- It's a two-step process to install it:
3
+ For integrating this plugin follow this process:
4
4
 
5
5
  1) `npm install --save-dev @runtime-type-inspector/plugin-parcel1`
6
6
 
@@ -10,3 +10,17 @@ It's a two-step process to install it:
10
10
  const bundler = new Bundler(entryFiles, options);
11
11
  bundler.addAssetType('js', require.resolve('@runtime-type-inspector/plugin-parcel1'));
12
12
  ```
13
+
14
+ 3) Make sure to declare RTI as globals:
15
+
16
+ ```html
17
+ <script src="/node_modules/@runtime-type-inspector/runtime/index.cjs"></script>
18
+ <script>
19
+ Object.assign(window, rtiRuntime);
20
+ </script>
21
+ <script src="./build/out.js"></script>
22
+ ```
23
+
24
+ This is *kind of ugly*, but Parcel v1 simply doesn't seem to support adding import declarations inside a plugin. If I will find a possibility, I will fix this.
25
+
26
+ Parcel also drops files that export nothing, but given the nature of JSDoc comments in combination of RTI, a comment is converted into `registerTypedef(...)` for example. This means that typedefs in such files will simply be unregistered, causing runtime type errors (because it's an unknown type). Make sure to process such files individually and add them into the final `out.js`.
package/index.cjs CHANGED
@@ -6,7 +6,7 @@ class JSAssetRuntimeTypeInspector extends JSAsset {
6
6
  * @returns {Promise<void>}
7
7
  */
8
8
  async pretransform() {
9
- this.contents = addTypeChecks(this.contents, {expandType});
9
+ this.contents = addTypeChecks(this.contents, {expandType, addHeader: false});
10
10
  // continue the normal flow
11
11
  return await super.pretransform();
12
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runtime-type-inspector/plugin-parcel1",
3
- "version": "1.0.1",
3
+ "version": "3.0.0",
4
4
  "description": "RuntimeTypeInspector.js plugin for Parcel v1",
5
5
  "main": "index.cjs",
6
6
  "publishConfig": {"access": "public"},
@@ -9,6 +9,6 @@
9
9
  "license": "MIT",
10
10
  "dependencies": {
11
11
  "parcel-bundler": "^1.12.5",
12
- "@runtime-type-inspector/transpiler": "^2.2.5"
12
+ "@runtime-type-inspector/transpiler": "^3.0.0"
13
13
  }
14
14
  }