Skip to content

Commit

Permalink
feat(providence): update version of oxc; cleanup; include .ts(x) and …
Browse files Browse the repository at this point in the history
…jsx by default
  • Loading branch information
tlouisse committed Jan 14, 2025
1 parent a992da4 commit b8cf6b9
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 28 deletions.
5 changes: 5 additions & 0 deletions .changeset/proud-pugs-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'providence-analytics': patch
---

update version of oxc; cleanup; include .ts(x) and jsx by default
31 changes: 28 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages-node/providence-analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
"test:node:unit": "mocha './{test-node,src}/**/*.test.js'"
},
"dependencies": {
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-node-resolve": "^16.0.0",
"commander": "^2.20.3",
"oxc-parser": "^0.39.0",
"oxc-parser": "^0.46.0",
"parse5": "^7.2.1",
"semver": "^7.6.3"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,9 @@ import { Analyzer } from '../core/Analyzer.js';

/**
* Intends to work for oxc, swc, and babel asts
* @param {SwcNode} s
*/
function getSpecifierValue(s) {
// for (const exportedorImportedName of [...exportedNames, ...importedNames]) {
// for (const valueName of valueNames) {
// const result = s[exportedorImportedName][valueName];
// if (result) return result;
// }
// }
// return undefined;

return (
// These are regular import values and must be checked first
s.imported?.value ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ import { AstService } from './AstService.js';
* @typedef {import('../../../types/index.js').Feature} Feature
*/

/** @type {`.${string}`[]} */
const defaultExtensions = ['.js', '.ts', '.jsx', '.tsx', '.mjs'];

/**
* @typedef {(rootPath:PathFromSystemRoot) => PackageJson|undefined} GetPackageJsonFn
* @type {GetPackageJsonFn}
Expand Down Expand Up @@ -179,8 +182,9 @@ const getNpmPackagePaths = memoize((/** @type {PathFromSystemRoot} */ rootPath)
});

/**
* @param {any|any[]} v
* @returns {any[]}
* @template T
* @param {T|T[]} v
* @returns {T[]}
*/
function ensureArray(v) {
return Array.isArray(v) ? v : [v];
Expand Down Expand Up @@ -429,7 +433,7 @@ export class InputDataService {
static get defaultGatherFilesConfig() {
return {
allowlist: ['!node_modules/**', '!bower_components/**', '!**/*.conf.js', '!**/*.config.js'],
extensions: ['.js'],
extensions: defaultExtensions,
depth: Infinity,
};
}
Expand All @@ -440,7 +444,7 @@ export class InputDataService {
* @param {string[]} extensions
* @returns {string}
*/
static _getDefaultGlobDepthPattern(depth = Infinity, extensions = ['.js']) {
static _getDefaultGlobDepthPattern(depth = Infinity, extensions = defaultExtensions) {
// `.{${cfg.extensions.map(e => e.slice(1)).join(',')},}`;
const extensionsGlobPart = `.{${extensions.map(extension => extension.slice(1)).join(',')},}`;
if (depth === Infinity) {
Expand Down Expand Up @@ -472,6 +476,15 @@ export class InputDataService {
* @returns {Promise<PathFromSystemRoot[]>} result list of file paths
*/
static async gatherFilesFromDir(startPath, customConfig = {}) {
const allowlistModes = ['npm', 'git', 'all', 'export-map'];
if (customConfig.allowlistMode && !allowlistModes.includes(customConfig.allowlistMode)) {
throw new Error(
`[gatherFilesConfig] Please provide a valid allowListMode like "${allowlistModes.join(
'|',
)}". Found: "${customConfig.allowlistMode}"`,
);
}

const cfg = {
...this.defaultGatherFilesConfig,
...customConfig,
Expand All @@ -483,15 +496,6 @@ export class InputDataService {
];
}

const allowlistModes = ['npm', 'git', 'all', 'export-map'];
if (customConfig.allowlistMode && !allowlistModes.includes(customConfig.allowlistMode)) {
throw new Error(
`[gatherFilesConfig] Please provide a valid allowListMode like "${allowlistModes.join(
'|',
)}". Found: "${customConfig.allowlistMode}"`,
);
}

if (cfg.allowlistMode === 'export-map') {
const pkgJson = getPackageJson(startPath);
if (!pkgJson?.exports) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,7 @@ describe('Memoize', () => {
{ fn: spy2Memoized, count: 4 },
]);

console.debug('spy3Memoized');
spy3Memoized();
console.debug(memoize.cacheStrategyItems);
expect(memoize.cacheStrategyItems).to.deep.equal([
{ fn: spy2Memoized, count: 4 },
{ fn: spy3Memoized, count: 1 }, // we start over
Expand Down

0 comments on commit b8cf6b9

Please sign in to comment.