Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
major: assets should not be parsed (#304)
This PR changes the behavior of dependency tracing such that `fs.readFile('./file.js')` is no longer considered a `dependency` and it will not be traced. Instead, it is considered an `asset` the same way a `fs.readFile('./file.txt')` is. The `dependency` type will be reserved for `import` and `require` only. - Fixes #303 - Related to vercel/customer-issues#608 Note that this could be considered a breaking change since #40 expected the `readFile()` config to be called for assets but it should only be called for dependencies. In order to reduce the amount of breakage, `require.resolve()` was left as dependency instead of asset since its often passed to `child_process.spawn()` which needs the dependencies. Co-authored-by: JJ Kasper <jj@jjsweb.site>
- Loading branch information
Showing
16 changed files
with
114 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
file1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
file2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const { readdirSync } = require('fs'); | ||
const { join } = require('path'); | ||
|
||
readdirSync(join(__dirname, 'lib')) | ||
.filter(f => f.endsWith('.js')) | ||
.forEach(f => { | ||
const mod = require('./lib/' + f); | ||
console.log(`mod: ${mod}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const { join } = require('path'); | ||
const file1 = join(__dirname, '..', 'asset', 'file1.js'); | ||
const dep2 = require('../more/dep2.js'); | ||
|
||
module.exports = `dep1 has asset ${file1} and dep ${dep2}` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const { join } = require('path'); | ||
const file2 = join(__dirname, '..', 'asset', 'file2.js'); | ||
|
||
module.exports = `dep2 has file ${file2}`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[ | ||
"package.json", | ||
"test/unit/fs-and-require/asset/file1.js", | ||
"test/unit/fs-and-require/asset/file2.js", | ||
"test/unit/fs-and-require/input.js", | ||
"test/unit/fs-and-require/lib/dep1.js", | ||
"test/unit/fs-and-require/more/dep2.js" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
require('./dep2') | ||
|
||
module.exports = { dep1: 'dep1' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = { dep2: 'dep2' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
included | ||
export const dep = 'dep' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
import * as fs from "fs"; | ||
|
||
fs.readFileSync(__dirname + '/dep.tsx'); | ||
import { dep } from './dep' |