Skip to content

Conversation

@zburke
Copy link
Member

@zburke zburke commented Jan 14, 2025

Replace the transpile command implemented in #259 (STCLI-224), which transpiled and bundled with help from stripes-webpack, with one that only conducts transpilation.

yarn stripes transpile
yarn stripes transpile --files ./lib

The default files value is ./src. Files are transpiled into ./dist. Sourcemaps are included. Non-compilable files (e.g. .css) are copied into the destination directory.

All dependencies and babel config files are included locally. The intent is to provide a canonical service, much as stripes-webpack has in the past, so the packages using this service do not have to worry about managing dependencies or config files.

The babel config is contained in
./lib/commands/transpile-babel.config.json:

{
  "presets": [
    ["@babel/preset-env", {
      "targets": "> 0.25%, not dead",
      // preset-env will transform dynamic exports, but we want
      // to let webpack handle those
      "exclude": ["transform-dynamic-import"]
    }],
    ["@babel/preset-flow", { "all": true }],
    ["@babel/preset-react", { "runtime": "automatic" }],
    ["@babel/preset-typescript"]
  ],
  "plugins": [
    ["@babel/plugin-proposal-decorators", { "legacy": true }],
    // when building a platform directly, i.e. outside a workspace,
    // babel complains loudly and repeatedly that when these modules are enabled:
    // * @babel/plugin-proposal-class-properties,
    // * @babel/plugin-proposal-private-methods and
    // * @babel/plugin-proposal-private-property-in-object
    // the "loose" option must be the same for all three.
    // but @babel/preset-env sets it to false for ...private-methods.
    // overriding it here silences the complaint. STRWEB-12
    ["@babel/plugin-transform-class-properties", { "loose": true }],
    ["@babel/plugin-transform-private-methods", { "loose": true }],
    ["@babel/plugin-transform-private-property-in-object", { "loose": true }],
    "@babel/plugin-transform-export-namespace-from",
    "@babel/plugin-proposal-function-sent",
    "@babel/plugin-transform-numeric-separator",
    "@babel/plugin-proposal-throw-expressions",
    "@babel/plugin-syntax-import-meta"
  ]
}

Refs STCLI-259

Replace the `transpile` command implmented in #259 (STCLI-224), which
transpiled and bundled with help from stripes-cli, with one that only
conducts transpilation.

```
yarn stripes transpile
yarn stripes transpile --path ./lib
```

The default `path` is `./src`. Files are transpiled into `./dist`.
Sourcemaps are included. Non-compilable files (e.g. `.css`) are copied
into the destination directory.

All dependencies and babel config files are included locally. The intent
is to provide a canonical service, much as stripes-webpack has in the
past, so the packages using this service do not have to worry about
managing dependencies or config files.

The babel config is contained in
`./lib/commands/transpile-babel.config.json`:
```
{
  "presets": [
    ["@babel/preset-env", {
      "targets": "> 0.25%, not dead",
      // preset-env will transform dynamic exports, but we want
      // to let webpack handle those
      "exclude": ["transform-dynamic-import"]
    }],
    ["@babel/preset-flow", { "all": true }],
    ["@babel/preset-react", { "runtime": "automatic" }],
    ["@babel/preset-typescript"]
  ],
  "plugins": [
    ["@babel/plugin-proposal-decorators", { "legacy": true }],
    // when building a platform directly, i.e. outside a workspace,
    // babel complains loudly and repeatedly that when these modules are enabled:
    // * @babel/plugin-proposal-class-properties,
    // * @babel/plugin-proposal-private-methods and
    // * @babel/plugin-proposal-private-property-in-object
    // the "loose" option must be the same for all three.
    // but @babel/preset-env sets it to false for ...private-methods.
    // overriding it here silences the complaint. STRWEB-12
    ["@babel/plugin-transform-class-properties", { "loose": true }],
    ["@babel/plugin-transform-private-methods", { "loose": true }],
    ["@babel/plugin-transform-private-property-in-object", { "loose": true }],
    "@babel/plugin-transform-export-namespace-from",
    "@babel/plugin-proposal-function-sent",
    "@babel/plugin-transform-numeric-separator",
    "@babel/plugin-proposal-throw-expressions",
    "@babel/plugin-syntax-import-meta"
  ]
}
```

Refs STCLI-259
@github-actions
Copy link

github-actions bot commented Jan 14, 2025

Jest Unit Test Results

0 tests  ±0   0 ✅ ±0   0s ⏱️ ±0s
0 suites ±0   0 💤 ±0 
0 files   ±0   0 ❌ ±0 

Results for commit 521e31e. ± Comparison against base commit 481713d.

♻️ This comment has been updated with latest results.

@zburke zburke marked this pull request as ready for review February 4, 2025 16:52
@zburke zburke requested a review from a team as a code owner February 4, 2025 16:52
@zburke
Copy link
Member Author

zburke commented Feb 11, 2025

@JohnC-80 , babel config is provided here as a straight .json file, rather than a .js file extending the config exported by stripes-webpack. At the time, my thinking was ".json is the recommended way and our config doesn't do anything fancy that requires actual JS." Which is true: the config itself doesn't require JS, but having only one single config in use across all our repos is a great goal and of course does require JS.

I think the rest of this PR is straightforward, but I welcome any feedback.

@zburke zburke requested a review from a team February 12, 2025 02:38
@Dmytro-Melnyshyn Dmytro-Melnyshyn requested a review from a team February 13, 2025 10:59
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants