@architect/hydrate
Advanced tools
Comparing version 2.2.2 to 2.2.3
@@ -5,2 +5,10 @@ # Architect Hydrate changelog | ||
## [2.2.3] 2022-01-11 | ||
### Fixed | ||
- Fix potential false tree shaking errors in ESM files that make use of `require()` (e.g. via `import { createRequire } from 'module'`) | ||
--- | ||
## [2.2.2] 2022-01-10 | ||
@@ -10,3 +18,3 @@ | ||
- Fix false positive treeshaking of `import`s from http(s) | ||
- Fix false positive tree shaking of `import`s from http(s) | ||
@@ -19,3 +27,3 @@ --- | ||
- Fixed treeshaking detection of CJS/ESM when strings `import` and `require` are present in the AST | ||
- Fixed tree shaking detection of CJS/ESM when strings `import` and `require` are present in the AST | ||
@@ -28,3 +36,3 @@ --- | ||
- Added support for Node.js 14 ESM Lambda treeshaking! | ||
- Added support for Node.js 14 ESM Lambda tree shaking! | ||
@@ -31,0 +39,0 @@ --- |
{ | ||
"name": "@architect/hydrate", | ||
"version": "2.2.2", | ||
"version": "2.2.3", | ||
"description": "Architect dependency hydrator and shared file manager", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -18,11 +18,8 @@ let { readFileSync } = require('fs') | ||
// Can't use both module systems in the same file | ||
if (hasRequire && hasImport) throw Error(`Found both 'import' and 'require' statements in ${file}`) | ||
let isESM = !!(hasImport) | ||
let called = [] | ||
let query = isESM | ||
? `ImportExpression, ImportDeclaration, ExpressionStatement[expression.type='ImportExpression'], Property[key.name='import']` | ||
: `[callee.name='require']` | ||
let esmQuery = `ImportExpression, ImportDeclaration, ExpressionStatement[expression.type='ImportExpression'], Property[key.name='import']` | ||
let query = `[callee.name='require']` | ||
if (isESM) query = query += ', ' + esmQuery | ||
let imports = esquery.query(ast, query) | ||
@@ -42,5 +39,6 @@ | ||
if (isESM) { | ||
if (r.expression) arg = r.expression?.source | ||
else if (r.source) arg = r.source | ||
else if (r.value) arg = r.value?.params?.[0] | ||
if (r.expression) arg = r.expression?.source | ||
else if (r.source) arg = r.source | ||
else if (r.value) arg = r.value?.params?.[0] | ||
else if (r.arguments) arg = r?.arguments?.[0] | ||
} | ||
@@ -47,0 +45,0 @@ else { |
@@ -8,3 +8,3 @@ let { join } = require('path') | ||
module.exports = function getDirDeps ({ dir, update, inventory }) { | ||
// Clean everything (except the root) out bebefore we get going jic | ||
// Clean everything (except the root) out before we get going jic | ||
let isRoot = dir === inventory.inv._project.src | ||
@@ -11,0 +11,0 @@ if (!isRoot) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
60239
941