Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): prevent generate task from crashing #5693

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/test-component-starter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,34 @@ jobs:
run: npm run test -- --no-build # the project was just built, don't build it again
working-directory: ./tmp-component-starter
shell: bash

- name: Test npx stencil generate
# `stencil generate` doesn't have a way to skip file generation, so we provide it with a component name and run
# `echo` with a newline to select "all files" to generate (and use -e to interpret that backslash for a newline)
run: echo -e '\n' | npm run generate -- hello-world
working-directory: ./tmp-component-starter
shell: bash

- name: Verify Files Exist
run: |
file_list=(
src/components/hello-world/hello-world.tsx
src/components/hello-world/hello-world.css
src/components/hello-world/test/hello-world.spec.tsx
src/components/hello-world/test/hello-world.e2e.ts
)
for file in "${file_list[@]}"; do
if [ -f "$file" ]; then
echo "File '$file' exists."
else
echo "File '$file' does not exist."
exit 1
fi
done
working-directory: ./tmp-component-starter
shell: bash

- name: Test Generated Files
run: npm run test
working-directory: ./tmp-component-starter
shell: bash
2 changes: 2 additions & 0 deletions scripts/esbuild/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export async function buildCli(opts: BuildOptions) {
const dtsFilename = 'index.d.ts';

const cliAliases = getEsbuildAliases();
// this isn't strictly necessary to alias - however, this minimizes cuts down the bundle size by ~70kb.
cliAliases['prompts'] = 'prompts/lib/index.js';

const external = getEsbuildExternalModules(opts, opts.output.cliDir);

Expand Down
3 changes: 1 addition & 2 deletions scripts/esbuild/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ export function getEsbuildAliases(): Record<string, string> {

// mapping node.js module names to `sys/node` "cache"
//
// these allow us to bundle and ship a dependency (like `prompts`) as part
// these allow us to bundle and ship a dependency (like `glob`) as part
// of the Stencil distributable but also have our separate bundles
// reference the same file
prompts: './sys/node/prompts.js',
glob: './sys/node/glob.js',

// dev server related aliases
Expand Down