Skip to content

Commit

Permalink
fix: typescript is pure commonjs
Browse files Browse the repository at this point in the history
close #101
  • Loading branch information
JounQin committed Oct 27, 2023
1 parent 57523f7 commit 6fcc16b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
14 changes: 12 additions & 2 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ const EXTERNALS = [...builtinModules, ...Object.keys(pkg.dependencies)]
* @returns {boolean} should source file be externalized
*/
const external = source =>
EXTERNALS.some(external => new RegExp(`^${external}(\\/?|$)`).test(source))
EXTERNALS.some(
external => source === external || source.startsWith(`${external}/`),
)

/**
* @param {string} content file content
Expand Down Expand Up @@ -77,7 +79,15 @@ const configs = /** @type {const} */ (['cjs', 'esm']).map(format => ({
'util',
'vue-eslint-parser',
'@typescript-eslint/parser',
).replace(/(["'])(eslint-plugin-sonarjs\/[^"']+)\1/g, '$1$2.js$1')
)
.replace(/(["'])(eslint-plugin-sonarjs\/[^"']+)\1/g, '$1$2.js$1')
// fix #101
.replaceAll(/\bts__default\b/g, 'ts')
.replace(
// eslint-disable-next-line regexp/strict
/import ts, { SyntaxKind, TypeFlags } from 'typescript'/,
'const { SyntaxKind, TypeFlags } = ts',
)
}
},
},
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5095,6 +5095,10 @@ eslint-plugin-simple-import-sort@^10.0.0:
resolved "https://registry.yarnpkg.com/eslint-plugin-simple-import-sort/-/eslint-plugin-simple-import-sort-10.0.0.tgz#cc4ceaa81ba73252427062705b64321946f61351"
integrity sha512-AeTvO9UCMSNzIHRkg8S6c3RPy5YEwKWSQPx3DYghLedo2ZQxowPFLGDN1AZ2evfg6r6mjBSZSLxLFsWSu3acsw==

eslint-plugin-sonar@^0.11.1:
version "0.0.0"
uid ""

"eslint-plugin-sonar@link:eslint-plugin-sonar":
version "0.0.0"
uid ""
Expand Down

0 comments on commit 6fcc16b

Please sign in to comment.