Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Vittly committed Feb 4, 2018
1 parent 426b734 commit d92ae2d
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ new WebpackBemPlugin(options: object)
## Known issues

* Small tests
* [Small tests](https://github.com/bem/webpack-bem-plugin/issues/3)
* Not picking changes in `bemrc` in watch-mode
* Working only for [nested](https://en.bem.info/methodology/filestructure/#nested) fs-scheme ([flat](https://en.bem.info/methodology/filestructure/#flat) is not supported)
* No **i18n** support
Expand Down
12 changes: 9 additions & 3 deletions src/BemPluginConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,29 @@ class BemPluginConfig {
}

/**
* Overwriting configs:
* Overriding configs:
* a. main config for testing purpose
* b. libraries configs (like bem-react-components) for many reasons
* example: https://github.com/bem/bem-sdk/issues/261
* b. libraries configs:
* - if wanted library has no its bemrc and adding it (via PR) is not simple
* - if wanted library or bem/sdk-config itself have unresolved issues but we can't wait
* example: https://github.com/bem/bem-sdk/issues/261
*/
__prepareRc(bemConfig, libs, self) {
if (!libs && !self) return;

const configsMap = {};
const oldSync = rc.sync;

// overriding bem/sdk-config internal mechanism of reading config .bemrc file
// overriding only sync-method because BemPluginConfig uses sync-api only
rc.sync = function(options) {
return configsMap[options.cwd] || oldSync(options);
};

// overriding main config
self && (configsMap[bemConfig._options.cwd] = [self]);

// overriding libraries configs
libs && Object.keys(libs).forEach(libName => {
configsMap[bemConfig.librarySync(libName)._options.cwd] = [libs[libName]];
});
Expand Down
7 changes: 4 additions & 3 deletions src/BemRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const namingConvention = require('./helpers/namingConvention');
const entityFromPath = require('./helpers/entityFromPath');

function completeRequest(request, ctx) {
// TODO: move to @bem/sdk.import-notation
// TODO: move to @bem/sdk.import-notation in https://github.com/bem/bem-sdk/issues/275
// TODO: make request string independent from import-notation parts order
if (/^b:/.test(request)) {
return request;
Expand All @@ -26,11 +26,12 @@ function completeRequest(request, ctx) {
*/
class BemRequest {
constructor(request, filePath, levels, setIndex) {
// TODO: replace it after https://github.com/bem/bem-sdk/issues/277
const requestNaming = namingConvention.getFromLevelsByPath(levels, filePath);

// TODO: replace it after https://github.com/bem/bem-sdk/issues/276
const ctx = entityFromPath(filePath, requestNaming);

// TODO: remove duplicates from array in @bem/sdk.import-notation
// https://github.com/bem/bem-sdk/issues/263
this.entities = bemParse(request, ctx);

this.ident = `bem-${completeRequest(request, ctx)}-${setIndex}`;
Expand Down
1 change: 0 additions & 1 deletion src/helpers/importedFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,5 @@ module.exports = (entities, levels, { techs, techMap }) => {
});
});

// FIXME: does it have right order ?
return bemDeps;
};
1 change: 0 additions & 1 deletion test/e2e/project/src/lib-with-rc/.bemrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module.exports = {
levels: [{ layer: 'desktop' }],
// TODO: remove sets after https://github.com/bem/bem-sdk/issues/262
sets: {
desktop: 'desktop'
}
Expand Down
1 change: 0 additions & 1 deletion test/e2e/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ describe('e2e', () => {
const libs = {
'lib-without-rc': {
levels: [{ layer: 'desktop' }],
// TODO: remove sets after https://github.com/bem/bem-sdk/issues/262
sets: {
desktop: 'desktop'
}
Expand Down

0 comments on commit d92ae2d

Please sign in to comment.