Skip to content

Commit

Permalink
Feature/use target (#1206)
Browse files Browse the repository at this point in the history
* init useTarget

* l

* v

* f

* f

* add test

* get parseJsx working

* f

* clean

* clean

* f

* f

* f

* f

* f

* f

* f

* f

* f

* rmv

* throw

* f
  • Loading branch information
samijaber authored Jun 14, 2023
1 parent 0612bb0 commit a3d65ca
Show file tree
Hide file tree
Showing 65 changed files with 2,147 additions and 550 deletions.
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
"ci:e2e": "yarn workspace @builder.io/e2e-app run e2e",
"ci": "run-s \"ci:*\"",
"commit": "git-cz",
"fix": "run-p -c 'lint:* --fix'",
"fmt": "yarn fmt:prettier",
"fmt": "run-s 'fmt:*'",
"fmt:eslint": "yarn lint:eslint --fix",
"fmt:prettier": "yarn lint:prettier --write",
"lint": "run-p -c lint:*",
"lint": "run-p -c 'lint:*'",
"lint:eslint": "eslint --cache 'packages/**/*.ts{,x}'",
"lint:prettier": "yarn run prettier --check",
"prerelease": "yarn build",
Expand Down Expand Up @@ -71,6 +71,7 @@
"@builder.io/e2e-app": "workspace:*"
},
"resolutions": {
"@sveltejs/[email protected]": "patch:@sveltejs/package@npm:1.0.0-next.1#.yarn/patches/@sveltejs-package-npm-1.0.0-next.1-2fd015530b.patch"
"@sveltejs/[email protected]": "patch:@sveltejs/package@npm:1.0.0-next.1#.yarn/patches/@sveltejs-package-npm-1.0.0-next.1-2fd015530b.patch",
"prettier": "^2.8.7"
}
}
30 changes: 30 additions & 0 deletions packages/core/src/__tests__/__snapshots__/alpine.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2544,6 +2544,21 @@ exports[`Alpine.js > jsx > Javascript Test > use-style-outside-component 1`] = `
"
`;

exports[`Alpine.js > jsx > Javascript Test > useTarget 1`] = `
"<div x-data=\\"useTargetComponent()\\"><span x-html=\\"name\\"></span></div>
<script>
document.addEventListener(\\"alpine:init\\", () => {
Alpine.data(\\"useTargetComponent\\", () => ({
get name() {
const prefix = \\"a\\";
return prefix + \\"foo\\";
},
}));
});
</script>
"
`;

exports[`Alpine.js > jsx > Remove Internal mitosis package 1`] = `
"<div x-data=\\"myBasicComponent()\\">
Hello
Expand Down Expand Up @@ -5096,6 +5111,21 @@ exports[`Alpine.js > jsx > Typescript Test > use-style-outside-component 1`] = `
"
`;

exports[`Alpine.js > jsx > Typescript Test > useTarget 1`] = `
"<div x-data=\\"useTargetComponent()\\"><span x-html=\\"name\\"></span></div>
<script>
document.addEventListener(\\"alpine:init\\", () => {
Alpine.data(\\"useTargetComponent\\", () => ({
get name() {
const prefix = \\"a\\";
return prefix + \\"foo\\";
},
}));
});
</script>
"
`;

exports[`Alpine.js > svelte > Javascript Test > basic 1`] = `
"<div x-data=\\"myComponent()\\">
<input x-on:change=\\"name = $event.target.value\\" x-bind:value=\\"name\\" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4064,6 +4064,34 @@ export class MyComponentModule {}
"
`;

exports[`Angular with Preserve Imports and File Extensions > jsx > Javascript Test > useTarget 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";

import { Component } from \\"@angular/core\\";

