Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/fabric-website/config/pre-copy.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"copyTo": {
"lib": [
"src/**/*.json"
"./src/**/*.json"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const diagramStyles: any = require('./GetStartedPage.diagram.module.scss');
import * as stylesImport from './GetStartedPage.module.scss';
const styles: any = stylesImport;
const pageStyles: any = require('../PageStyles.module.scss');
const corePackageData = require('../../../node_modules/office-ui-fabric-core/package.json');
const corePackageData = require('office-ui-fabric-core/package.json');
const corePackageVersion: string = corePackageData && corePackageData.version || '9.2.0';

export class GetStartedPage extends React.Component<any, any> {
Expand Down
4 changes: 2 additions & 2 deletions apps/fabric-website/src/pages/HomePage/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { css } from 'office-ui-fabric-react/lib/Utilities';
import * as stylesImport from './HomePage.module.scss';
const styles: any = stylesImport;

const corePackageData = require('../../../node_modules/office-ui-fabric-core/package.json');
const reactPackageData = require('../../../node_modules/office-ui-fabric-react/package.json');
const corePackageData = require('office-ui-fabric-core/package.json');
const reactPackageData = require('office-ui-fabric-react/package.json');

export class HomePage extends React.Component<any, any> {
public render(): JSX.Element {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as stylesImport from './IconsPage.module.scss';
const styles: any = stylesImport;
const pageStyles: any = require('../../PageStyles.module.scss');

const iconData = require('../../../../node_modules/office-ui-fabric-core/src/data/icons.json');
const iconData = require('office-ui-fabric-core/src/data/icons.json');

export class IconsPage extends React.Component<any, any> {
public render(): JSX.Element {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@uifabric/fabric-website",
"comment": "made sure the deps are resolved by package rather than relative paths",
"type": "patch"
}
],
"packageName": "@uifabric/fabric-website",
"email": "kchau@microsoft.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "",
"packageName": "office-ui-fabric-react",
"type": "none"
}
],
"packageName": "office-ui-fabric-react",
"email": "kchau@microsoft.com"
}
14 changes: 7 additions & 7 deletions packages/office-ui-fabric-react/config/pre-copy.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"copyTo": {
"dist": [
"index.html"
"./index.html"
],
"dist/sass": [
"node_modules/office-ui-fabric-core/dist/sass/**/*",
"src/common/_highContrast.scss",
"src/common/_i18n.scss",
"src/common/_semanticSlots.scss",
"src/common/_themeOverrides.scss"
"office-ui-fabric-core/dist/sass/**/*",
"./src/common/_highContrast.scss",
"./src/common/_i18n.scss",
"./src/common/_semanticSlots.scss",
"./src/common/_themeOverrides.scss"
],
"dist/css": [
"node_modules/office-ui-fabric-core/dist/css/**/*"
"office-ui-fabric-core/dist/css/**/*"
]
}
}
1 change: 1 addition & 0 deletions scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"postcss-modules": "^0.8.0",
"raf": "^3.4.0",
"raw-loader": "^0.5.1",
"resolve": "^1.7.1",
"sass-loader": "^6.0.6",
"source-map-loader": "^0.2.1",
"style-loader": "^0.19.0",
Expand Down
4 changes: 4 additions & 0 deletions scripts/require-resolve-cwd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = function (request) {
const resolve = require('resolve');
return resolve.sync(request, { basedir: process.cwd() });
}
35 changes: 33 additions & 2 deletions scripts/tasks/copy.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,41 @@
const path = require('path');

function expandSourcePath(pattern) {
const requireResolveCwd = require('../require-resolve-cwd');

if (!pattern) {
return null;
}

// just returns the relative paths
if (pattern.startsWith('.')) {
return pattern;
}

// tries to resolve the packages, handling scoped packages
const splitPattern = pattern.split('/');
const packageName = pattern[0] == '@' ? `${splitPattern[0]}/${splitPattern[1]}` : splitPattern[0];

try {
const resolvedPackageJson = requireResolveCwd(`${packageName}/package.json`);

if (!resolvedPackageJson) {
// returns pattern if the packageName didn't contain a package.json (not really a package)
return pattern;
}

return pattern.replace(packageName, path.dirname(resolvedPackageJson));
} catch (e) {
console.error(e);
}
}

module.exports = function (options) {
const { logStartTask, logEndTask } = require('../logging');
const path = require('path');
const fs = require('fs');

configPath = path.resolve(process.cwd(), 'config/pre-copy.json');
let configPath = path.resolve(process.cwd(), 'config/pre-copy.json');

if (!fs.existsSync(configPath)) {
return;
Expand All @@ -18,7 +49,7 @@ module.exports = function (options) {
const sources = config.copyTo[destination];

for (let source of sources) {
source = path.resolve(process.cwd(), source);
source = expandSourcePath(source);
destination = path.resolve(process.cwd(), destination);
startCopy(source, destination);
}
Expand Down
5 changes: 3 additions & 2 deletions scripts/tasks/jest-resources.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const path = require('path');
const merge = require('./merge');
const resolve = require('resolve');

const styleMockPath =
module.exports = {
Expand All @@ -12,13 +13,13 @@ const styleMockPath =
createConfig: (customConfig) => merge(
{
moduleNameMapper: {
'ts-jest': path.resolve(__dirname, '../node_modules/ts-jest'),
'ts-jest': resolve.sync('ts-jest'),
'\\.(scss)$': path.resolve(__dirname, 'jest-style-mock.js'),
'KeyCodes': path.resolve(__dirname, 'jest-mock.js')
},

'transform': {
'.(ts|tsx)': path.resolve(__dirname, '../node_modules/ts-jest/preprocessor.js')
'.(ts|tsx)': resolve.sync('ts-jest/preprocessor.js')
},

'reporters': [
Expand Down
4 changes: 2 additions & 2 deletions scripts/tasks/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ module.exports = function (options) {
const fs = require('fs');
const execSync = require('../exec-sync');
const findConfig = require('../find-config');

const jestConfigPath = findConfig('jest.config.js');
const resolve = require('resolve');

if (fs.existsSync(jestConfigPath)) {
const jestPath = path.resolve(__dirname, '../node_modules/jest/bin/jest');
const jestPath = resolve.sync('jest/bin/jest');
const customArgs = options && options.argv ? options.argv.slice(3).join(' ') : '';

const args = [
Expand Down
14 changes: 13 additions & 1 deletion scripts/tasks/sass.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = function (options) {
const glob = require('glob');
const path = require('path');
const requireResolveCwd = require('../require-resolve-cwd');

const _fileNameToClassMap = {};

Expand Down Expand Up @@ -86,11 +87,22 @@ module.exports = function (options) {
return source.join('\n');
}

function requireResolvePackageUrl(packageUrl) {
const fullName = packageUrl + (packageUrl.endsWith('.scss') ? '' : '.scss');

try {
return requireResolveCwd(fullName);
} catch (e) {
// try again with a private reference
return requireResolveCwd(path.join(path.dirname(fullName), `_${path.basename(fullName)}`));
}
}

function patchSassUrl(url, prev, done) {
let newUrl = url;

if (url[0] === '~') {
newUrl = path.resolve(process.cwd(), 'node_modules', url.substr(1));
newUrl = requireResolvePackageUrl(url.substr(1));
}
else if (url === 'stdin') {
newUrl = '';
Expand Down
3 changes: 2 additions & 1 deletion scripts/tasks/ts.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module.exports = function (options) {
const path = require('path');
const execSync = require('../exec-sync');
const typescriptPath = 'node ' + path.resolve(__dirname, '../node_modules/typescript/lib/tsc');
const resolve = require('resolve');
const typescriptPath = 'node ' + resolve.sync('typescript/lib/tsc');
const libPath = path.resolve(process.cwd(), 'lib');
const srcPath = path.resolve(process.cwd(), 'src');
const extraParams = '--pretty' + (options.isProduction ? ` --inlineSources --sourceRoot ${path.relative(libPath, srcPath)}` : '');
Expand Down
5 changes: 3 additions & 2 deletions scripts/tasks/tslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ module.exports = function (options) {
const execSync = require('../exec-sync');
const path = require('path');
const fs = require('fs');
const msCustomRulesMain = require.resolve('tslint-microsoft-contrib');
const resolve = require('resolve');
const msCustomRulesMain = resolve.sync('tslint-microsoft-contrib');
const rulesPath = path.dirname(msCustomRulesMain);
const projectPath = path.resolve(process.cwd(), 'tsconfig.json');
const sourcePath = path.resolve(process.cwd(), 'src/**/*.ts*');
const tslintPath = 'node ' + path.resolve(__dirname, '../node_modules/tslint/lib/tslint-cli');
const tslintPath = 'node ' + resolve.sync('tslint/lib/tslint-cli');

execSync(`${tslintPath} --project ${projectPath} -t stylish -r ${rulesPath}`);
};
4 changes: 0 additions & 4 deletions scripts/tasks/webpack-resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,6 @@ module.exports = {

plugins: [
new WebpackNotifierPlugin(),
new webpack.WatchIgnorePlugin([
/\.js$/,
/\.d\.ts$/
]),
new ForkTsCheckerWebpackPlugin()
]
},
Expand Down