Compare commits
18 Commits
@advdomini
...
@advdomini
| Author | SHA1 | Date | |
|---|---|---|---|
|
f8d793195c
|
|||
|
a655e7b5e4
|
|||
|
fc11cdfa48
|
|||
|
650008ad76
|
|||
|
96ae522a8f
|
|||
|
9dc95dd47a
|
|||
|
bce960599a
|
|||
|
6f24952680
|
|||
|
e1756bd60f
|
|||
|
ea33198344
|
|||
|
ca88f622d1
|
|||
|
9131e220d2
|
|||
|
4012b982a6
|
|||
|
d6aec9ed14
|
|||
|
e8a3ea043f
|
|||
|
cc8d0b7ab3
|
|||
|
dfb04760f1
|
|||
|
db9022c00b
|
2
.yarn/sdks/prettier/package.json
vendored
2
.yarn/sdks/prettier/package.json
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "prettier",
|
||||
"version": "3.7.4-sdk",
|
||||
"version": "3.8.0-sdk",
|
||||
"main": "./index.cjs",
|
||||
"type": "commonjs",
|
||||
"bin": "./bin/prettier.cjs"
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
|
||||
## Публикация новых версий
|
||||
|
||||
```
|
||||
```bash
|
||||
yarn lerna publish
|
||||
```
|
||||
|
||||
## Обновление зависимостей
|
||||
|
||||
```shell
|
||||
```bash
|
||||
yarn set version stable
|
||||
|
||||
yarn install
|
||||
|
||||
@@ -9,6 +9,6 @@
|
||||
"@advdominion/eslint-config": "workspace:*",
|
||||
"eslint": "^9.39.2",
|
||||
"lerna": "^9.0.3",
|
||||
"prettier": "^3.7.4"
|
||||
"prettier": "^3.8.0"
|
||||
}
|
||||
}
|
||||
|
||||
70
packages/babel-plugin-nunjucks/README.md
Normal file
70
packages/babel-plugin-nunjucks/README.md
Normal file
@@ -0,0 +1,70 @@
|
||||
# babel-plugin-nunjucks
|
||||
|
||||
Плагин для [babel-loader](https://github.com/babel/babel-loader), позволяющий использовать шаблонизатор [Nunjucks](https://mozilla.github.io/nunjucks/) внутри JS-файлов.
|
||||
|
||||
## Установка
|
||||
|
||||
```bash
|
||||
yarn add -D @advdominion/babel-plugin-nunjucks
|
||||
```
|
||||
|
||||
## Использование
|
||||
|
||||
Используются [Tagged templates](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates) с тегом `njk`:
|
||||
|
||||
```js
|
||||
njk`
|
||||
{% from "./item.njk" import item as item %}
|
||||
|
||||
<div class="items">
|
||||
{% for n in range(0, 10) %}
|
||||
{{item()}}
|
||||
{% endfor %}
|
||||
</div>
|
||||
`;
|
||||
```
|
||||
|
||||
Пример конфигурации Webpack:
|
||||
|
||||
```js
|
||||
[
|
||||
{
|
||||
test: /\.js$/,
|
||||
exclude: [/mocks\.js$/],
|
||||
use: [
|
||||
{
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
cacheDirectory: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /mocks\.js$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
compact: false,
|
||||
plugins: [
|
||||
[
|
||||
'@advdominion/babel-plugin-nunjucks',
|
||||
{
|
||||
templatesFolder: 'src/templates/',
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
## Опции
|
||||
|
||||
- `templatesFolder` - строка, обязательный параметр. Путь до папки с файлами шаблонов
|
||||
- `globals` - массив, необязательный параметр. Глобальные переменные для Nunjucks (например, `[{name: "message", value: "Hello, world!"}]`)
|
||||
|
||||
**Важно:** Параметр `cacheDirectory` в опциях babel-loader должен быть отключён.
|
||||
25
packages/babel-plugin-nunjucks/index.js
Normal file
25
packages/babel-plugin-nunjucks/index.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import nunjucks from 'nunjucks';
|
||||
|
||||
const babelPluginNunjucks = ({types: t}) => {
|
||||
return {
|
||||
pre(state) {
|
||||
const options = state.opts.plugins[0].options;
|
||||
this.njkenv = new nunjucks.Environment(new nunjucks.FileSystemLoader(options.templatesFolder));
|
||||
if (options.globals) {
|
||||
for (const {name, value} of options.globals) {
|
||||
this.njkenv.addGlobal(name, value);
|
||||
}
|
||||
}
|
||||
},
|
||||
visitor: {
|
||||
TaggedTemplateExpression(path) {
|
||||
if (path.get('tag').isIdentifier({name: 'njk'})) {
|
||||
const render = this.njkenv.renderString(path.node.quasi.quasis[0].value.raw);
|
||||
path.replaceWith(t.stringLiteral(render));
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default babelPluginNunjucks;
|
||||
18
packages/babel-plugin-nunjucks/package.json
Normal file
18
packages/babel-plugin-nunjucks/package.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "@advdominion/babel-plugin-nunjucks",
|
||||
"version": "3.1.0",
|
||||
"type": "module",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://gitea.optiweb.ru/public/frontend.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.0.0",
|
||||
"nunjucks": "^3.0.0"
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@advdominion/eslint-config",
|
||||
"version": "1.1.1",
|
||||
"version": "1.1.3",
|
||||
"type": "module",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
@@ -16,8 +16,8 @@
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-simple-import-sort": "^12.1.1",
|
||||
"eslint-plugin-unicorn": "^62.0.0",
|
||||
"eslint-plugin-vue": "^10.6.2",
|
||||
"globals": "^16.5.0",
|
||||
"eslint-plugin-vue": "^10.7.0",
|
||||
"globals": "^17.0.0",
|
||||
"vue-eslint-parser": "^10.2.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
@@ -1,11 +0,0 @@
|
||||
# is
|
||||
|
||||
Check variable type
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import { is } from '@advdominion/is';
|
||||
|
||||
console.log(is('Hello, world!', 'String'));
|
||||
```
|
||||
@@ -1,3 +0,0 @@
|
||||
export const is = (obj, type) => {
|
||||
return Object.prototype.toString.call(obj).slice(8, -1) === type && obj !== undefined && obj !== null;
|
||||
};
|
||||
53
packages/lightningcss-loader/README.md
Normal file
53
packages/lightningcss-loader/README.md
Normal file
@@ -0,0 +1,53 @@
|
||||
# lightningcss-loader
|
||||
|
||||
[Lightning CSS](https://lightningcss.dev) loader for [Webpack](https://webpack.js.org)
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import { transform } from 'lightningcss';
|
||||
|
||||
return {
|
||||
...,
|
||||
rules: [
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: [
|
||||
{
|
||||
loader: '@advdominion/lightningcss-loader',
|
||||
options: {
|
||||
implementation: transform,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
```
|
||||
|
||||
### Passing options to Lightning CSS
|
||||
|
||||
```js
|
||||
import { transform } from 'lightningcss';
|
||||
|
||||
return {
|
||||
...,
|
||||
rules: [
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: [
|
||||
{
|
||||
loader: '@advdominion/lightningcss-loader',
|
||||
options: {
|
||||
implementation: transform,
|
||||
drafts: {
|
||||
customMedia: true,
|
||||
},
|
||||
minify: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
```
|
||||
22
packages/lightningcss-loader/index.js
Normal file
22
packages/lightningcss-loader/index.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const lightningcssLoader = function (source, sourceMap) {
|
||||
const { implementation, ...options } = this.getOptions();
|
||||
const callback = this.async();
|
||||
|
||||
if (typeof implementation !== 'function') {
|
||||
throw new TypeError(
|
||||
`[lightningcss-loader]: The "implementation" option is required and must provide "transform" function of the LightningCSS`,
|
||||
);
|
||||
}
|
||||
|
||||
const { code, map } = implementation({
|
||||
filename: this.resourcePath,
|
||||
code: Buffer.from(source),
|
||||
sourceMap: this.sourceMap,
|
||||
inputSourceMap: this.sourceMap && sourceMap ? JSON.stringify(sourceMap) : undefined,
|
||||
...options,
|
||||
});
|
||||
|
||||
callback(undefined, code.toString(), map && JSON.parse(map.toString()));
|
||||
};
|
||||
|
||||
export default lightningcssLoader;
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "@advdominion/is",
|
||||
"name": "@advdominion/lightningcss-loader",
|
||||
"version": "1.0.2",
|
||||
"type": "module",
|
||||
"main": "index.js",
|
||||
@@ -2,4 +2,12 @@ export default {
|
||||
printWidth: 120,
|
||||
singleQuote: true,
|
||||
quoteProps: 'consistent',
|
||||
overrides: [
|
||||
{
|
||||
files: 'packages/*/package.json',
|
||||
options: {
|
||||
tabWidth: 2,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
48
yarn.lock
48
yarn.lock
@@ -5,16 +5,25 @@ __metadata:
|
||||
version: 8
|
||||
cacheKey: 10c0
|
||||
|
||||
"@advdominion/eslint-config@workspace:*, @advdominion/eslint-config@workspace:packages/config-eslint":
|
||||
"@advdominion/babel-plugin-nunjucks@workspace:packages/babel-plugin-nunjucks":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@advdominion/eslint-config@workspace:packages/config-eslint"
|
||||
resolution: "@advdominion/babel-plugin-nunjucks@workspace:packages/babel-plugin-nunjucks"
|
||||
peerDependencies:
|
||||
"@babel/core": ^7.0.0
|
||||
nunjucks: ^3.0.0
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@advdominion/eslint-config@workspace:*, @advdominion/eslint-config@workspace:packages/eslint-config":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@advdominion/eslint-config@workspace:packages/eslint-config"
|
||||
dependencies:
|
||||
"@eslint/js": "npm:^9.39.2"
|
||||
eslint-config-prettier: "npm:^10.1.8"
|
||||
eslint-plugin-simple-import-sort: "npm:^12.1.1"
|
||||
eslint-plugin-unicorn: "npm:^62.0.0"
|
||||
eslint-plugin-vue: "npm:^10.6.2"
|
||||
globals: "npm:^16.5.0"
|
||||
eslint-plugin-vue: "npm:^10.7.0"
|
||||
globals: "npm:^17.0.0"
|
||||
vue-eslint-parser: "npm:^10.2.0"
|
||||
peerDependencies:
|
||||
eslint: ^9.39.0
|
||||
@@ -27,9 +36,9 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@advdominion/is@workspace:packages/is":
|
||||
"@advdominion/lightningcss-loader@workspace:packages/lightningcss-loader":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@advdominion/is@workspace:packages/is"
|
||||
resolution: "@advdominion/lightningcss-loader@workspace:packages/lightningcss-loader"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
@@ -2444,9 +2453,9 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"eslint-plugin-vue@npm:^10.6.2":
|
||||
version: 10.6.2
|
||||
resolution: "eslint-plugin-vue@npm:10.6.2"
|
||||
"eslint-plugin-vue@npm:^10.7.0":
|
||||
version: 10.7.0
|
||||
resolution: "eslint-plugin-vue@npm:10.7.0"
|
||||
dependencies:
|
||||
"@eslint-community/eslint-utils": "npm:^4.4.0"
|
||||
natural-compare: "npm:^1.4.0"
|
||||
@@ -2464,7 +2473,7 @@ __metadata:
|
||||
optional: true
|
||||
"@typescript-eslint/parser":
|
||||
optional: true
|
||||
checksum: 10c0/3d3705e6906f6a55529ba99d1ab4e952f2178e109bdab21cc486ef8fee6cd4d4434a4bcb9e77b4d4a8d511dbb2f99deeaeaf22d2847ab3c2ab3d130358a4f8a0
|
||||
checksum: 10c0/52ae339373a4fc032e1a45871050b91b7eab75903edaf1ea044032e1039acef62304ef8fc2965075c821a26adf44ee323d37e274d252b7f1b122b3520735709c
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -3053,13 +3062,20 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"globals@npm:^16.4.0, globals@npm:^16.5.0":
|
||||
"globals@npm:^16.4.0":
|
||||
version: 16.5.0
|
||||
resolution: "globals@npm:16.5.0"
|
||||
checksum: 10c0/615241dae7851c8012f5aa0223005b1ed6607713d6813de0741768bd4ddc39353117648f1a7086b4b0fa45eae733f1c0a0fe369aa4e543bb63f8de8990178ea9
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"globals@npm:^17.0.0":
|
||||
version: 17.0.0
|
||||
resolution: "globals@npm:17.0.0"
|
||||
checksum: 10c0/e3c169fdcb0fc6755707b697afb367bea483eb29992cfc0de1637382eb893146e17f8f96db6d7453e3696b478a7863ae2000e6c71cd2f4061410285106d3847a
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"gopd@npm:^1.2.0":
|
||||
version: 1.2.0
|
||||
resolution: "gopd@npm:1.2.0"
|
||||
@@ -5196,12 +5212,12 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"prettier@npm:^3.7.4":
|
||||
version: 3.7.4
|
||||
resolution: "prettier@npm:3.7.4"
|
||||
"prettier@npm:^3.8.0":
|
||||
version: 3.8.0
|
||||
resolution: "prettier@npm:3.8.0"
|
||||
bin:
|
||||
prettier: bin/prettier.cjs
|
||||
checksum: 10c0/9675d2cd08eacb1faf1d1a2dbfe24bfab6a912b059fc9defdb380a408893d88213e794a40a2700bd29b140eb3172e0b07c852853f6e22f16f3374659a1a13389
|
||||
checksum: 10c0/8926e9c9941a293b76c2d799089d038e9f6d84fb37702fc370bedd03b3c70d7fcf507e2e3c4f151f222d81820a3b74cac5e692c955cfafe34dd0d02616ce8327
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -5533,7 +5549,7 @@ __metadata:
|
||||
"@advdominion/eslint-config": "workspace:*"
|
||||
eslint: "npm:^9.39.2"
|
||||
lerna: "npm:^9.0.3"
|
||||
prettier: "npm:^3.7.4"
|
||||
prettier: "npm:^3.8.0"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
|
||||
Reference in New Issue
Block a user