|
1 | 1 | # Migration |
2 | 2 |
|
| 3 | +## 5.0.0 |
| 4 | + |
| 5 | +### ym → ES modules |
| 6 | + |
| 7 | +The `ym` module system (`modules.define`/`modules.require`) has been replaced with native ES modules. |
| 8 | + |
| 9 | +Before: |
| 10 | + |
| 11 | +```js |
| 12 | +modules.define('my-block', ['i-bem-dom', 'events'], function(provide, bemDom, events) { |
| 13 | + |
| 14 | +provide(bemDom.declBlock(this.name, { /* ... */ })); |
| 15 | + |
| 16 | +}); |
| 17 | +``` |
| 18 | + |
| 19 | +After: |
| 20 | + |
| 21 | +```js |
| 22 | +import bemDom from 'bem:i-bem-dom'; |
| 23 | +import events from 'bem:events'; |
| 24 | + |
| 25 | +export default bemDom.declBlock('my-block', { /* ... */ }); |
| 26 | +``` |
| 27 | + |
| 28 | +All `bem:*` imports are resolved at build time by `vite-plugin-bem-levels` to the actual file paths, respecting platform-specific level priorities. |
| 29 | + |
| 30 | +### Module redefinitions |
| 31 | + |
| 32 | +Module redefinitions that previously used `modules.define` with a callback receiving the previous module value are now handled via barrel files generated by the Vite plugin. |
| 33 | + |
| 34 | +Before (ym redefinition): |
| 35 | + |
| 36 | +```js |
| 37 | +modules.define('jquery', function(provide, $) { |
| 38 | + $.event.special.pointerclick = { /* ... */ }; |
| 39 | + provide($); |
| 40 | +}); |
| 41 | +``` |
| 42 | + |
| 43 | +After (side-effect import in barrel): |
| 44 | + |
| 45 | +```js |
| 46 | +// The barrel file auto-generated by vite-plugin-bem-levels: |
| 47 | +import $ from '../../common.blocks/jquery/jquery.js'; |
| 48 | +import '../../common.blocks/jquery/__event/_type/jquery__event_type_pointerclick.js'; |
| 49 | +export default $; |
| 50 | +``` |
| 51 | + |
| 52 | +### jQuery 3 → 4 |
| 53 | + |
| 54 | +The `jquery` peer dependency is now `^4.0.0`. |
| 55 | + |
| 56 | +Key breaking changes in jQuery 4: |
| 57 | +- `$.unique()` has been removed. Use `$.uniqueSort()`. |
| 58 | +- Several deprecated methods have been removed. See [jQuery 4.0 upgrade guide](https://jquery.com/upgrade-guide/4.0/). |
| 59 | + |
| 60 | +### vow → native Promise |
| 61 | + |
| 62 | +The `vow` dependency has been removed. All asynchronous code now uses native `Promise`. |
| 63 | + |
| 64 | +Before: |
| 65 | + |
| 66 | +```js |
| 67 | +var vow = require('vow'); |
| 68 | +var promise = vow.resolve(value); |
| 69 | +``` |
| 70 | + |
| 71 | +After: |
| 72 | + |
| 73 | +```js |
| 74 | +const promise = Promise.resolve(value); |
| 75 | +``` |
| 76 | + |
| 77 | +### Build system: ENB → Vite |
| 78 | + |
| 79 | +The entire ENB toolchain has been replaced with Vite. |
| 80 | + |
| 81 | +Before: |
| 82 | + |
| 83 | +```bash |
| 84 | +./node_modules/.bin/enb make |
| 85 | +``` |
| 86 | + |
| 87 | +After: |
| 88 | + |
| 89 | +```bash |
| 90 | +npm run build # both platforms |
| 91 | +npm run build:desktop # desktop only |
| 92 | +npm run build:touch # touch only |
| 93 | +``` |
| 94 | + |
| 95 | +The Vite config is in `build/vite.config.js`. The custom `vite-plugin-bem-levels` plugin in `build/plugins/` handles BEM level scanning and module resolution. |
| 96 | + |
| 97 | +### Node.js 20+ |
| 98 | + |
| 99 | +The minimum supported Node.js version is now 20 (was 8). Update your `.nvmrc` or CI configuration accordingly. |
| 100 | + |
| 101 | +### Linting: jshint/jscs → ESLint 10 |
| 102 | + |
| 103 | +Replace any custom `.jshintrc` or `.jscs.json` rules with ESLint flat config (`eslint.config.js`). |
| 104 | + |
| 105 | +### Testing |
| 106 | + |
| 107 | +- **Server-side tests**: `mocha`/`chai` have been replaced with `node:test`/`node:assert`. |
| 108 | +- **Browser tests**: `mocha-phantomjs` has been replaced with Playwright. Run with `npm run test:browser`. |
| 109 | +- **All tests**: `npm run test:all` runs both server-side and browser tests. |
| 110 | + |
| 111 | +### CI/CD: Travis → GitHub Actions |
| 112 | + |
| 113 | +Replace `.travis.yml` with `.github/workflows/ci.yml`. The new CI runs lint, test, test:browser, and build jobs. |
| 114 | + |
| 115 | +### Git hooks: git-hooks → husky |
| 116 | + |
| 117 | +Replace `.githooks/` with husky configuration. The `prepare` script in `package.json` sets up husky automatically on `npm install`. |
| 118 | + |
3 | 119 | ## 4.0.0 |
4 | 120 |
|
5 | 121 | ### Changes in the `i-bem` block |
|
0 commit comments