Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
patricklx committed Mar 7, 2024
1 parent 8bb9326 commit 68f9d30
Show file tree
Hide file tree
Showing 7 changed files with 845 additions and 839 deletions.
6 changes: 5 additions & 1 deletion carbon-components-ember/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,13 @@
"types": "./declarations/index.d.ts",
"default": "./dist/index.js"
},
"./components/*": {
"types": "./declarations/*.d.ts",
"default": "./dist/components/*/index.js"
},
"./*": {
"types": "./declarations/*.d.ts",
"default": "./dist/*.js"
"default": "./dist/*/*.js"
},
"./addon-main.js": "./addon-main.cjs"
},
Expand Down
2 changes: 1 addition & 1 deletion doc-app/app/app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Application from '@ember/application';
import Resolver from 'ember-resolver';
import loadInitializers from 'ember-load-initializers';
import config from 'test-app/config/environment';
import config from 'doc-app/config/environment';

export default class App extends Application {
modulePrefix = config.modulePrefix;
Expand Down
2 changes: 1 addition & 1 deletion doc-app/config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module.exports = function (environment) {
const ENV = {
modulePrefix: 'test-app',
modulePrefix: 'doc-app',
environment,
rootURL: '/',
locationType: 'history',
Expand Down
78 changes: 47 additions & 31 deletions doc-app/ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,37 @@ const EmberApp = require('ember-cli/lib/broccoli/ember-app');
const { resolve } = require('path');
const { Resolver } = require('@embroider/core');


const componentTemplateCandidates = Resolver.prototype.componentTemplateCandidates;
const componentTemplateCandidates =
Resolver.prototype.componentTemplateCandidates;
Resolver.prototype.componentTemplateCandidates = function () {
return [...componentTemplateCandidates.call(this)].concat([{ prefix: '/', suffix: '/template' }]);
}
return [...componentTemplateCandidates.call(this)].concat([
{ prefix: '/', suffix: '/template' },
]);
};

const componentJSCandidates = Resolver.prototype.componentJSCandidates;
Resolver.prototype.componentJSCandidates = function () {
const extensions = ['.js', '.ts', '.gjs', '.gts'];
const result = [...componentJSCandidates.call(this)];
for (const ext of extensions) {
result.push(...[
{ prefix: '/', suffix: ext },
{ prefix: '/', suffix: `/index${ext}` },
{ prefix: '/', suffix: `/component${ext}` }
]);
result.push(
...[
{ prefix: '/', suffix: ext },
{ prefix: '/', suffix: `/index${ext}` },
{ prefix: '/', suffix: `/component${ext}` },
]
);
}
return result;
}

};

const parseGlobalPath = Resolver.prototype.parseGlobalPath;
Resolver.prototype.parseGlobalPath = function (path, inEngine) {
if (path.includes('__hbs__import_')) {
const parts = path.replace('__hbs__import_', '').split('/');
let packageName = parts[0].startsWith('@') ? parts.slice(0, 2).join('/') : parts[0];
let packageName = parts[0].startsWith('@')
? parts.slice(0, 2).join('/')
: parts[0];
try {
// packageName = this.packageCache.resolve(packageName, inEngine).root;
} catch (e) {
Expand All @@ -39,52 +44,63 @@ Resolver.prototype.parseGlobalPath = function (path, inEngine) {
return {
packageName,
memberName,
from: resolve(inEngine.root, 'package.json')
}
from: resolve(inEngine.root, 'package.json'),
};
}
return parseGlobalPath.call(this, path, inEngine);
}
};

const resolveHelper = Resolver.prototype.resolveHelper;
Resolver.prototype.resolveHelper = function (path, inEngine, request) {
if (path.includes('__hbs__import_')) {
let target = this.parseGlobalPath(path, inEngine);
return request.alias(`${target.packageName}/${target.memberName}`).rehome((0, path_1.resolve)(inEngine.root, 'package.json'));
return request
.alias(`${target.packageName}/${target.memberName}`)
.rehome((0, resolve)(inEngine.root, 'package.json'));
}
return resolveHelper.call(this, path, inEngine, request);
}
};

