lemon-eye-70471
05/03/2024, 2:30 PM"*.jsx"
as a default option to the javascript_sources.sources
field? I'm imagining setting this default in pants.toml somehow.curved-television-6568
05/03/2024, 8:39 PM___defaults___
in the build file.
https://www.pantsbuild.org/2.20/docs/using-pants/key-concepts/targets-and-build-files#field-default-valuescurved-television-6568
05/03/2024, 8:40 PMcurved-television-6568
05/03/2024, 8:41 PMsilly-queen-7197
05/03/2024, 11:19 PM*.jsx
would dependency parsing still work? Actually even if you call them js
files, does dependency parsing still work for JSX? I've been assuming it wouldn'tsilly-queen-7197
05/03/2024, 11:26 PMimport * as React from 'react';
export default function App() {
return (
<div>
<h1>Hello, world!</h1>
</div>
);
}
╰❱ pants dependencies index.js
//:0#react
silly-queen-7197
05/03/2024, 11:46 PMjsx
. I'm having a hard time following the example in the "Extending field defaults".
Just to clarify, when doing something like
javascript_sources(
name="support-jsx",
sources=["index.jsx"]
)
running pants dependencies :support-jsx
produces
InvalidFieldException: BUILD:1: Invalid field value for 'sources' in target //:support-jsx: The 'sources' field in target //:support-jsx can only contain files that end in one of ['.cjs', '.js', '.mjs'], but it had these files: ['index.jsx'].
This can be sidestepped by overriding defaults?nutritious-hair-72580
05/04/2024, 6:32 AMcurved-television-6568
05/04/2024, 8:56 AMjavascript_sources
target only accepts .cjs, .js and .mjs files.lemon-eye-70471
05/06/2024, 3:32 PMjsx_sources
target in a custom plugin:
from pants.engine.target import (
COMMON_TARGET_FIELDS,
Dependencies,
MultipleSourcesField,
StringField,
Target,
)
class JsxSourcesField(MultipleSourcesField):
alias = "sources"
expected_file_extensions = ("*.jsx", "*.js")
class JsxSourcesTarget(Target):
alias = "jsx_sources"
core_fields = (
*COMMON_TARGET_FIELDS,
Dependencies,
JsxSourcesField,
)