leanweb 1.1.2 → 1.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -3
- package/commands/build.js +7 -55
- package/commands/init.js +1 -1
- package/package.json +10 -10
- package/templates/lib/lw-element.js +1 -0
package/README.md
CHANGED
|
@@ -259,6 +259,7 @@ items = ["one", "two", "three"];
|
|
|
259
259
|
<br />
|
|
260
260
|
<button lw-on:click="resetName()">Reset Name</button>
|
|
261
261
|
```
|
|
262
|
+
|
|
262
263
|
You could bind multiple events like `lw-on:click,change=handler($event, $node)`.
|
|
263
264
|
|
|
264
265
|
```javascript
|
|
@@ -318,24 +319,26 @@ imageWidth = 400;
|
|
|
318
319
|
`demo-parent.html`
|
|
319
320
|
|
|
320
321
|
```html
|
|
321
|
-
<demo-child lw-input:userData="user"></demo-child>
|
|
322
|
+
<demo-child lw-input:parent="self" lw-input:userData="user"></demo-child>
|
|
322
323
|
```
|
|
323
324
|
|
|
324
325
|
`demo-parent.js`
|
|
325
326
|
|
|
326
327
|
```javascript
|
|
327
328
|
// ...
|
|
329
|
+
// self is defined in LWElement as `self = this`;
|
|
328
330
|
user = { firstname: "Qian", lastname: "Chen" };
|
|
329
331
|
// ...
|
|
330
332
|
```
|
|
331
333
|
|
|
332
|
-
The child is able to access the `user` object passed in with
|
|
333
|
-
directive from `inputReady()` method.
|
|
334
|
+
The child is able to access the `parent` and `user` object passed in with
|
|
335
|
+
`lw-input:` directive from `inputReady()` method.
|
|
334
336
|
`demo-child.js`
|
|
335
337
|
|
|
336
338
|
```javascript
|
|
337
339
|
// ...
|
|
338
340
|
inputReady() {
|
|
341
|
+
console.log(this.parent);
|
|
339
342
|
console.log(this.userData);
|
|
340
343
|
}
|
|
341
344
|
// ...
|
package/commands/build.js
CHANGED
|
@@ -18,52 +18,6 @@ const require = createRequire(import.meta.url);
|
|
|
18
18
|
env = args[2];
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
// const replaceNodeModulesImport = (str, filePath) => {
|
|
22
|
-
// // match import not starting with dot or slash
|
|
23
|
-
// return str.replace(/^([^\S\r\n]*(?:importScripts|import).+?['"])((?!\.|\/|http\:|https\:).*?)(['"].*)$/gm, (m, a, b, c) => {
|
|
24
|
-
// if (b.startsWith(`~`)) {
|
|
25
|
-
// // ~/package.json
|
|
26
|
-
// return a + path.normalize(`${process.cwd()}/` + b.substring(1)) + c;
|
|
27
|
-
// } else if (b.indexOf('/') > -1) {
|
|
28
|
-
// // lodash-es/get.js
|
|
29
|
-
// return a + path.normalize(`${process.cwd()}/node_modules/` + b) + c;
|
|
30
|
-
// } else {
|
|
31
|
-
// const nodeModulePath = `${process.cwd()}/node_modules/` + b + '/package.json';
|
|
32
|
-
// const package = require(nodeModulePath);
|
|
33
|
-
// // lodash-es
|
|
34
|
-
// return a + path.normalize(`${process.cwd()}/node_modules/` + b + '/' + package.main) + c;
|
|
35
|
-
// }
|
|
36
|
-
// });
|
|
37
|
-
// };
|
|
38
|
-
|
|
39
|
-
// const walkDirSync = (dir, accept = null, callback) => {
|
|
40
|
-
// fs.readdirSync(dir).forEach(f => {
|
|
41
|
-
// let dirPath = path.join(dir, f);
|
|
42
|
-
// const isDirectory = fs.statSync(dirPath).isDirectory() && (!accept || (typeof accept === 'function' && accept(dirPath, f)));
|
|
43
|
-
// isDirectory ? walkDirSync(dirPath, accept, callback) : callback(path.join(dirPath));
|
|
44
|
-
// });
|
|
45
|
-
// };
|
|
46
|
-
|
|
47
|
-
// const preprocessJsImport = filePath => {
|
|
48
|
-
// if (
|
|
49
|
-
// filePath.toLowerCase().endsWith('.js') &&
|
|
50
|
-
// !filePath.toLowerCase().endsWith('/ast.js') &&
|
|
51
|
-
// !filePath.startsWith(`${utils.dirs.build}/lib/`) &&
|
|
52
|
-
// !filePath.startsWith(`${utils.dirs.build}/resources/`)
|
|
53
|
-
// ) {
|
|
54
|
-
// let jsFileString = fs.readFileSync(filePath, 'utf8');
|
|
55
|
-
// jsFileString = replaceNodeModulesImport(jsFileString, filePath);
|
|
56
|
-
// fs.writeFileSync(filePath, jsFileString);
|
|
57
|
-
// }
|
|
58
|
-
// };
|
|
59
|
-
|
|
60
|
-
// const buildDirFilter = dirPath => {
|
|
61
|
-
// if (dirPath.startsWith(`${utils.dirs.build}/lib/`)) {
|
|
62
|
-
// return false;
|
|
63
|
-
// }
|
|
64
|
-
// return true;
|
|
65
|
-
// };
|
|
66
|
-
|
|
67
21
|
const leanwebPackageJSON = require(`${__dirname}/../package.json`);
|
|
68
22
|
|
|
69
23
|
const buildModule = (projectPath) => {
|
|
@@ -108,8 +62,6 @@ const require = createRequire(import.meta.url);
|
|
|
108
62
|
};
|
|
109
63
|
|
|
110
64
|
const buildJS = () => {
|
|
111
|
-
// walkDirSync(buildDir, buildDirFilter, preprocessJsImport);
|
|
112
|
-
|
|
113
65
|
const jsString = project.components.reduce((acc, cur) => {
|
|
114
66
|
const cmpName = utils.getComponentName(cur);
|
|
115
67
|
let importString = `import './components/${cur}/${cmpName}.js';`;
|
|
@@ -121,18 +73,18 @@ const require = createRequire(import.meta.url);
|
|
|
121
73
|
const buildHTML = () => {
|
|
122
74
|
project.components.forEach(cmp => {
|
|
123
75
|
const cmpName = utils.getComponentName(cmp);
|
|
124
|
-
const htmlFilename = `${
|
|
76
|
+
const htmlFilename = `${buildDir}/components/${cmp}/${cmpName}.html`;
|
|
125
77
|
const htmlFileExists = fs.existsSync(htmlFilename);
|
|
126
78
|
if (htmlFileExists) {
|
|
127
79
|
|
|
128
|
-
const scssFilename = `${
|
|
80
|
+
const scssFilename = `${buildDir}/components/${cmp}/${cmpName}.scss`;
|
|
129
81
|
const scssFileExists = fs.existsSync(scssFilename);
|
|
130
82
|
let cssString = '';
|
|
131
83
|
if (scssFileExists) {
|
|
132
|
-
let scssString = `@use "global-styles.scss";\n`;
|
|
84
|
+
let scssString = `@use "${buildDir}/global-styles.scss";\n`;
|
|
133
85
|
scssString += fs.readFileSync(scssFilename, 'utf8');
|
|
134
86
|
scssString += '\n[lw-false],[lw-for]{display:none !important;}\n';
|
|
135
|
-
cssString = utils.buildCSS(scssString, `${
|
|
87
|
+
cssString = utils.buildCSS(scssString, `${buildDir}/components/${cmp}`);
|
|
136
88
|
}
|
|
137
89
|
const styleString = cssString || '';
|
|
138
90
|
const htmlString = fs.readFileSync(htmlFilename, 'utf8');
|
|
@@ -144,16 +96,16 @@ const require = createRequire(import.meta.url);
|
|
|
144
96
|
fs.writeFileSync(`${buildDir}/components/${cmp}/ast.js`, `export default ${JSON.stringify(ast, null, 0)};`);
|
|
145
97
|
}
|
|
146
98
|
});
|
|
147
|
-
const htmlString = fs.readFileSync(`${
|
|
99
|
+
const htmlString = fs.readFileSync(`${buildDir}/index.html`, 'utf8');
|
|
148
100
|
fs.writeFileSync(`${buildDir}/index.html`, htmlString);
|
|
149
101
|
};
|
|
150
102
|
|
|
151
103
|
const buildSCSS = () => {
|
|
152
|
-
const projectScssFilename = `${projectPath}
|
|
104
|
+
const projectScssFilename = `${projectPath}/${utils.dirs.src}/${project.name}.scss`;
|
|
153
105
|
let projectCssString = '';
|
|
154
106
|
if (fs.existsSync(projectScssFilename)) {
|
|
155
107
|
const projectScssString = fs.readFileSync(projectScssFilename, 'utf8');
|
|
156
|
-
projectCssString += utils.buildCSS(projectScssString,
|
|
108
|
+
projectCssString += utils.buildCSS(projectScssString, buildDir);
|
|
157
109
|
}
|
|
158
110
|
fs.writeFileSync(`${buildDir}/${project.name}.css`, projectCssString);
|
|
159
111
|
};
|
package/commands/init.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "leanweb",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"description": "Builds framework agnostic web components.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"leanweb": "leanweb.js",
|
|
@@ -20,25 +20,25 @@
|
|
|
20
20
|
"author": "Qian Chen",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@babel/core": "^7.
|
|
24
|
-
"@babel/parser": "^7.
|
|
25
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
23
|
+
"@babel/core": "^7.17.0",
|
|
24
|
+
"@babel/parser": "^7.17.0",
|
|
25
|
+
"@babel/plugin-transform-runtime": "^7.17.0",
|
|
26
26
|
"@babel/preset-env": "^7.16.11",
|
|
27
27
|
"babel-loader": "^8.2.3",
|
|
28
28
|
"clean-css": "^5.2.4",
|
|
29
|
-
"css-loader": "^6.
|
|
29
|
+
"css-loader": "^6.6.0",
|
|
30
30
|
"fs-extra": "^10.0.0",
|
|
31
|
-
"globby": "^13.1.
|
|
31
|
+
"globby": "^13.1.1",
|
|
32
32
|
"html-minifier": "^4.0.0",
|
|
33
|
-
"isomorphic-git": "^1.11.
|
|
33
|
+
"isomorphic-git": "^1.11.2",
|
|
34
34
|
"json5-loader": "^4.0.1",
|
|
35
35
|
"node-watch": "^0.7.3",
|
|
36
36
|
"parse5": "^6.0.1",
|
|
37
37
|
"raw-loader": "^4.0.2",
|
|
38
|
-
"sass": "^1.49.
|
|
38
|
+
"sass": "^1.49.7",
|
|
39
39
|
"sass-loader": "^12.4.0",
|
|
40
40
|
"semver": "^7.3.5",
|
|
41
|
-
"webpack": "^5.
|
|
42
|
-
"webpack-dev-server": "^4.7.
|
|
41
|
+
"webpack": "^5.68.0",
|
|
42
|
+
"webpack-dev-server": "^4.7.4"
|
|
43
43
|
}
|
|
44
44
|
}
|