-
Notifications
You must be signed in to change notification settings - Fork 48
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
Module require resolving refactor #493
Conversation
848b8c0
to
a04ff1f
Compare
lib/compiler.js
Outdated
var commonPath = deps.commonJS[dep]; | ||
return '_libs["' + dep + '"] = ' + | ||
'glob && typeof glob["' + dep + '"] ' + | ||
'!== "undefined" ? ' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like no need to do it (try to use global) here - it will get to us anyway on line 222
@dustyo-O linters are red |
a04ff1f
to
f2f24e8
Compare
f2f24e8
to
79cf722
Compare
fixed linters now TODO: check that tests will fail on corrupted data (checks are checking) |
lib/compiler.js
Outdated
deps.ymVarsString = deps.ymVars.map(function(item) { | ||
return item + ':' + item; | ||
}).join(''); | ||
deps.ymVars = ',' + deps.ymLibs.map(function (item) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we make 3 maps here, can do 1 for instead, could be faster. what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dustyo-O generate()
is not runtime operation. No matter how it fast or slow we use it to generate bundles for browser.
test/requires-test.js
Outdated
var chaiAsPromised = require('chai-as-promised'); | ||
chai.use(chaiAsPromised); | ||
|
||
describe('Require modules', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needed to move back tests to test/api-generate-test.js
to minimize diff.
test/requires-test.js
Outdated
|
||
vm.runInNewContext(code + EOL + bundle, sandbox); | ||
|
||
var result = sandbox.exports.bemhtml.compile(function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code style: notice that function() {
in other files in the repo doesn’t have space before ()
brackets.
lib/compiler.js
Outdated
}).join(''); | ||
deps.ymVars = ',' + deps.ymLibs.map(function (item) { | ||
return item; | ||
}).join(','); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What?
deps.ymLibs.map(function(item) { return item; }).join(',');
map
is useless here.
lib/compiler.js
Outdated
|
||
'modules.define("' + exportName + '",' + | ||
JSON.stringify(deps.ymLibs) + ',' + | ||
'function(provide' + deps.ymVars + ') { ' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let’s place deps.ymVars
inline?
'provide, ' + deps. … .join(', ')
lib/compiler.js
Outdated
ymLibs: [], | ||
ymVars: '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we need both ymVars
and ymNames
?
Previuosly, I used only ymVars: []
and ymVars.join(', ')
So many variables… I’m try to reduce their number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general we need to
- minimize diff
- figure out what’s changed: describe priority of module loading before and after to determine minor or major changes.
Rollback after bem/bem-xjst#493
Rollback after bem/bem-xjst#493
JFYI: we just discussed details with @dustyo-O and decided to finish PR this evening together. |
efca840
to
535b29d
Compare
535b29d
to
4b8f5df
Compare
4b8f5df
to
3833d24
Compare
ok guys, i've sawed the whole diff into step-by-step commits. i hope, this helps - happy reading! into the f98319f i've added some alpha-version documentation, please read carefully and feel free to suggest changes. I'll add english translation before merge. |
docs/ru/3-api.md
Outdated
|
||
И также, модуль из CommonJS приоритетнее модуля в YModules. | ||
|
||
Это позволяет, например, переопределять ваши модули на статические объекты в целях тестирования в соответствующих конфигурациях. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Кажется, что эту фразу можно пропустить.
'if (typeof modules === "object") {', | ||
|
||
// re-define YM modules to require keys | ||
deps.ymNames.length !== 0 ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Можно оставить просто deps.ymNames.length
…
Several probs with require more than one module in different modular systems
Changes proposed in this pull request
Checklist