leanweb 1.0.9 → 1.1.0
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 +2 -4
- package/commands/build.js +39 -34
- package/commands/dist.js +1 -1
- package/commands/generate.js +1 -1
- package/commands/utils.js +1 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -476,9 +476,7 @@ Assuming npm module `lodash-es` is installed, you could use any of the
|
|
|
476
476
|
following `import` statements for your web component class:
|
|
477
477
|
|
|
478
478
|
```javascript
|
|
479
|
-
import
|
|
480
|
-
import get from "lodash-es/get.js"; // find from node_modules
|
|
481
|
-
import * as _ from "lodash-es"; // find from node_modules
|
|
479
|
+
import get from "/node_modules/lodash-es/get.js"; // find from node_modules
|
|
482
480
|
```
|
|
483
481
|
|
|
484
482
|
Importing a JSON file:
|
|
@@ -490,7 +488,7 @@ import someJSON from "./some.json";
|
|
|
490
488
|
Importing CSS/SCSS:
|
|
491
489
|
|
|
492
490
|
```javascript
|
|
493
|
-
import agate from "highlight.js/scss/agate.scss";
|
|
491
|
+
import agate from "/node_modules/highlight.js/scss/agate.scss";
|
|
494
492
|
|
|
495
493
|
// customElements.define('demo-root',
|
|
496
494
|
// class extends LWElement { // LWElement extends HTMLElement
|
package/commands/build.js
CHANGED
|
@@ -11,39 +11,44 @@
|
|
|
11
11
|
env = args[2];
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
const replaceNodeModulesImport = (str, filePath) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const walkDirSync = (dir, accept = null, callback) => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const preprocessJsImport = filePath => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
14
|
+
// const replaceNodeModulesImport = (str, filePath) => {
|
|
15
|
+
// // match import not starting with dot or slash
|
|
16
|
+
// return str.replace(/^([^\S\r\n]*(?:importScripts|import).+?['"])((?!\.|\/|http\:|https\:).*?)(['"].*)$/gm, (m, a, b, c) => {
|
|
17
|
+
// if (b.startsWith(`~`)) {
|
|
18
|
+
// // ~/package.json
|
|
19
|
+
// return a + path.normalize(`${process.cwd()}/` + b.substring(1)) + c;
|
|
20
|
+
// } else if (b.indexOf('/') > -1) {
|
|
21
|
+
// // lodash-es/get.js
|
|
22
|
+
// return a + path.normalize(`${process.cwd()}/node_modules/` + b) + c;
|
|
23
|
+
// } else {
|
|
24
|
+
// const nodeModulePath = `${process.cwd()}/node_modules/` + b + '/package.json';
|
|
25
|
+
// const package = require(nodeModulePath);
|
|
26
|
+
// // lodash-es
|
|
27
|
+
// return a + path.normalize(`${process.cwd()}/node_modules/` + b + '/' + package.main) + c;
|
|
28
|
+
// }
|
|
29
|
+
// });
|
|
30
|
+
// };
|
|
31
|
+
|
|
32
|
+
// const walkDirSync = (dir, accept = null, callback) => {
|
|
33
|
+
// fs.readdirSync(dir).forEach(f => {
|
|
34
|
+
// let dirPath = path.join(dir, f);
|
|
35
|
+
// const isDirectory = fs.statSync(dirPath).isDirectory() && (!accept || (typeof accept === 'function' && accept(dirPath, f)));
|
|
36
|
+
// isDirectory ? walkDirSync(dirPath, accept, callback) : callback(path.join(dirPath));
|
|
37
|
+
// });
|
|
38
|
+
// };
|
|
39
|
+
|
|
40
|
+
// const preprocessJsImport = filePath => {
|
|
41
|
+
// if (
|
|
42
|
+
// filePath.toLowerCase().endsWith('.js') &&
|
|
43
|
+
// !filePath.toLowerCase().endsWith('/ast.js') &&
|
|
44
|
+
// !filePath.startsWith(`${utils.dirs.build}/lib/`) &&
|
|
45
|
+
// !filePath.startsWith(`${utils.dirs.build}/resources/`)
|
|
46
|
+
// ) {
|
|
47
|
+
// let jsFileString = fs.readFileSync(filePath, 'utf8');
|
|
48
|
+
// jsFileString = replaceNodeModulesImport(jsFileString, filePath);
|
|
49
|
+
// fs.writeFileSync(filePath, jsFileString);
|
|
50
|
+
// }
|
|
51
|
+
// };
|
|
47
52
|
|
|
48
53
|
const buildDirFilter = dirPath => {
|
|
49
54
|
if (dirPath.startsWith(`${utils.dirs.build}/lib/`)) {
|
|
@@ -96,7 +101,7 @@
|
|
|
96
101
|
};
|
|
97
102
|
|
|
98
103
|
const buildJS = () => {
|
|
99
|
-
walkDirSync(buildDir, buildDirFilter, preprocessJsImport);
|
|
104
|
+
// walkDirSync(buildDir, buildDirFilter, preprocessJsImport);
|
|
100
105
|
|
|
101
106
|
const jsString = project.components.reduce((acc, cur) => {
|
|
102
107
|
const cmpName = utils.getComponentName(cur);
|
package/commands/dist.js
CHANGED
|
@@ -54,7 +54,7 @@ if (args.length >= 3) {
|
|
|
54
54
|
fs.writeFileSync(`./${utils.dirs.dist}/${project.name}.css`, minifiedAppCss.styles);
|
|
55
55
|
|
|
56
56
|
fse.copySync(`./${utils.dirs.build}/favicon.svg`, `./${utils.dirs.dist}/favicon.svg`);
|
|
57
|
-
project.resources
|
|
57
|
+
project.resources?.forEach(resource => {
|
|
58
58
|
fse.copySync(`./${utils.dirs.build}/${resource}`, `./${utils.dirs.dist}/${resource}`, { dereference: true });
|
|
59
59
|
});
|
|
60
60
|
});
|
package/commands/generate.js
CHANGED
package/commands/utils.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "leanweb",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Builds framework agnostic web components.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"leanweb": "leanweb.js",
|
|
@@ -20,24 +20,24 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@babel/core": "^7.16.7",
|
|
23
|
-
"@babel/parser": "^7.16.
|
|
24
|
-
"@babel/plugin-transform-runtime": "^7.16.
|
|
25
|
-
"@babel/preset-env": "^7.16.
|
|
23
|
+
"@babel/parser": "^7.16.8",
|
|
24
|
+
"@babel/plugin-transform-runtime": "^7.16.8",
|
|
25
|
+
"@babel/preset-env": "^7.16.8",
|
|
26
26
|
"babel-loader": "^8.2.3",
|
|
27
27
|
"clean-css": "^5.2.2",
|
|
28
28
|
"css-loader": "^6.5.1",
|
|
29
29
|
"fs-extra": "^10.0.0",
|
|
30
30
|
"globby": "^11.0.4",
|
|
31
31
|
"html-minifier": "^4.0.0",
|
|
32
|
-
"isomorphic-git": "^1.10.
|
|
32
|
+
"isomorphic-git": "^1.10.4",
|
|
33
33
|
"json5-loader": "^4.0.1",
|
|
34
34
|
"node-watch": "^0.7.2",
|
|
35
35
|
"parse5": "^6.0.1",
|
|
36
36
|
"raw-loader": "^4.0.2",
|
|
37
|
-
"sass": "^1.
|
|
37
|
+
"sass": "^1.48.0",
|
|
38
38
|
"sass-loader": "^12.4.0",
|
|
39
39
|
"semver": "^7.3.5",
|
|
40
|
-
"webpack": "^5.
|
|
41
|
-
"webpack-dev-server": "^4.7.
|
|
40
|
+
"webpack": "^5.66.0",
|
|
41
|
+
"webpack-dev-server": "^4.7.3"
|
|
42
42
|
}
|
|
43
43
|
}
|