@runtime-type-inspector/parcel-transformer 1.0.3 → 1.0.5
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 +1 -1
- package/index.mjs +7 -4
- package/package.json +2 -5
package/README.md
CHANGED
package/index.mjs
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import {Transformer} from '@parcel/plugin';
|
|
2
|
-
import {addTypeChecks} from 'runtime-type-inspector';
|
|
2
|
+
import {addTypeChecks, expandType} from '@runtime-type-inspector/transpiler';
|
|
3
3
|
export default new Transformer({
|
|
4
4
|
async transform({asset}) {
|
|
5
5
|
// Retrieve the asset's source code and source map.
|
|
6
|
-
|
|
6
|
+
const source = await asset.getCode();
|
|
7
7
|
//let sourceMap = await asset.getMap();
|
|
8
|
-
// Run it through some compiler, and set the results
|
|
8
|
+
// Run it through some compiler, and set the results
|
|
9
9
|
// on the asset.
|
|
10
10
|
//let {code, map} = compile(source, sourceMap);
|
|
11
11
|
//asset.setCode(code);
|
|
12
12
|
//asset.setMap(map);
|
|
13
|
-
|
|
13
|
+
// Unfortunately Parcel generates unusable code while adding an import via plugin.
|
|
14
|
+
// Not adding the import results in function calls that can simple be polyfilled into `window`.
|
|
15
|
+
// TODO: Open issue on Parcel or find another way.
|
|
16
|
+
const code = addTypeChecks(source, {expandType, addHeader: false});
|
|
14
17
|
asset.setCode(code);
|
|
15
18
|
// Return the asset
|
|
16
19
|
return [asset];
|
package/package.json
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runtime-type-inspector/parcel-transformer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.mjs",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
-
},
|
|
9
6
|
"author": "Hermann Rolfes (kungfooman)",
|
|
10
7
|
"license": "MIT",
|
|
11
8
|
"dependencies": {
|
|
12
9
|
"@parcel/plugin": "^2.10.1",
|
|
13
|
-
"runtime-type-inspector": "^2.
|
|
10
|
+
"@runtime-type-inspector/transpiler": "^2.2.5"
|
|
14
11
|
},
|
|
15
12
|
"engines": {
|
|
16
13
|
"parcel": "2.x"
|