@htmlplus/element 0.7.5 → 0.7.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.
|
@@ -168,7 +168,7 @@ export const customElement = (options) => {
|
|
|
168
168
|
const template = t.templateLiteral(quasis, expressions);
|
|
169
169
|
// TODO
|
|
170
170
|
// if (!expressions.length) return template;
|
|
171
|
-
const { local } = addDependency(path, CONSTANTS.UTILS_PATH, CONSTANTS.UTILS_HTML_LOCAL, CONSTANTS.UTILS_HTML_IMPORTED);
|
|
171
|
+
const { local } = addDependency(path, CONSTANTS.UTILS_PATH, CONSTANTS.UTILS_HTML_LOCAL, CONSTANTS.UTILS_HTML_IMPORTED, true);
|
|
172
172
|
return t.taggedTemplateExpression(t.identifier(local), template);
|
|
173
173
|
};
|
|
174
174
|
path.replaceWith(transform(render(path.node)));
|
|
@@ -30,7 +30,7 @@ export const style = (options) => {
|
|
|
30
30
|
}
|
|
31
31
|
if (!context.stylePath)
|
|
32
32
|
return;
|
|
33
|
-
const { local } = addDependency(context.fileAST, context.stylePath, CONSTANTS.STYLE_IMPORTED);
|
|
33
|
+
const { local } = addDependency(context.fileAST, context.stylePath, CONSTANTS.STYLE_IMPORTED, undefined, true);
|
|
34
34
|
// TODO: remove 'local!'
|
|
35
35
|
const property = t.classProperty(t.identifier(CONSTANTS.STATIC_STYLES), t.identifier(local), undefined, null, undefined, true);
|
|
36
36
|
t.addComment(property, 'leading', CONSTANTS.COMMENT_AUTO_ADDED_PROPERTY, true);
|
|
@@ -3,7 +3,5 @@ interface AddDependencyReturns {
|
|
|
3
3
|
local?: string;
|
|
4
4
|
node: ImportDeclaration;
|
|
5
5
|
}
|
|
6
|
-
export declare function addDependency(path: File | any, source: string): AddDependencyReturns;
|
|
7
|
-
export declare function addDependency(path: File | any, source: string, local: string): AddDependencyReturns;
|
|
8
|
-
export declare function addDependency(path: File | any, source: string, local: string, imported: string): AddDependencyReturns;
|
|
6
|
+
export declare function addDependency(path: File | any, source: string, local?: string, imported?: string, comment?: boolean): AddDependencyReturns;
|
|
9
7
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import t from '@babel/types';
|
|
2
2
|
import * as CONSTANTS from '../../constants/index.js';
|
|
3
3
|
import { visitor } from './visitor.js';
|
|
4
|
-
export function addDependency(path, source, local, imported) {
|
|
4
|
+
export function addDependency(path, source, local, imported, comment) {
|
|
5
5
|
const isDefault = local && !imported;
|
|
6
6
|
const isImport = local && imported;
|
|
7
7
|
const isNormal = !local && !imported;
|
|
@@ -54,7 +54,9 @@ export function addDependency(path, source, local, imported) {
|
|
|
54
54
|
// TODO
|
|
55
55
|
(file.program || file).body.unshift(declaration);
|
|
56
56
|
// TODO
|
|
57
|
-
|
|
57
|
+
if (comment) {
|
|
58
|
+
t.addComment(declaration, 'leading', CONSTANTS.COMMENT_AUTO_ADDED_DEPENDENCY, true);
|
|
59
|
+
}
|
|
58
60
|
}
|
|
59
61
|
return {
|
|
60
62
|
local,
|