babel-plugin-inline-webgl-constants
Advanced tools
Comparing version 1.0.3 to 2.0.0-alpha.1
26
index.js
@@ -1,4 +0,3 @@ | ||
/* eslint-disable no-console */ | ||
// const GL = require('luma.gl/constants'); | ||
const GL = require('@luma.gl/constants').default; | ||
/* eslint-disable no-console, import/no-unresolved */ | ||
import {GL} from '@luma.gl/constants'; | ||
@@ -9,3 +8,3 @@ const COLOR_RESET = '\x1b[0m'; | ||
module.exports = function _(opts) { | ||
export default function _(opts) { | ||
return { | ||
@@ -16,5 +15,8 @@ visitor: { | ||
// source: Literal; | ||
const specifiers = path.get('specifiers'); | ||
specifiers.forEach(specifier => { | ||
if (specifier.type === 'ImportDefaultSpecifier') { | ||
let modified = false; | ||
let specifiers = path.get('specifiers'); | ||
specifiers.forEach((specifier) => { | ||
if (specifier.type === 'ImportDefaultSpecifier' || specifier.type === 'ImportSpecifier') { | ||
const local = specifier.node.local; | ||
@@ -29,6 +31,14 @@ if (local.type === 'Identifier' && local.name === 'GL') { | ||
} | ||
path.remove(); | ||
specifier.remove(); | ||
modified = true; | ||
} | ||
} | ||
}); | ||
specifiers = path.get('specifiers'); | ||
// If the last imported specifier was removed, remove the entire import. | ||
if (modified && specifiers.length === 0) { | ||
path.remove(); | ||
} | ||
}, | ||
@@ -35,0 +45,0 @@ |
{ | ||
"name": "babel-plugin-inline-webgl-constants", | ||
"version": "1.0.3", | ||
"version": "2.0.0-alpha.1", | ||
"description": "Babel plugin for replacing long gl constants with the shorter corresponding numbers", | ||
"type": "module", | ||
"license": "MIT", | ||
@@ -16,6 +17,15 @@ "author": "Ib Green", | ||
], | ||
"main": "index.js", | ||
"scripts": { | ||
"build": "babel index.js --presets @babel/env --out-file dist/index.cjs", | ||
"prepublishOnly": "npm run build" | ||
}, | ||
"main": "dist/index.cjs", | ||
"exports": { | ||
"import": "./index.js", | ||
"require": "./dist/index.cjs" | ||
}, | ||
"dependencies": { | ||
"@luma.gl/constants": "^8.4.0" | ||
} | ||
"@luma.gl/constants": "9.0.0-alpha.45" | ||
}, | ||
"gitHead": "c636c34b8f1581eed163e94543a8eb1f4382ba8e" | ||
} |
@@ -11,3 +11,3 @@ # babel-plugin-inline-webgl-constants | ||
```js | ||
```typescript | ||
const max = gl.MAX_VERTEX_ATTRIBS; | ||
@@ -18,3 +18,3 @@ ``` | ||
```js | ||
```typescript | ||
const max = 34921; | ||
@@ -25,4 +25,4 @@ ``` | ||
```js | ||
import GL from '@luma.gl/constants'; | ||
```typescript | ||
import {GL} from '@luma.gl/constants'; | ||
... | ||
@@ -34,3 +34,3 @@ const max = GL.MAX_VERTEX_ATTRIBS; | ||
```js | ||
```typescript | ||
... | ||
@@ -66,3 +66,3 @@ const max = 34921; | ||
```js | ||
```typescript | ||
require('babel-core').transform('code', { | ||
@@ -69,0 +69,0 @@ plugins: ['inline-webgl-constants'] |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
7202
4
141
Yes
2
1
+ Added@luma.gl/constants@9.0.0-alpha.45(transitive)
- Removed@luma.gl/constants@8.5.21(transitive)