Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: load .env value also if entry target is specified with source value in package.json #7537

Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
84aede1
Fix: make each entry file refers some (virtual) file before getRootDir
Shinyaigeek Jan 7, 2022
bb1b902
Chore: add test case for .env with entry specified with package.source
Shinyaigeek Jan 7, 2022
d4170d0
Merge branch 'v2' into fix/inline-env-file-with-source-package-entry
Shinyaigeek Jan 15, 2022
4ce447e
Merge branch 'v2' into fix/inline-env-file-with-source-package-entry
Shinyaigeek Jan 18, 2022
1627b1c
Merge branch 'v2' into fix/inline-env-file-with-source-package-entry
Shinyaigeek Jan 26, 2022
6746fdf
Merge branch 'v2' into fix/inline-env-file-with-source-package-entry
Shinyaigeek Jan 28, 2022
82dad6d
Merge branch 'v2' into fix/inline-env-file-with-source-package-entry
Shinyaigeek Jan 31, 2022
0eda1b7
Merge branch 'v2' into fix/inline-env-file-with-source-package-entry
Shinyaigeek Feb 4, 2022
bb4b78c
Merge branch 'v2' into fix/inline-env-file-with-source-package-entry
Shinyaigeek Feb 10, 2022
79f6d76
Merge branch 'v2' into fix/inline-env-file-with-source-package-entry
Shinyaigeek Feb 12, 2022
81c3e8f
Merge branch 'v2' into fix/inline-env-file-with-source-package-entry
Shinyaigeek Feb 18, 2022
a725a6f
Merge branch 'v2' into fix/inline-env-file-with-source-package-entry
Shinyaigeek Feb 23, 2022
1b22141
Merge branch 'v2' into fix/inline-env-file-with-source-package-entry
Shinyaigeek Mar 1, 2022
5ea84ce
Merge branch 'v2' into fix/inline-env-file-with-source-package-entry
Shinyaigeek Mar 2, 2022
ec835d7
Merge branch 'v2' into fix/inline-env-file-with-source-package-entry
Shinyaigeek Mar 12, 2022
4dcae5c
Merge branch 'v2' into fix/inline-env-file-with-source-package-entry
Shinyaigeek Mar 13, 2022
6dd6df7
Update packages/core/integration-tests/test/javascript.js
Shinyaigeek Mar 13, 2022
4b2d4a6
Update: only resolve index when entry is file
Shinyaigeek Mar 13, 2022
d5fda50
Merge branch 'v2' into fix/inline-env-file-with-source-package-entry
Shinyaigeek Mar 20, 2022
7ea8c51
Merge branch 'v2' into fix/inline-env-file-with-source-package-entry
Shinyaigeek Mar 21, 2022
6c370bc
Update packages/core/core/src/resolveOptions.js
mischnic Mar 21, 2022
6d0ccf2
Merge branch 'v2' into fix/inline-env-file-with-source-package-entry
Shinyaigeek Mar 23, 2022
7c9d5a8
Update: handle entries specified with source in a specific case for perf
Shinyaigeek Mar 23, 2022
1201d63
Update packages/core/core/src/resolveOptions.js
mischnic Mar 23, 2022
8aae3df
Merge branch 'v2' into fix/inline-env-file-with-source-package-entry
Shinyaigeek Mar 29, 2022
4491fde
Merge branch 'v2' into fix/inline-env-file-with-source-package-entry
Shinyaigeek Mar 31, 2022
9c00171
Merge branch 'v2' into fix/inline-env-file-with-source-package-entry
Shinyaigeek Apr 2, 2022
aa4b037
Merge branch 'v2' into fix/inline-env-file-with-source-package-entry
Shinyaigeek Apr 7, 2022
9d11e6d
Merge branch 'v2' into fix/inline-env-file-with-source-package-entry
mischnic Apr 15, 2022
6ce5845
Merge branch 'v2' into fix/inline-env-file-with-source-package-entry
mischnic Apr 15, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion packages/core/core/src/resolveOptions.js
Expand Up @@ -50,7 +50,18 @@ export default async function resolveOptions(
entries = [path.resolve(inputCwd, initialOptions.entries)];
}

let entryRoot = getRootDir(entries);
let entryRoot = getRootDir(
await Promise.all(
entries.map(async entry =>
// getRootDir treats the input as files, so getRootDir(["/home/user/myproject"]) returns "/home/user".
// Instead we need to make the entries refer to some file inside the specified folders.
(await inputFS.stat(entry)).isFile()
? entry
: path.join(entry, 'index'),
),
),
);

let projectRootFile =
(await resolveConfig(
inputFS,
Expand Down
@@ -0,0 +1,2 @@
FOO=bar
BAR=test
@@ -0,0 +1 @@
module.exports = process.env.FOO + process.env.BAR;
@@ -0,0 +1,4 @@
{
"name": "env-file-with-package-source",
"source": "index.js"
}
9 changes: 9 additions & 0 deletions packages/core/integration-tests/test/javascript.js
Expand Up @@ -2978,6 +2978,15 @@ describe('javascript', function () {
assert.equal(output, 'barbaz');
});

it('should insert environment variables from a file even if entry file is specified with source value in package.json', async function () {
let b = await bundle(
path.join(__dirname, '/integration/env-file-with-package-source'),
);

let output = await run(b);
assert.equal(output, 'bartest');
});

it('should error on process.env mutations', async function () {
let filePath = path.join(__dirname, '/integration/env-mutate/index.js');
await assert.rejects(bundle(filePath), {
Expand Down