hashicorp-copywrite[bot] 5fb9df1640
[COMPLIANCE] License changes (#18443)
* Adding explicit MPL license for sub-package

This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository.

* Adding explicit MPL license for sub-package

This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository.

* Updating the license from MPL to Business Source License

Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at <Blog URL>, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl.

* add missing license headers

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

* Update copyright file headers to BUSL-1.1

---------

Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
2023-08-11 09:12:13 -04:00

70 lines
2.4 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
'use strict';
module.exports = {
name: require('./package').name,
getTransform: function () {
return {
name: 'custom-element',
plugin: class {
transform(ast) {
this.syntax.traverse(ast, {
ElementNode: (node) => {
if (node.tag === 'CustomElement') {
node.attributes = node.attributes
// completely remove these ones, they are not used runtime
// element is potentially only temporarily being removed
.filter(
(item) =>
!['element', 'description', 'slots', 'cssparts'].includes(
`${item.name.substr(1)}`
)
)
.map((item) => {
switch (true) {
// these ones are ones where we need to remove the documentation only
// the attributes themselves are required at runtime
case ['attrs', 'cssprops'].includes(`${item.name.substr(1)}`):
item.value.params = item.value.params.map((item) => {
// we can't use arr.length here as we don't know
// whether someone has used the documentation entry
// in the array or not We use the hardcoded `3` for
// the moment if that position needs to change per
// property we can just add more cases for the
// moment
item.params = item.params.filter((item, i, arr) => i < 3);
return item;
});
break;
}
return item;
});
}
},
});
return ast;
}
},
baseDir: function () {
return __dirname;
},
cacheKey: function () {
return 'custom-element';
},
};
},
setupPreprocessorRegistry(type, registry) {
const transform = this.getTransform();
transform.parallelBabel = {
requireFile: __filename,
buildUsing: 'getTransform',
params: {},
};
registry.add('htmlbars-ast-plugin', transform);
},
};