@Component({
selector: \\"use-target-component, UseTargetComponent\\",
template: \`
<div>{{name}}</div>
\`,
})
export class UseTargetComponent {
get name() {
const prefix = true;
return prefix + \\"foo\\";
}
}

@NgModule({
declarations: [UseTargetComponent],
imports: [CommonModule],
exports: [UseTargetComponent],
})
export class UseTargetComponentModule {}
"
`;

exports[`Angular with Preserve Imports and File Extensions > jsx > Remove Internal mitosis package 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";
Expand Down Expand Up @@ -8554,6 +8582,34 @@ export class MyComponentModule {}
"
`;

exports[`Angular with Preserve Imports and File Extensions > jsx > Typescript Test > useTarget 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";

import { Component } from \\"@angular/core\\";

@Component({
selector: \\"use-target-component, UseTargetComponent\\",
template: \`
<div>{{name}}</div>
\`,
})
export class UseTargetComponent {
get name() {
const prefix = true;
return prefix + \\"foo\\";
}
}

@NgModule({
declarations: [UseTargetComponent],
imports: [CommonModule],
exports: [UseTargetComponent],
})
export class UseTargetComponentModule {}
"
`;

exports[`Angular with Preserve Imports and File Extensions > svelte > Javascript Test > basic 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4156,6 +4156,35 @@ export class MyComponentModule {}
"
`;

exports[`Angular with Import Mapper Tests > jsx > Javascript Test > useTarget 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";

import { Component } from \\"@angular/core\\";

@Component({
selector: \\"use-target-component, UseTargetComponent\\",
template: \`
<div>{{name}}</div>
\`,
})
export class UseTargetComponent {
get name() {
const prefix = true;
return prefix + \\"foo\\";
}
}

@NgModule({
declarations: [UseTargetComponent],
imports: [CommonModule],
exports: [UseTargetComponent],
bootstrap: [SomeOtherComponent],
})
export class UseTargetComponentModule {}
"
`;

exports[`Angular with Import Mapper Tests > jsx > Remove Internal mitosis package 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";
Expand Down Expand Up @@ -8741,6 +8770,35 @@ export class MyComponentModule {}
"
`;

exports[`Angular with Import Mapper Tests > jsx > Typescript Test > useTarget 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";

import { Component } from \\"@angular/core\\";

@Component({
selector: \\"use-target-component, UseTargetComponent\\",
template: \`
<div>{{name}}</div>
\`,
})
export class UseTargetComponent {
get name() {
const prefix = true;
return prefix + \\"foo\\";
}
}

@NgModule({
declarations: [UseTargetComponent],
imports: [CommonModule],
exports: [UseTargetComponent],
bootstrap: [SomeOtherComponent],
})
export class UseTargetComponentModule {}
"
`;

exports[`Angular with Import Mapper Tests > svelte > Javascript Test > basic 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";
Expand Down
98 changes: 98 additions & 0 deletions packages/core/src/__tests__/__snapshots__/angular.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7465,6 +7465,55 @@ export class MyComponent {}
"
`;

exports[`Angular > jsx > Javascript Test > useTarget 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";

import { Component } from \\"@angular/core\\";

@Component({
selector: \\"use-target-component, UseTargetComponent\\",
template: \`
<div>{{name}}</div>
\`,
})
export class UseTargetComponent {
get name() {
const prefix = true;
return prefix + \\"foo\\";
}
}

@NgModule({
declarations: [UseTargetComponent],
imports: [CommonModule],
exports: [UseTargetComponent],
})
export class UseTargetComponentModule {}
"
`;

exports[`Angular > jsx > Javascript Test > useTarget 2`] = `
"import { Component } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";

@Component({
selector: \\"use-target-component, UseTargetComponent\\",
template: \`
<div>{{name}}</div>
\`,
standalone: true,
imports: [CommonModule],
})
export class UseTargetComponent {
get name() {
const prefix = true;
return prefix + \\"foo\\";
}
}
"
`;

exports[`Angular > jsx > Remove Internal mitosis package 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";
Expand Down Expand Up @@ -15773,6 +15822,55 @@ export class MyComponent {}
"
`;

exports[`Angular > jsx > Typescript Test > useTarget 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";

import { Component } from \\"@angular/core\\";

@Component({
selector: \\"use-target-component, UseTargetComponent\\",
template: \`
<div>{{name}}</div>
\`,
})
export class UseTargetComponent {
get name() {
const prefix = true;
return prefix + \\"foo\\";
}
}

@NgModule({
declarations: [UseTargetComponent],
imports: [CommonModule],
exports: [UseTargetComponent],
})
export class UseTargetComponentModule {}
"
`;

exports[`Angular > jsx > Typescript Test > useTarget 2`] = `
"import { Component } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";

@Component({
selector: \\"use-target-component, UseTargetComponent\\",
template: \`
<div>{{name}}</div>
\`,
standalone: true,
imports: [CommonModule],
})
export class UseTargetComponent {
get name() {
const prefix = true;
return prefix + \\"foo\\";
}
}
"
`;

exports[`Angular > svelte > Javascript Test > basic 1`] = `
"import { NgModule } from \\"@angular/core\\";
import { CommonModule } from \\"@angular/common\\";
Expand Down
Loading

1 comment on commit a3d65ca

@vercel
Copy link

@vercel vercel bot commented on a3d65ca Jun 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.