-
Notifications
You must be signed in to change notification settings - Fork 142
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
Addon Dev - Allow ts,gts,gjs files as publicEntrypoints #1106
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,10 @@ import walkSync from 'walk-sync'; | |
import type { Plugin } from 'rollup'; | ||
import { join } from 'path'; | ||
|
||
function normalizeFileExt(fileName: string) { | ||
return fileName.replace(/\.ts|\.gts|\.gjs$/, '.js'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tl;dr: I'm back to thinking this PR is fine, and we don't need changes. 🙃 by adding This is the exact change to your PR function normalizeFileExt(fileName: string) {
- return fileName.replace(/\.ts|\.gts|\.gjs$/, '.js');
+ return fileName.replace(/\.ts|\.gts|\.gjs|\.hbs$/, '.js');
} dist/components/demo/button.js now exists, and looks correct: // ❯ cat dist/components/demo/button.js
import { setComponentTemplate } from '@ember/component';
import { hbs } from 'ember-cli-htmlbars';
var FlipButton = setComponentTemplate(FlipButton, hbs`<button {{on 'click' @onClick}}>
flip
</button>
`);
export { FlipButton as default }; and the demo/index.js in dist looks like: // ❯ cat dist/components/demo/index.js
import { setComponentTemplate } from '@ember/component';
import TEMPLATE from './index.js';
import { __decorate } from 'tslib';
import { t as tracked, C as Component } from '../../tracked-b2e133b9.js';
import FlipButton from './button.js';
import 'ember-cli-htmlbars';
import '@glimmer/application';
class Demo extends Component {
constructor(...args) {
super(...args);
this.Button = FlipButton;
this.active = false;
this.flip = () => this.active = !this.active;
}
}
__decorate([tracked], Demo.prototype, "active", void 0);
setComponentTemplate(TEMPLATE, Demo);
export { Demo as default }; which is so close to being correct. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
this seems like it'll break things though 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry for all the noise on the PR -- having a hard time with formatting and nested For some reason I now have to supply externals, and I think that's breaking a bunch of stuff (lots of stuff to exclude) -- I think In this commit: NullVoxPopuli/ember-addon-v2-typescript-demo@7834ea2 I now get this (with no changes to this PR, #1106): ❯ cat dist/components/demo/index.js
import { setComponentTemplate } from '@ember/component';
import { hbs } from 'ember-cli-htmlbars';
import { __decorate } from 'tslib';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
var TEMPLATE = setComponentTemplate(TEMPLATE, hbs`Hello there!
<out>{{this.active}}</out>
<this.Button @onClick={{this.flip}} />
`);
var FlipButton = setComponentTemplate(FlipButton, hbs`<button {{on 'click' @onClick}}>
flip
</button>
`);
class Demo extends Component {
constructor(...args) {
super(...args);
this.Button = FlipButton;
this.active = false;
this.flip = () => this.active = !this.active;
}
}
__decorate([tracked], Demo.prototype, "active", void 0);
setComponentTemplate(TEMPLATE, Demo);
export { Demo as default }; |
||
} | ||
|
||
export default function publicEntrypoints(args: { | ||
srcDir: string; | ||
include: string[]; | ||
|
@@ -15,7 +19,7 @@ export default function publicEntrypoints(args: { | |
this.emitFile({ | ||
type: 'chunk', | ||
id: join(args.srcDir, name), | ||
fileName: name, | ||
fileName: normalizeFileExt(name), | ||
}); | ||
} | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kinda like the idea of being able to have .d.ts files co-located with the js and js.map files!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even for the app files that get's merged into the host app? You can still have colocated in the other files, not in the app folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, I mean I support this change! I'm excited for it!
I've been making separate types directories because of the way it used to be