Skip to content

Commit ac2a822

Browse files
authored
embroider ready (#1454)
1 parent 0669831 commit ac2a822

File tree

8 files changed

+49
-45
lines changed

8 files changed

+49
-45
lines changed

.eslintrc.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
const { buildEmberPlugins } = require('ember-cli-babel');
4+
35
module.exports = {
46
globals: {
57
server: true,
@@ -9,6 +11,13 @@ module.exports = {
911
parserOptions: {
1012
ecmaVersion: 2020,
1113
sourceType: 'module',
14+
requireConfigFile: false,
15+
babelOptions: {
16+
babelrc: false,
17+
configFile: false,
18+
// your babel options
19+
plugins: buildEmberPlugins(),
20+
},
1221
ecmaFeatures: {
1322
legacyDecorators: true,
1423
},

.github/workflows/ci-cd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ jobs:
104104
- 'ember-canary'
105105
- 'ember-default-with-jquery'
106106
- 'ember-classic'
107-
# - 'embroider-safe'
107+
- 'embroider-safe'
108108
# - 'embroider-optimized'
109109
timeout-minutes: 7
110110
steps:

babel.config.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

index.js

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,6 @@ module.exports = {
206206
return new AddonDocsDeployPlugin(this._readUserConfig());
207207
},
208208

209-
setupPreprocessorRegistry(type, registry) {
210-
if (type === 'parent') {
211-
let TemplateCompiler = require('./lib/preprocessors/markdown-template-compiler');
212-
let ContentExtractor = require('./lib/preprocessors/hbs-content-extractor');
213-
registry.add('template', new TemplateCompiler());
214-
registry.add('template', new ContentExtractor(this.getBroccoliBridge()));
215-
}
216-
},
217-
218209
contentFor(type) {
219210
if (type === 'body') {
220211
return fs.readFileSync(
@@ -247,12 +238,36 @@ module.exports = {
247238
return this._broccoliBridge;
248239
},
249240

250-
postprocessTree(type, tree) {
241+
treeForApp(tree) {
242+
if (!this._appTree) {
243+
let { app, templates } = this.app.trees;
244+
let appTree = new MergeTrees([new Funnel(app), new Funnel(templates)], {
245+
overwrite: true,
246+
annotation: 'app md & templates',
247+
});
248+
let TemplateCompiler = require('./lib/preprocessors/markdown-template-compiler');
249+
const templateCompiler = new TemplateCompiler();
250+
appTree = templateCompiler.toTree(appTree);
251+
appTree = new Funnel(appTree, {
252+
include: [/.*\.hbs/],
253+
annotation: 'app templates',
254+
});
255+
this._appTree = this._super(new MergeTrees([tree, appTree]));
256+
}
257+
return this._appTree;
258+
},
259+
260+
treeForPublic(tree) {
251261
let addonToDocument = this._documentingAddon();
252-
if (!addonToDocument || type !== 'all') {
262+
if (!addonToDocument) {
253263
return tree;
254264
}
255265

266+
let ContentExtractor = require('./lib/preprocessors/hbs-content-extractor');
267+
let appTree = this._treeFor('app');
268+
const contentExtractor = new ContentExtractor(this.getBroccoliBridge());
269+
contentExtractor.toTree(appTree);
270+
256271
let PluginRegistry = require('./lib/models/plugin-registry');
257272
let DocsCompiler = require('./lib/broccoli/docs-compiler');
258273
let SearchIndexer = require('./lib/broccoli/search-indexer');
@@ -285,19 +300,22 @@ module.exports = {
285300
);
286301
}
287302

288-
let docsTree = new MergeTrees(docsTrees);
303+
let docsTree = new MergeTrees(docsTrees, { annotation: 'docsTrees' });
289304

290305
let templateContentsTree =
291306
this.getBroccoliBridge().placeholderFor('template-contents');
292307
let searchIndexTree = new SearchIndexer(
293-
new MergeTrees([docsTree, templateContentsTree]),
308+
new MergeTrees([docsTree, templateContentsTree], {
309+
annotation: 'SearchIndexer',
310+
}),
294311
{
295312
outputFile: 'ember-cli-addon-docs/search-index.json',
296313
config: this.project.config(EmberApp.env()),
297314
}
298315
);
299-
300-
return new MergeTrees([tree, docsTree, searchIndexTree]);
316+
return new MergeTrees([this._super(tree), searchIndexTree, docsTree], {
317+
annotation: 'this._super(tree), docsTree',
318+
});
301319
},
302320

303321
_lunrTree() {

lib/broccoli/search-indexer.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,7 @@ module.exports = class SearchIndexCompiler extends Writer {
6262
let modulePrefix = this.config.modulePrefix;
6363

6464
let routePath;
65-
if (
66-
relativePath.indexOf(modulePrefix) === 0 &&
67-
/\.template-contents$/.test(relativePath)
68-
) {
65+
if (/\.template-contents$/.test(relativePath)) {
6966
routePath = relativePath
7067
.replace(`${modulePrefix}/templates/`, '')
7168
.replace(/\.template-contents$/, '');

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
"@ember/optional-features": "^2.0.0",
103103
"@ember/string": "^3.0.1",
104104
"@ember/test-helpers": "^2.8.1",
105-
"@embroider/test-setup": "^2.0.2",
105+
"@embroider/test-setup": "^3.0.1",
106106
"@fullhuman/postcss-purgecss": "^4.0.3",
107107
"broccoli-asset-rev": "^3.0.0",
108108
"chai": "^4.2.0",

tests/helpers/resolver.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,10 +1402,10 @@
14021402
semver "^7.3.5"
14031403
typescript-memoize "^1.0.1"
14041404

1405-
"@embroider/test-setup@^2.0.2":
1406-
version "2.1.1"
1407-
resolved "https://registry.yarnpkg.com/@embroider/test-setup/-/test-setup-2.1.1.tgz#1cf613f479ed120fdc5d71cb834c8fb71514cce1"
1408-
integrity sha512-t81a2z2OEFAOZVbV7wkgiDuCyZ3ajD7J7J+keaTfNSRiXoQgeFFASEECYq1TCsH8m/R+xHMRiY59apF2FIeFhw==
1405+
"@embroider/test-setup@^3.0.1":
1406+
version "3.0.1"
1407+
resolved "https://registry.yarnpkg.com/@embroider/test-setup/-/test-setup-3.0.1.tgz#603b21a809708ac928fe9f002905ee3711dc6864"
1408+
integrity sha512-t7R2f10iZDSNw3ovWAPM63GRQTu63uihpVh6CvHev5XkLt8B7tdxcxGyO6RbdF5Hu+pbsUu8sD0kAlR1gopmxg==
14091409
dependencies:
14101410
lodash "^4.17.21"
14111411
resolve "^1.20.0"

0 commit comments

Comments
 (0)