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

Fix dependency resolution when using pnpm #774

Merged
merged 3 commits into from
May 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"build": "tsc --version && tsc --project \"./src\"",
"comparison-tests": "npm link ./test/comparison-tests/testLib && node test/comparison-tests/run-tests.js",
"comparison-tests-generate": "node test/comparison-tests/stub-new-version.js",
"execution-tests": "node test/execution-tests/run-tests.js",
"execution-tests": "npm i -g pnpm && node test/execution-tests/run-tests.js",
"test": "node test/run-tests.js",
"precommit": "lint-staged"
},
Expand Down Expand Up @@ -78,6 +78,7 @@
"prettier": "^1.11.1",
"rimraf": "^2.6.2",
"typescript": "^2.7.2",
"webpack": "^4.5.0"
"webpack": "^4.5.0",
"webpack-cli": "^2.1.2"
}
}
6 changes: 1 addition & 5 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as typescript from 'typescript';
export { ModuleResolutionHost } from 'typescript';
import { Chalk } from 'chalk';

export interface SourceMap {
Expand Down Expand Up @@ -214,11 +215,6 @@ export interface ResolveSync {
(context: string | undefined, path: string, moduleName: string): string;
}

export interface ModuleResolutionHost {
fileExists(fileName: string): boolean;
readFile(fileName: string, encoding?: string | undefined): string | undefined;
}

export interface WatchHost
extends typescript.WatchCompilerHostOfFilesAndCompilerOptions<
typescript.BuilderProgram
Expand Down
6 changes: 4 additions & 2 deletions src/servicesHost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export function makeServicesHost(

const moduleResolutionHost: ModuleResolutionHost = {
fileExists,
readFile: readFileWithFallback
readFile: readFileWithFallback,
realpath: compiler.sys.realpath
};

// loader.context seems to work fine on Linux / Mac regardless causes problems for @types resolution on Windows for TypeScript < 2.3
Expand Down Expand Up @@ -170,7 +171,8 @@ export function makeWatchHost(

const moduleResolutionHost: ModuleResolutionHost = {
fileExists,
readFile: readFileWithFallback
readFile: readFileWithFallback,
realpath: compiler.sys.realpath
};

// loader.context seems to work fine on Linux / Mac regardless causes problems for @types resolution on Windows for TypeScript < 2.3
Expand Down
6 changes: 5 additions & 1 deletion test/comparison-tests/npmLink/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"compilerOptions": {
"module": "commonjs"
}
},
// so that ts files there is part of this ts project
"include": [
"../../test/comparison-tests/testLib/*"
]
}
11 changes: 11 additions & 0 deletions test/execution-tests/issue768/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "typescript-pnpm",
"main": "index.js",
"dependencies": {
"@types/react": "16.3.12",
"@types/react-dom": "16.0.5",
"office-ui-fabric-react": "5.88.0",
"react": "16.3.2",
"react-dom": "16.3.2"
}
}
215 changes: 215 additions & 0 deletions test/execution-tests/issue768/shrinkwrap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
dependencies:
'@types/react': 16.3.12
'@types/react-dom': 16.0.5
office-ui-fabric-react: 5.88.0
react: 16.3.2
react-dom: 16.3.2
packages:
/@microsoft/load-themed-styles/1.7.56:
dev: false
resolution:
integrity: sha1-/fyQ+yS9QnMx1xuDzLjtJ69/4pM=
/@types/node/10.0.4:
dev: false
resolution:
integrity: sha512-RisaZmcmCLjRipAY7nVi3fmkIk4Z0JMn8YHdGF6qYMsIDpD0dfzz+3yy2dL5Q5aHWOnqPx51IRxkA44myknJvw==
/@types/react-dom/16.0.5:
dependencies:
'@types/node': 10.0.4
'@types/react': 16.3.12
dev: false
resolution:
integrity: sha512-ony2hEYlGXCLWNAWWgbsHR7qVvDbeMRFc5b43+7dhj3n+zXzxz81HV9Yjpc3JD8vLCiwYoSLqFCI6bD0+0zG2Q==
/@types/react/16.3.12:
dependencies:
csstype: 2.4.2
dev: false
resolution:
integrity: sha512-FfBhLC3QeXXEtjoGGLixS7cB305vzBOM1dZKtbUuXeTfjY0quzRRMxpqylC4QyUaLqdhNLdER0ZdHUGAVlGSCA==
/@uifabric/icons/5.7.1:
dependencies:
'@uifabric/styling': 5.30.1
tslib: 1.9.0
dev: false
resolution:
integrity: sha512-UwfDU6A0bj/QAdTsO20g9mrKXo3zxvumkBWx0F0sEHn1DF/IQDiq4zYVBjRZ3NikQe2o7koWe3Gb0NR84Qr2Sg==
/@uifabric/merge-styles/5.17.0:
dependencies:
tslib: 1.9.0
dev: false
resolution:
integrity: sha512-xA4sbfKgOAx42gD56/ch8hWI6b7Gp70JM0kMnTIyF0oPWd12Lkvm5IVy1QZWxPE9YENIj5fn/mFWV2qkWKnJxQ==
/@uifabric/styling/5.30.1:
dependencies:
'@microsoft/load-themed-styles': 1.7.56
'@uifabric/merge-styles': 5.17.0
'@uifabric/utilities': 5.30.1
tslib: 1.9.0
dev: false
resolution:
integrity: sha512-FIPfljABxmhOp7f2ppR3/07D055dtAygtk5MIVhTzrJsyJuVFU560k7EyxJzXoMFptRaA3TH4obROP6qe8jQgA==
/@uifabric/utilities/5.30.1:
dependencies:
'@uifabric/merge-styles': 5.17.0
prop-types: 15.6.1
tslib: 1.9.0
dev: false
peerDependencies:
react: ^0.14.9 || ^15.0.1-0 || ^16.0.0-0
react-dom: ^0.14.9 || ^15.0.1-0 || ^16.0.0-0
resolution:
integrity: sha512-IbLhsCjkubLv/yAx+OxIQjXhGXxy5J7WpZMzsV9lPM6/CLXdfSkU5eX9C0FsvnGGzdaG2TzVqUFks1Z3VrqZFA==
/asap/2.0.6:
dev: false
resolution:
integrity: sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=
/core-js/1.2.7:
dev: false
resolution:
integrity: sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY=
/csstype/2.4.2:
dev: false
resolution:
integrity: sha512-1TnkyZwDy0oUl//6685j2bTMNe61SzntWntijNdmmEzvpYbGmVMZkj204gv4glcQp6z/ypg+YRziT91XVFmOyg==
/encoding/0.1.12:
dependencies:
iconv-lite: 0.4.21
dev: false
resolution:
integrity: sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=
/fbjs/0.8.16:
dependencies:
core-js: 1.2.7
isomorphic-fetch: 2.2.1
loose-envify: 1.3.1
object-assign: 4.1.1
promise: 7.3.1
setimmediate: 1.0.5
ua-parser-js: 0.7.18
dev: false
resolution:
integrity: sha1-XmdDL1UNxBtXK/VYR7ispk5TN9s=
/iconv-lite/0.4.21:
dependencies:
safer-buffer: 2.1.2
dev: false
engines:
node: '>=0.10.0'
resolution:
integrity: sha512-En5V9za5mBt2oUA03WGD3TwDv0MKAruqsuxstbMUZaj9W9k/m1CV/9py3l0L5kw9Bln8fdHQmzHSYtvpvTLpKw==
/is-stream/1.1.0:
dev: false
engines:
node: '>=0.10.0'
resolution:
integrity: sha1-EtSj3U5o4Lec6428hBc66A2RykQ=
/isomorphic-fetch/2.2.1:
dependencies:
node-fetch: 1.7.3
whatwg-fetch: 2.0.4
dev: false
resolution:
integrity: sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=
/js-tokens/3.0.2:
dev: false
resolution:
integrity: sha1-mGbfOVECEw449/mWvOtlRDIJwls=
/loose-envify/1.3.1:
dependencies:
js-tokens: 3.0.2
dev: false
resolution:
integrity: sha1-0aitM/qc4OcT1l/dCsi3SNR4yEg=
/node-fetch/1.7.3:
dependencies:
encoding: 0.1.12
is-stream: 1.1.0
dev: false
resolution:
integrity: sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==
/object-assign/4.1.1:
dev: false
engines:
node: '>=0.10.0'
resolution:
integrity: sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=
/office-ui-fabric-react/5.88.0:
dependencies:
'@microsoft/load-themed-styles': 1.7.56
'@uifabric/icons': 5.7.1
'@uifabric/merge-styles': 5.17.0
'@uifabric/styling': 5.30.1
'@uifabric/utilities': 5.30.1
prop-types: 15.6.1
tslib: 1.9.0
dev: false
peerDependencies:
react: ^0.14.9 || ^15.0.1-0 || ^16.0.0-0
react-dom: ^0.14.9 || ^15.0.1-0 || ^16.0.0-0
resolution:
integrity: sha512-Rz6q7wlIYwVurNqDusWX9YbvXjDsIS2qbRsam1Dg6iuNTefrZHFGrYV2c7T3NOBMEAA7Nc9muThqogHOF6lxQw==
/promise/7.3.1:
dependencies:
asap: 2.0.6
dev: false
resolution:
integrity: sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==
/prop-types/15.6.1:
dependencies:
fbjs: 0.8.16
loose-envify: 1.3.1
object-assign: 4.1.1
dev: false
resolution:
integrity: sha512-4ec7bY1Y66LymSUOH/zARVYObB23AT2h8cf6e/O6ZALB/N0sqZFEx7rq6EYPX2MkOdKORuooI/H5k9TlR4q7kQ==
/react-dom/16.3.2:
dependencies:
fbjs: 0.8.16
loose-envify: 1.3.1
object-assign: 4.1.1
prop-types: 15.6.1
dev: false
peerDependencies:
react: ^16.0.0
resolution:
integrity: sha512-MMPko3zYncNrz/7gG17wJWUREZDvskZHXOwbttzl0F0L3wDmToyuETuo/r8Y5yvDejwYcRyWI1lvVBjLJWFwKA==
/react/16.3.2:
dependencies:
fbjs: 0.8.16
loose-envify: 1.3.1
object-assign: 4.1.1
prop-types: 15.6.1
dev: false
engines:
node: '>=0.10.0'
resolution:
integrity: sha512-o5GPdkhciQ3cEph6qgvYB7LTOHw/GB0qRI6ZFNugj49qJCFfgHwVNjZ5u+b7nif4vOeMIOuYj3CeYe2IBD74lg==
/safer-buffer/2.1.2:
dev: false
resolution:
integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==
/setimmediate/1.0.5:
dev: false
resolution:
integrity: sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=
/tslib/1.9.0:
dev: false
resolution:
integrity: sha512-f/qGG2tUkrISBlQZEjEqoZ3B2+npJjIf04H1wuAv9iA8i04Icp+61KRXxFdha22670NJopsZCIjhC3SnjPRKrQ==
/ua-parser-js/0.7.18:
dev: false
resolution:
integrity: sha512-LtzwHlVHwFGTptfNSgezHp7WUlwiqb0gA9AALRbKaERfxwJoiX0A73QbTToxteIAuIaFshhgIZfqK8s7clqgnA==
/whatwg-fetch/2.0.4:
dev: false
resolution:
integrity: sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng==
registry: 'https://registry.npmjs.org/'
shrinkwrapMinorVersion: 5
shrinkwrapVersion: 3
specifiers:
'@types/react': 16.3.12
'@types/react-dom': 16.0.5
office-ui-fabric-react: 5.88.0
react: 16.3.2
react-dom: 16.3.2
3 changes: 3 additions & 0 deletions test/execution-tests/issue768/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { mergeStyles } from 'office-ui-fabric-react/lib/Styling';

