Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref(typescript): remove resolve package #1742

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@
}
},
"dependencies": {
"@rollup/pluginutils": "^5.1.0",
"resolve": "^1.22.1"
"@rollup/pluginutils": "^5.1.0"
},
"devDependencies": {
"@rollup/plugin-buble": "^1.0.0",
Expand Down
20 changes: 6 additions & 14 deletions packages/typescript/src/tslib.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
import { fileURLToPath } from 'url';

import type { SyncOpts } from 'resolve';
import resolve from 'resolve';

// const resolveIdAsync = (file: string, opts: AsyncOpts) =>
// new Promise<string>((fulfil, reject) =>
// resolveId(file, opts, (err, contents) =>
// err || typeof contents === 'undefined' ? reject(err) : fulfil(contents)
// )
// );

const resolveId = (file: string, opts: SyncOpts) => resolve.sync(file, opts);
import { createRequire } from 'module';

/**
* Returns code asynchronously for the tslib helper library.
*/
export const getTsLibPath = () => {
// @ts-ignore import.meta.url is allowed because the Rollup plugin injects the correct module format
const require = createRequire(import.meta.url);
// Note: This isn't preferable, but we've no other way to test this bit. Removing the tslib devDep
// during the test run doesn't work due to the nature of the pnpm flat node_modules, and
// other workspace dependencies that depenend upon tslib.
try {
// eslint-disable-next-line no-underscore-dangle
return resolveId(process.env.__TSLIB_TEST_PATH__ || 'tslib/tslib.es6.js', {
// @ts-ignore import.meta.url is allowed because the Rollup plugin injects the correct module format
basedir: fileURLToPath(new URL('.', import.meta.url))
return require.resolve(process.env.__TSLIB_TEST_PATH__ || 'tslib/tslib.es6.js', {
// @ts-ignore See import.meta.url above
paths: [fileURLToPath(new URL('.', import.meta.url))]
});
} catch (_) {
return null;
Expand Down
Loading
Loading