diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e146ef..9c73d43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). * [#27]: support for Node 22. ### Changed +* [#31]: **BREAKING CHANGE**: changed the default config file name from `.esmlmrc.js` to `esmlm.config.js`. * [#26]: **BREAKING CHANGE**: updated dependencies: | Dependency | Old version | New version | @@ -78,6 +79,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). [#24]: https://github.com/Comandeer/esm-loader-manager/issues/24 [#26]: https://github.com/Comandeer/esm-loader-manager/issues/26 [#27]: https://github.com/Comandeer/esm-loader-manager/issues/27 +[#31]: https://github.com/Comandeer/esm-loader-manager/issues/31 [0.6.0]: https://github.com/Comandeer/esm-loader-manager/compare/v0.5.1...v0.6.0 [0.5.1]: https://github.com/Comandeer/esm-loader-manager/compare/v0.5.0...v0.5.1 diff --git a/README.md b/README.md index c3c4f33..48a3465 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ The loader manager does nothing on its own but you can declare your loaders insi ### Configuration file format -The configuration file needs to be named `.esmlmrc.js` or `.esmlmrc.mjs`. +The configuration file needs to be named `esmlm.config.js` or `esmlm.config.mjs`. The sample one could look like the one below: @@ -99,15 +99,15 @@ The manager will look for the configuration file inside the CWD and go up until ``` - projectRoot/ |- package.json -|- .esmlmrc.js +|- esmlm.config.js |- subdir/ | |- app.js -| |- .esmlmrc.js +| |- esmlm.config.js |- someOtherDir/ | |- someOtherApp.js ``` -If we launch Node.js inside `projectRoot/subdir`, the manager will use the `projectRoot/subdir/.esmlmrc.js` file. However, if we launch Node.js inside `projectRoot/someOtherDir` (which does not contain its own configuration file), the `projectRoot/.esmlmrc.js` one will be used. +If we launch Node.js inside `projectRoot/subdir`, the manager will use the `projectRoot/subdir/esmlm.config.js` file. However, if we launch Node.js inside `projectRoot/someOtherDir` (which does not contain its own configuration file), the `projectRoot/esmlm.config.js` one will be used. If for some reason you want to have a config file under some other name, you can provide the path to it via `ESMLM_CONFIG` environment variable, e.g. @@ -155,7 +155,7 @@ import samplePng from './sample.png'; console.log( samplePng ); // data:image/png;base64,[…] ``` -**.esmlmrc.js** +**esmlm.config.js** ```javascript export default { diff --git a/src/utilities/resolveConfigFile.ts b/src/utilities/resolveConfigFile.ts index c6f8c91..261fe76 100644 --- a/src/utilities/resolveConfigFile.ts +++ b/src/utilities/resolveConfigFile.ts @@ -1,7 +1,7 @@ import { readdir } from 'node:fs/promises'; import { resolve as resolvePath } from 'pathe'; -const configFileName = '.esmlmrc'; +const configFileName = 'esmlm.config'; const configFileExtensions = [ '.js', '.mjs' diff --git a/tests/__fixtures__/builtinModules/.esmlmrc.js b/tests/__fixtures__/builtinModules/esmlm.config.js similarity index 100% rename from tests/__fixtures__/builtinModules/.esmlmrc.js rename to tests/__fixtures__/builtinModules/esmlm.config.js diff --git a/tests/__fixtures__/customConfigFile/.esmlmrc.js b/tests/__fixtures__/customConfigFile/esmlm.config.js similarity index 100% rename from tests/__fixtures__/customConfigFile/.esmlmrc.js rename to tests/__fixtures__/customConfigFile/esmlm.config.js diff --git a/tests/__fixtures__/esmlm/.esmlmrc.js b/tests/__fixtures__/esmlm/esmlm.config.js similarity index 100% rename from tests/__fixtures__/esmlm/.esmlmrc.js rename to tests/__fixtures__/esmlm/esmlm.config.js diff --git a/tests/__fixtures__/esmlmArgs/.esmlmrc.js b/tests/__fixtures__/esmlmArgs/esmlm.config.js similarity index 100% rename from tests/__fixtures__/esmlmArgs/.esmlmrc.js rename to tests/__fixtures__/esmlmArgs/esmlm.config.js diff --git a/tests/__fixtures__/esmlmError/.esmlmrc.js b/tests/__fixtures__/esmlmError/esmlm.config.js similarity index 100% rename from tests/__fixtures__/esmlmError/.esmlmrc.js rename to tests/__fixtures__/esmlmError/esmlm.config.js diff --git a/tests/__fixtures__/loaderArgs/.esmlmrc.js b/tests/__fixtures__/loaderArgs/esmlm.config.js similarity index 100% rename from tests/__fixtures__/loaderArgs/.esmlmrc.js rename to tests/__fixtures__/loaderArgs/esmlm.config.js diff --git a/tests/__fixtures__/moduleConfigFile/.esmlmrc.mjs b/tests/__fixtures__/moduleConfigFile/esmlm.config.mjs similarity index 100% rename from tests/__fixtures__/moduleConfigFile/.esmlmrc.mjs rename to tests/__fixtures__/moduleConfigFile/esmlm.config.mjs diff --git a/tests/__fixtures__/multipleConfigFiles/.esmlmrc.js b/tests/__fixtures__/multipleConfigFiles/esmlm.config.js similarity index 100% rename from tests/__fixtures__/multipleConfigFiles/.esmlmrc.js rename to tests/__fixtures__/multipleConfigFiles/esmlm.config.js diff --git a/tests/__fixtures__/multipleConfigFiles/.esmlmrc.mjs b/tests/__fixtures__/multipleConfigFiles/esmlm.config.mjs similarity index 100% rename from tests/__fixtures__/multipleConfigFiles/.esmlmrc.mjs rename to tests/__fixtures__/multipleConfigFiles/esmlm.config.mjs diff --git a/tests/__fixtures__/multipleLoaders/.esmlmrc.js b/tests/__fixtures__/multipleLoaders/esmlm.config.js similarity index 100% rename from tests/__fixtures__/multipleLoaders/.esmlmrc.js rename to tests/__fixtures__/multipleLoaders/esmlm.config.js diff --git a/tests/__fixtures__/nested/.esmlmrc.js b/tests/__fixtures__/nested/esmlm.config.js similarity index 100% rename from tests/__fixtures__/nested/.esmlmrc.js rename to tests/__fixtures__/nested/esmlm.config.js diff --git a/tests/__fixtures__/nested/level1/level2/.esmlmrc.js b/tests/__fixtures__/nested/level1/level2/esmlm.config.js similarity index 100% rename from tests/__fixtures__/nested/level1/level2/.esmlmrc.js rename to tests/__fixtures__/nested/level1/level2/esmlm.config.js diff --git a/tests/__fixtures__/noProjectRoot/cwd/.esmlmrc.mjs b/tests/__fixtures__/noProjectRoot/cwd/esmlm.config.mjs similarity index 100% rename from tests/__fixtures__/noProjectRoot/cwd/.esmlmrc.mjs rename to tests/__fixtures__/noProjectRoot/cwd/esmlm.config.mjs diff --git a/tests/__fixtures__/npmImports/.esmlmrc.js b/tests/__fixtures__/npmImports/esmlm.config.js similarity index 100% rename from tests/__fixtures__/npmImports/.esmlmrc.js rename to tests/__fixtures__/npmImports/esmlm.config.js diff --git a/tests/__fixtures__/outsideProjectRoot/projectRoot/.esmlmrc.js b/tests/__fixtures__/outsideProjectRoot/projectRoot/esmlm.config.js similarity index 100% rename from tests/__fixtures__/outsideProjectRoot/projectRoot/.esmlmrc.js rename to tests/__fixtures__/outsideProjectRoot/projectRoot/esmlm.config.js diff --git a/tests/__fixtures__/resolvingURLs/.esmlmrc.js b/tests/__fixtures__/resolvingURLs/esmlm.config.js similarity index 100% rename from tests/__fixtures__/resolvingURLs/.esmlmrc.js rename to tests/__fixtures__/resolvingURLs/esmlm.config.js diff --git a/tests/__fixtures__/simpleLoader/.esmlmrc.js b/tests/__fixtures__/simpleLoader/esmlm.config.js similarity index 100% rename from tests/__fixtures__/simpleLoader/.esmlmrc.js rename to tests/__fixtures__/simpleLoader/esmlm.config.js diff --git a/tests/utilities/resolveConfigFile.ts b/tests/utilities/resolveConfigFile.ts index a31b220..e467a07 100644 --- a/tests/utilities/resolveConfigFile.ts +++ b/tests/utilities/resolveConfigFile.ts @@ -4,8 +4,8 @@ import mockFS from 'mock-fs'; import fixtureDirPath from '../__helpers__/fixtureDirPath.js'; import resolveConfigFile from '../../src/utilities/resolveConfigFile.js'; -const configFileName = '.esmlmrc.js'; -const configModuleFileName = '.esmlmrc.mjs'; +const configFileName = 'esmlm.config.js'; +const configModuleFileName = 'esmlm.config.mjs'; const simpleLoaderDirPath = resolvePath( fixtureDirPath, 'simpleLoader' ); const nestedLoaderDirPath = resolvePath( fixtureDirPath, 'nested' ); const nestedLoaderLevel1DirPath = resolvePath( nestedLoaderDirPath, 'level1' ); @@ -25,35 +25,35 @@ test.after( () => { mockFS.restore(); } ); -test( 'resolveConfigFile() points to the nearest .esmlmrc.js file (same dir)', async ( t ) => { +test( 'resolveConfigFile() points to the nearest esmlm.config.js file (same dir)', async ( t ) => { const expectedConfigFilePath = resolvePath( simpleLoaderDirPath, configFileName ); const resolvedConfigFilePath = await resolveConfigFile( simpleLoaderDirPath, simpleLoaderDirPath ); t.is( resolvedConfigFilePath, expectedConfigFilePath ); } ); -test( 'resolveConfigFile() points to the nearest .esmlmrc.js file (nested dir)', async ( t ) => { +test( 'resolveConfigFile() points to the nearest esmlm.config.js file (nested dir)', async ( t ) => { const expectedConfigFilePath = resolvePath( nestedLoaderDirPath, configFileName ); const resolvedConfigFilePath = await resolveConfigFile( nestedLoaderLevel1DirPath, nestedLoaderDirPath ); t.is( resolvedConfigFilePath, expectedConfigFilePath ); } ); -test( 'resolveConfigFile() points to the nearest .esmlmrc.js file (deeply nested dir)', async ( t ) => { +test( 'resolveConfigFile() points to the nearest esmlm.config.js file (deeply nested dir)', async ( t ) => { const expectedConfigFilePath = resolvePath( nestedLoaderLevel2DirPath, configFileName ); const resolvedConfigFilePath = await resolveConfigFile( nestedLoaderLevel3DirPath, nestedLoaderDirPath ); t.is( resolvedConfigFilePath, expectedConfigFilePath ); } ); -test( 'resolveConfigFile() points to the nearest .esmlmrc.mjs file', async ( t ) => { +test( 'resolveConfigFile() points to the nearest esmlm.config.mjs file', async ( t ) => { const expectedConfigFilePath = resolvePath( moduleConfigFileDirPath, configModuleFileName ); const resolvedConfigFilePath = await resolveConfigFile( moduleConfigFileDirPath, moduleConfigFileDirPath ); t.is( resolvedConfigFilePath, expectedConfigFilePath ); } ); -test( 'resolveConfigFile() prefers .esmlmrc.js over .esmlmrc.mjs', async ( t ) => { +test( 'resolveConfigFile() prefers esmlm.config.js over esmlm.config.mjs', async ( t ) => { const expectedConfigFilePath = resolvePath( multipleConfigFilesDirPath, configFileName ); const resolvedConfigFilePath = await resolveConfigFile( multipleConfigFilesDirPath, multipleConfigFilesDirPath );