const resolveModifier = Resolver.prototype.resolveModifier;
Resolver.prototype.resolveModifier = function (path, inEngine, request) {
if (path.includes('__hbs__import_')) {
let target = this.parseGlobalPath(path, inEngine);
return request.alias(`${target.packageName}/${target.memberName}`).rehome((0, path_1.resolve)(inEngine.root, 'package.json'));
return request
.alias(`${target.packageName}/${target.memberName}`)
.rehome((0, resolve)(inEngine.root, 'package.json'));
}
return resolveModifier.call(this, path, inEngine, request);
}
};

module.exports = function (defaults) {
let app = new EmberApp(defaults, {
autoImport: {
watchDependencies: ['carbon-components-ember'],
},
'ember-cli-addon-docs': {
documentingAddonAt: '../carbon-components-ember'
documentingAddonAt: '../carbon-components-ember',
},
'ember-cli-babel': {
enableTypeScriptTransform: true,
},
});

return require('@embroider/compat').compatBuild(app, require('@embroider/webpack').Webpack, {
staticAddonTrees: true,
staticAddonTestSupportTrees: true,
staticComponents: true,
staticHelpers: true,
staticModifiers: true,
staticEmberSource: true,
amdCompatibility: {
es: [],
'ember-hbs-imports': {
embroiderStatic: true,
},
});

return require('@embroider/compat').compatBuild(
app,
require('@embroider/webpack').Webpack,
{
staticAddonTrees: true,
staticAddonTestSupportTrees: true,
staticComponents: true,
staticHelpers: true,
staticModifiers: true,
staticEmberSource: true,
amdCompatibility: {
es: [],
},
}
);
};
15 changes: 5 additions & 10 deletions doc-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,12 @@
"test": "concurrently \"npm:lint\" \"npm:test:*\" --names \"lint,test:\"",
"test:ember": "ember test"
},
"dependencies": {
"ember-cli-addon-docs": "^7.0.1",
"ember-cli-addon-docs-yuidoc": "^1.1.0"
},
"devDependencies": {
"ember-vite-hmr": "^0.6.0",
"@embroider/compat": "^3.4.5",
"@embroider/core": "^3.4.5",
"@embroider/vite": "^0.2.0",
"@embroider/webpack": "^3.2.2",
"@embroider/compat": "^3.4.6-unstable.6d64eff",
"@embroider/core": "^3.4.6-unstable.6d64eff",
"@embroider/vite": "^0.2.1-unstable.6d64eff",
"@embroider/webpack": "^3.2.3-unstable.6d64eff",
"@babel/eslint-parser": "^7.22.5",
"@babel/plugin-proposal-decorators": "^7.22.5",
"@ember/optional-features": "^2.0.0",
Expand All @@ -55,9 +51,8 @@
"ember-cli-inject-live-reload": "^2.1.0",
"ember-cli-sri": "^2.1.1",
"ember-cli-terser": "^4.0.2",
"ember-hbs-imports": "^1.0.4",
"ember-hbs-imports": "^1.0.5",
"ember-data": "~5.1.0",
"ember-fetch": "^8.1.2",
"ember-load-initializers": "^2.1.2",
"ember-modifier": "^4.1.0",
"ember-page-title": "^7.0.0",
Expand Down
4 changes: 2 additions & 2 deletions doc-app/tests/test-helper.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Application from 'test-app/app';
import config from 'test-app/config/environment';
import Application from 'doc-app/app';
import config from 'doc-app/config/environment';
import * as QUnit from 'qunit';
import { setApplication } from '@ember/test-helpers';
import { setup } from 'qunit-dom';
Expand Down
Loading

0 comments on commit 68f9d30

Please sign in to comment.