mergeStyles({});
5 changes: 5 additions & 0 deletions test/execution-tests/issue768/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"compilerOptions": {

}
}
22 changes: 22 additions & 0 deletions test/execution-tests/issue768/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

module.exports = {
devtool: 'inline-source-map',
entry: './src/index.ts',
mode: 'development',
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader'
}
]
},
resolve: {
extensions: ['.ts', '.tsx', '.js']
},
stats: "errors-only"
};

// for test harness purposes only, you would not need this in a normal project
module.exports.resolveLoader = { alias: { 'ts-loader': require('path').join(__dirname, "../../../index.js") } }
19 changes: 14 additions & 5 deletions test/execution-tests/run-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,25 @@ function runTests(testName) {

var karmaConfPath = path.join(testPath, 'karma.conf.js');

if (pathExists(path.join(testPath, 'package.json'))) {
if (pathExists(path.join(testPath, 'shrinkwrap.yaml'))) {
console.log('pnpm install into ' + testPath);
execSync('pnpm install', { cwd: testPath, stdio: 'inherit' });
} else if (pathExists(path.join(testPath, 'package.json'))) {
console.log('yarn install into ' + testPath);
execSync('yarn install', { cwd: testPath, stdio: 'inherit' });
}

try {
var singleRunOrWatch = watch ? '' : ' --single-run';
execSync('karma start --reporters mocha' + singleRunOrWatch + ' --browsers ChromeHeadless', { cwd: testPath, stdio: 'inherit' });

passingTests.push(testName);
if (pathExists(path.join(testPath, 'karma.conf.js'))) {
var singleRunOrWatch = watch ? '' : ' --single-run';
execSync('karma start --reporters mocha' + singleRunOrWatch + ' --browsers ChromeHeadless', { cwd: testPath, stdio: 'inherit' });

passingTests.push(testName);
} else {
console.log('running webpack compliation');
execSync('webpack --bail', { cwd: testPath, stdio: 'inherit' });
passingTests.push(testName);
}
}
catch (err) {
failingTests.push(testName);
Expand Down