Socket
Socket
Sign inDemoInstall

@web/config-loader

Package Overview
Dependencies
Maintainers
7
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@web/config-loader - npm Package Compare versions

Comparing version 0.0.0-canary-20230420104136 to 0.0.0-canary-20231122093600

dist/ConfigLoaderError.js

3

dist/ConfigLoaderError.d.ts

@@ -1,4 +0,3 @@

export = ConfigLoaderError;
declare class ConfigLoaderError extends Error {
export default class ConfigLoaderError extends Error {
}
//# sourceMappingURL=ConfigLoaderError.d.ts.map

@@ -1,2 +0,1 @@

export = getPackageType;
/**

@@ -8,3 +7,3 @@ * Gets the package type for a given directory. Walks up the file system, looking

*/
declare function getPackageType(basedir: string): Promise<string>;
export default function getPackageType(basedir: string): Promise<string>;
//# sourceMappingURL=getPackageType.d.ts.map

@@ -1,6 +0,5 @@

export = importConfig;
/**
* @param {string} path
*/
declare function importConfig(path: string): Promise<any>;
export function importConfig(path: string): Promise<any>;
//# sourceMappingURL=importConfig.d.ts.map

@@ -1,2 +0,1 @@

export = importOrRequireConfig;
/**

@@ -6,3 +5,3 @@ * @param {string} configPath

*/
declare function importOrRequireConfig(configPath: string, basedir: string): Promise<any>;
export default function importOrRequireConfig(configPath: string, basedir: string): Promise<any>;
//# sourceMappingURL=importOrRequireConfig.d.ts.map

@@ -7,4 +7,4 @@ /**

export function readConfig(name: string, customPath?: string | undefined, basedir?: string | undefined): Promise<any>;
import ConfigLoaderError = require("./ConfigLoaderError.js");
import ConfigLoaderError from './ConfigLoaderError.js';
export { ConfigLoaderError };
//# sourceMappingURL=index.d.ts.map

@@ -1,6 +0,5 @@

export = requireConfig;
/**
* @param {string} path
*/
declare function requireConfig(path: string): any;
export default function requireConfig(path: string): any;
//# sourceMappingURL=requireConfig.d.ts.map

@@ -1,1 +0,1 @@

export * from './dist/index';
export * from './dist/index.js';
{
"name": "@web/config-loader",
"version": "0.0.0-canary-20230420104136",
"version": "0.0.0-canary-20231122093600",
"publishConfig": {

@@ -15,6 +15,7 @@ "access": "public"

"author": "modern-web",
"type": "module",
"homepage": "https://github.com/modernweb-dev/web/tree/master/packages/config-loader",
"main": "src/index.js",
"engines": {
"node": ">=16.0.0"
"node": ">=18.0.0"
},

@@ -24,3 +25,3 @@ "scripts": {

"test": "mocha test/**/*.test.js --reporter dot",
"test:ci": "yarn test",
"test:ci": "npm run test",
"test:watch": "mocha test/**/*.test.js --watch --watch-files .,src,test --reporter dot"

@@ -43,8 +44,7 @@ },

],
"dependencies": {
"semver": "^7.3.4"
},
"dependencies": {},
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./index.d.ts",
"import": "./index.mjs",

@@ -51,0 +51,0 @@ "require": "./src/index.js"

@@ -1,1 +0,1 @@

module.exports = class ConfigLoaderError extends Error {};
export default class ConfigLoaderError extends Error {};

@@ -1,4 +0,4 @@

const fs = require('fs').promises;
const path = require('path');
const { fileExists } = require('./utils');
import fs from 'fs/promises';
import path from 'path';
import { fileExists } from './utils.js';

@@ -11,3 +11,3 @@ /**

*/
async function getPackageType(basedir) {
export default async function getPackageType(basedir) {
let currentPath = basedir;

@@ -31,3 +31,1 @@ try {

}
module.exports = getPackageType;

@@ -1,7 +0,4 @@

const semver = require('semver');
const { pathToFileURL } = require('url');
const ConfigLoaderError = require('./ConfigLoaderError');
import { pathToFileURL } from 'url';
import ConfigLoaderError from './ConfigLoaderError.js';
const supportsEsm = semver.satisfies(process.version, '>=12.17.0');
// These strings may be node-version dependent and need updating over time

@@ -18,11 +15,3 @@ // They're just to display a helpful error message

*/
async function importConfig(path) {
if (!supportsEsm) {
throw new ConfigLoaderError(
'You are trying to load a config as es module but your version of node does not support it. ' +
'Update to node v12.17.0 or higher, or load the config as commonjs by using the .cjs extension ' +
'or .js without type="module" set in your package.json',
);
}
export async function importConfig(path) {
try {

@@ -39,3 +28,3 @@ const config = await import(pathToFileURL(path).href);

} catch (e) {
if (CJS_ERRORS.some(msg => e.stack.includes(msg))) {
if (CJS_ERRORS.some(msg => /** @type {Error} */(e).stack?.includes(msg))) {
throw new ConfigLoaderError(

@@ -50,3 +39,1 @@ 'You are using CommonJS syntax such as "require" or "module.exports" in a config loaded as es module. ' +

}
module.exports = importConfig;

@@ -1,4 +0,4 @@

const getPackageType = require('./getPackageType');
const path = require('path');
const requireConfig = require('./requireConfig');
import getPackageType from './getPackageType.js';
import path from 'path';
import requireConfig from './requireConfig.js';

@@ -8,7 +8,7 @@ /**

*/
function importConfig(configPath) {
async function importConfig(configPath) {
// Conditionally requires importConfig function to avoid logging a warning on node v12
// when not using an es modules
const importConfigFunction = require('./importConfig');
return importConfigFunction(configPath);
const {importConfig} = await import('./importConfig.js');
return importConfig(configPath);
}

@@ -20,3 +20,3 @@

*/
async function importOrRequireConfig(configPath, basedir) {
export default async function importOrRequireConfig(configPath, basedir) {
const packageType = await getPackageType(basedir);

@@ -34,3 +34,1 @@ const ext = path.extname(configPath);

}
module.exports = importOrRequireConfig;

@@ -1,5 +0,5 @@

const path = require('path');
const { fileExists } = require('./utils');
const ConfigLoaderError = require('./ConfigLoaderError.js');
const importOrRequireConfig = require('./importOrRequireConfig');
import { fileExists } from './utils.js';
import path from 'path';
import ConfigLoaderError from './ConfigLoaderError.js';
import importOrRequireConfig from './importOrRequireConfig.js';

@@ -35,2 +35,2 @@ const EXTENSIONS = ['.mjs', '.cjs', '.js'];

module.exports = { readConfig, ConfigLoaderError };
export { readConfig, ConfigLoaderError };

@@ -1,2 +0,4 @@

const ConfigLoaderError = require('./ConfigLoaderError');
import ConfigLoaderError from './ConfigLoaderError.js';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);

@@ -13,7 +15,7 @@ // These strings may be node-version dependent and need updating over time

*/
function requireConfig(path) {
export default function requireConfig(path) {
try {
return require(path);
} catch (e) {
if (ESM_ERRORS.some(msg => e.stack.includes(msg))) {
if (ESM_ERRORS.some(msg => /** @type {Error} **/(e).stack?.includes(msg))) {
throw new ConfigLoaderError(

@@ -28,3 +30,1 @@ 'You are using es module syntax in a config loaded as CommonJS module. ' +

}
module.exports = requireConfig;

@@ -1,2 +0,2 @@

const fs = require('fs').promises;
import fs from 'fs/promises';

@@ -6,3 +6,3 @@ /**

*/
async function fileExists(path) {
export async function fileExists(path) {
try {

@@ -15,3 +15,1 @@ await fs.access(path);

}
module.exports = { fileExists };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc