Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

[config] Fix relative module resolution for config files #2744

Merged
merged 1 commit into from
Oct 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/config/src/__tests__/ConfigParsing-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ describe('getConfig', () => {
expect(exp.foo).toBe('bar');
expect(exp.name).toBe('cool+export-json_app.config');
});
it('parses a js config with import', () => {
const projectRoot = path.resolve(__dirname, './fixtures/language-support/js');
const configPath = path.resolve(projectRoot, 'with-import_app.config.js');
setCustomConfigPath(projectRoot, configPath);
const { exp } = getConfig(projectRoot, {
skipSDKVersionRequirement: true,
});
expect(exp.foo).toBe('bar');
});
xit('parses a yaml config', () => {
const projectRoot = path.resolve(__dirname, './fixtures/language-support/yaml');
const { exp } = getConfig(projectRoot, {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const { foo } = require('./export-json_app.config');

module.exports = function ({ config }) {
config.foo = foo;
return config;
};
2 changes: 1 addition & 1 deletion packages/config/src/evalConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function evalConfig(
presets: [preset],
});

let result = requireString(code);
let result = requireString(code, configFile);
if (result.default != null) {
result = result.default;
}
Expand Down