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('office-ui-fabric-core/package.json');
const corePackageData = require('../../../node_modules/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('office-ui-fabric-core/package.json');
const reactPackageData = require('office-ui-fabric-react/package.json');
const corePackageData = require('../../../node_modules/office-ui-fabric-core/package.json');
const reactPackageData = require('../../../node_modules/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('office-ui-fabric-core/src/data/icons.json');
const iconData = require('../../../../node_modules/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
Expand Up @@ -2,8 +2,8 @@
"changes": [
{
"packageName": "@uifabric/fabric-website",
"comment": "Use require.resolve logic in builds & watch .js files from node_modules",
"type": "patch"
"comment": "revert build change",
"type": "none"
}
],
"packageName": "@uifabric/fabric-website",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"changes": [
{
"packageName": "office-ui-fabric-react",
"comment": "Use require.resolve logic in builds & watch .js files from node_modules",
"type": "patch"
"comment": "revert build change",
"type": "none"
}
],
"packageName": "office-ui-fabric-react",
Expand Down
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": [
"office-ui-fabric-core/dist/sass/**/*",
"./src/common/_highContrast.scss",
"./src/common/_i18n.scss",
"./src/common/_semanticSlots.scss",
"./src/common/_themeOverrides.scss"
"node_modules/office-ui-fabric-core/dist/sass/**/*",
"src/common/_highContrast.scss",
"src/common/_i18n.scss",
"src/common/_semanticSlots.scss",
"src/common/_themeOverrides.scss"
],
"dist/css": [
"office-ui-fabric-core/dist/css/**/*"
"node_modules/office-ui-fabric-core/dist/css/**/*"
]
}
}
3 changes: 0 additions & 3 deletions scripts/require-resolve-cwd.js

This file was deleted.

35 changes: 2 additions & 33 deletions scripts/tasks/copy.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,10 @@
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');

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

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

for (let source of sources) {
source = expandSourcePath(source);
source = path.resolve(process.cwd(), source);
destination = path.resolve(process.cwd(), destination);
startCopy(source, destination);
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/tasks/jest-resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ const styleMockPath =
createConfig: (customConfig) => merge(
{
moduleNameMapper: {
'ts-jest': require.resolve('ts-jest'),
'ts-jest': path.resolve(__dirname, '../node_modules/ts-jest'),
'\\.(scss)$': path.resolve(__dirname, 'jest-style-mock.js'),
'KeyCodes': path.resolve(__dirname, 'jest-mock.js')
},

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

'reporters': [
Expand Down
2 changes: 1 addition & 1 deletion scripts/tasks/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = function (options) {
const jestConfigPath = findConfig('jest.config.js');

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

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

const _fileNameToClassMap = {};

Expand Down Expand Up @@ -87,22 +86,11 @@ 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 = requireResolvePackageUrl(url.substr(1));
newUrl = path.resolve(process.cwd(), 'node_modules', url.substr(1));
}
else if (url === 'stdin') {
newUrl = '';
Expand Down
2 changes: 1 addition & 1 deletion scripts/tasks/ts.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = function (options) {
const path = require('path');
const execSync = require('../exec-sync');
const typescriptPath = 'node ' + require.resolve('typescript/lib/tsc');
const typescriptPath = 'node ' + path.resolve(__dirname, '../node_modules/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
2 changes: 1 addition & 1 deletion scripts/tasks/tslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = function (options) {
const rulesPath = path.dirname(msCustomRulesMain);
const projectPath = path.resolve(process.cwd(), 'tsconfig.json');
const sourcePath = path.resolve(process.cwd(), 'src/**/*.ts*');
const tslintPath = 'node ' + require.resolve('tslint/lib/tslint-cli');
const tslintPath = 'node ' + path.resolve(__dirname, '../node_modules/tslint/lib/tslint-cli');

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

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