Skip to content

Commit

Permalink
Merge pull request #231 from embroider-build/try-decorator-transforms
Browse files Browse the repository at this point in the history
Remove unneeded babel plugins so that shipped addon code is way smaller and easier to debug without sourcemaps
  • Loading branch information
ef4 authored Dec 8, 2023
2 parents 1185872 + 5410e19 commit c161b56
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 17 deletions.
4 changes: 1 addition & 3 deletions files/__addonLocation__/babel.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
"plugins": [
<% if (typescript) { %> ["@babel/plugin-transform-typescript", { "allExtensions": true, "onlyRemoveTypeImports": true, "allowDeclareFields": true }],
<% } %> "@embroider/addon-dev/template-colocation-plugin",
"@babel/plugin-transform-class-static-block",
["babel-plugin-ember-template-compilation", {
"targetFormat": "hbs",
"transforms": []
}],
["@babel/plugin-proposal-decorators", { "version": "legacy" }],
"@babel/plugin-proposal-class-properties"
["module:decorator-transforms", { "runtime": { "import": "decorator-transforms/runtime" } }],
]
}
6 changes: 2 additions & 4 deletions files/__addonLocation__/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,12 @@
"prepack": "rollup --config"
},
"dependencies": {
"@embroider/addon-shim": "^1.0.0"
"@embroider/addon-shim": "^1.0.0",
"decorator-transforms": "^1.0.1"
},
"devDependencies": {
"@babel/core": "^7.17.0",
<% if (typescript) { %>"@babel/plugin-transform-typescript": "^7.22.15"<% } else { %>"@babel/eslint-parser": "^7.19.1"<% } %>,
"@babel/plugin-proposal-class-properties": "^7.16.7",
"@babel/plugin-proposal-decorators": "^7.20.13",
"@babel/plugin-transform-class-static-block": "^7.20.0",
"@babel/runtime": "^7.17.0",
"@embroider/addon-dev": "^4.1.0",<% if (typescript) { %>
"@glint/core": "^1.2.0",
Expand Down
6 changes: 3 additions & 3 deletions tests/smoke-tests/--addon-only.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('--addon-only', () => {
expect(rootContents).to.include('.editorconfig');
expect(rootContents).to.include('.eslintignore');
expect(rootContents).to.include('.eslintrc.cjs');
expect(rootContents).to.include('.gitignore');
expect(rootContents).to.include('.gitignore');
expect(rootContents).to.include('.npmrc');
expect(rootContents).to.include('.prettierignore');
expect(rootContents).to.include('.prettierrc.cjs');
Expand All @@ -39,11 +39,11 @@ describe('--addon-only', () => {
expect(rootContents).to.include('rollup.config.mjs');

let configContents = await dirContents(path.join(helper.projectRoot, 'config'));

expect(configContents).to.include('ember-cli-update.json');

let srcContents = await dirContents(path.join(helper.projectRoot, 'src'));

expect(srcContents).to.include('index.js');
});

Expand Down
9 changes: 2 additions & 7 deletions tests/smoke-tests/--typescript.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,12 @@ for (let packageManager of SUPPORTED_PACKAGE_MANAGERS) {
'template-registry.js.map',
]);

expect(distContents.hashed.length).toBe(4);
expect(
distContents.hashed
.filter((file) => file.includes('_rollup'))
.map((file) => file.split('.js')[1]),
).to.deep.equal(['', '.map'], 'the rollup helpers are emitted with a source map');
expect(distContents.hashed.length).toBe(2);
expect(
distContents.hashed
.filter((file) => file.includes('template-only'))
.map((file) => file.split('.js')[1]),
).to.deep.equal(['', '.map'], 'the template-only component is emitted with a source map');
).to.deep.equal(['', '.map'], 'the template-only (private) component is emitted with a source map');

expect(declarationsContents).to.deep.equal([
'components',
Expand Down

0 comments on commit c161b56

Please sign in to comment.