Skip to content

Commit

Permalink
Rename tsconfig to what it really is.
Browse files Browse the repository at this point in the history
  • Loading branch information
thesoftwarephilosopher committed Aug 14, 2024
1 parent 8f6be06 commit ce0426e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { readFileSync } from 'fs';

export class Compiler {

tsconfig = JSON.parse(readFileSync('package.json').toString('utf8'));
packageJson = JSON.parse(readFileSync('package.json').toString('utf8'));

compile(code: string, realFilePath?: string, browserFilePath?: string) {
let prefix = '';
Expand All @@ -21,16 +21,16 @@ export class Compiler {
if (imp.type === 'ImportDeclaration') {
const dep = imp.source.value;
const version = (
this.tsconfig.devDependencies[dep] ??
this.tsconfig.dependencies[dep]
this.packageJson.devDependencies[dep] ??
this.packageJson.dependencies[dep]
);
if (version) {
delete imp.source.raw;
imp.source.value = `https://cdn.jsdelivr.net/npm/${dep}@${version}/+esm`;
}
else {
const typeDep = '@types/' + dep.replace(/^@(.+?)\/(.+)/, '$1__$2');
if (this.tsconfig.devDependencies[typeDep]) {
if (this.packageJson.devDependencies[typeDep]) {
delete imp.source.raw;
imp.source.value = `https://cdn.jsdelivr.net/npm/${dep}/+esm`;
}
Expand Down

0 comments on commit ce0426e

Please sign in to comment.