Skip to content
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

build ember_debug with vite #2458

Closed
wants to merge 21 commits into from
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: setup pnpm
uses: NullVoxPopuli/action-setup-pnpm@v2
- name: Install dependencies (pnpm)
run: pnpm install
run: pnpm install && cd ember_debug && pnpm i && cd ..
- name: Lint (hbs)
run: pnpm lint:hbs
- name: Lint (js)
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
- name: setup pnpm
uses: NullVoxPopuli/action-setup-pnpm@v2
- name: Install dependencies (pnpm)
run: pnpm install
run: pnpm install && cd ember_debug && pnpm i && cd ..
- name: Set NO_EXTEND_PROTOTYPES
if: matrix.scenario == 'ember-default-no-prototype-extensions'
run: echo "NO_EXTEND_PROTOTYPES==true" >> .GITHUB_ENV
Expand Down
59 changes: 24 additions & 35 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,32 @@ const concatFiles = require('broccoli-concat');
const stew = require('broccoli-stew');
const writeFile = require('broccoli-file-creator');
const replace = require('broccoli-string-replace');
const Babel = require('broccoli-babel-transpiler');
const moduleResolver = require('amd-name-resolver').resolveModules({
throwOnRootAccess: false,
});
const Funnel = require('broccoli-funnel');
const ensurePosix = require('ensure-posix-path');
const path = require('path');
const BrocolliPlugin = require('broccoli-plugin');
const packageJson = require('./package.json');
const { map, mv } = stew;
const { build } = require('vite');
const viteConfig = require('./ember_debug/vite.config');

class ViteBuildPlugin extends BrocolliPlugin {
constructor(inputs, options = {}) {
const inputNodes = Array.isArray(inputs) ? inputs : [inputs];
super(inputNodes, {
persistentOutput: true,
needsCache: false,
annotation: options.annotation,
});
this.inputNodes = inputNodes;
this.options = options;
}

async build() {
viteConfig.build.outDir = `${this.outputPath}${
this.options.destDir ? '/' + this.options.destDir : ''
}`;
await build(viteConfig);
}
}

const options = {
autoImport: {
Expand All @@ -33,16 +50,6 @@ const options = {
options.minifyJS = { enabled: false };
options.minifyCSS = { enabled: false };

// Stolen from relative-module-paths.js in ember-cli-babel
function getRelativeModulePath(modulePath) {
return ensurePosix(path.relative(process.cwd(), modulePath));
}

// Stolen from relative-module-paths.js in ember-cli-babel
function resolveRelativeModulePath(name, child) {
return moduleResolver(name, getRelativeModulePath(child));
}

module.exports = function (defaults) {
let checker = new VersionChecker(defaults);
let emberChecker = checker.for('ember-source');
Expand Down Expand Up @@ -103,25 +110,7 @@ module.exports = function (defaults) {
// Ember Debug

let emberDebug = 'ember_debug';

emberDebug = new Funnel(emberDebug, {
destDir: 'ember-debug',
include: ['**/*.js'],
exclude: [
'vendor/loader.js',
'vendor/source-map.js',
'vendor/startup-wrapper.js',
],
});

emberDebug = new Babel(emberDebug, {
moduleIds: true,
getModuleId: getRelativeModulePath,
plugins: [
['module-resolver', { resolvePath: resolveRelativeModulePath }],
['transform-es2015-modules-amd', { noInterop: true }],
],
});
emberDebug = new ViteBuildPlugin(emberDebug);

const previousEmberVersionsSupportedString = `[${packageJson.previousEmberVersionsSupported
.map(function (item) {
Expand Down
3 changes: 3 additions & 0 deletions ember_debug/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
module.exports = {
root: true,
extends: '../.eslintrc.js',
globals: {
define: true,
},
rules: {
'no-useless-escape': 'off',

Expand Down
4 changes: 2 additions & 2 deletions ember_debug/adapters/basic.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint no-console: 0 */
import { onReady } from 'ember-debug/utils/on-ready';

import { A } from 'ember-debug/utils/ember/array';
import EmberObject, { computed } from 'ember-debug/utils/ember/object';
import { A } from '@ember/array';
import EmberObject, { computed } from '@ember/object';
import { Promise, resolve } from 'ember-debug/utils/rsvp';

export default EmberObject.extend({
Expand Down
2 changes: 1 addition & 1 deletion ember_debug/adapters/websocket.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import BasicAdapter from './basic';
import { onReady } from 'ember-debug/utils/on-ready';

import { computed } from 'ember-debug/utils/ember/object';
import { computed } from '@ember/object';
import { run } from 'ember-debug/utils/ember/runloop';
import { Promise } from 'ember-debug/utils/rsvp';

Expand Down
4 changes: 2 additions & 2 deletions ember_debug/container-debug.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import DebugPort from './debug-port';

import { computed } from 'ember-debug/utils/ember/object';
import { reads, readOnly } from 'ember-debug/utils/ember/object/computed';
import { computed } from '@ember/object';
import { reads, readOnly } from '@ember/object/computed';

export default DebugPort.extend({
namespace: null,
Expand Down
6 changes: 3 additions & 3 deletions ember_debug/data-debug.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import DebugPort from './debug-port';

import { A } from 'ember-debug/utils/ember/array';
import { computed, set } from 'ember-debug/utils/ember/object';
import { alias } from 'ember-debug/utils/ember/object/computed';
import { A } from '@ember/array';
import { computed, set } from '@ember/object';
import { alias } from '@ember/object/computed';
import { guidFor } from 'ember-debug/utils/ember/object/internals';

export default DebugPort.extend({
Expand Down
2 changes: 1 addition & 1 deletion ember_debug/debug-port.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import EmberObject from 'ember-debug/utils/ember/object';
import EmberObject from '@ember/object';

export default EmberObject.extend({
port: null,
Expand Down
6 changes: 3 additions & 3 deletions ember_debug/deprecation-debug.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import DebugPort from './debug-port';
import SourceMap from 'ember-debug/libs/source-map';

import { A } from 'ember-debug/utils/ember/array';
import { A } from '@ember/array';
import { registerDeprecationHandler } from 'ember-debug/utils/ember/debug';
import { computed } from 'ember-debug/utils/ember/object';
import { readOnly } from 'ember-debug/utils/ember/object/computed';
import { computed } from '@ember/object';
import { readOnly } from '@ember/object/computed';
import { guidFor } from 'ember-debug/utils/ember/object/internals';
import { cancel, debounce } from 'ember-debug/utils/ember/runloop';
import { all, resolve } from 'ember-debug/utils/rsvp';
Expand Down
8 changes: 4 additions & 4 deletions ember_debug/libs/promise-assembler.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

import Promise from 'ember-debug/models/promise';

import { A } from 'ember-debug/utils/ember/array';
import EmberObject from 'ember-debug/utils/ember/object';
import Evented from 'ember-debug/utils/ember/object/evented';
import { isNone } from 'ember-debug/utils/ember/utils';
import { A } from '@ember/array';
import EmberObject from '@ember/object';
import Evented from '@ember/object/evented';
import { isNone } from '@ember/utils';
import RSVP from 'ember-debug/utils/rsvp';

let PromiseAssembler = EmberObject.extend(Evented, {
Expand Down
8 changes: 4 additions & 4 deletions ember_debug/libs/render-tree.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import captureRenderTree from './capture-render-tree';
import { guidFor } from 'ember-debug/utils/ember/object/internals';
import { A } from 'ember-debug/utils/ember/array';
import Ember from 'ember-debug/utils/ember';
import { A } from '@ember/array';
import { EmberLoader } from 'ember-debug/utils/ember/loader';

class InElementSupportProvider {
constructor(owner) {
Expand Down Expand Up @@ -36,7 +36,7 @@ class InElementSupportProvider {

buildInElementNode(node) {
const obj = Object.create(null);
obj.index = this.currentNode.refs.size;
obj.index = this.currentNode?.refs?.size || 0;
obj.name = 'in-element';
obj.type = 'component';
obj.template = null;
Expand Down Expand Up @@ -146,7 +146,7 @@ class InElementSupportProvider {
require(req) {
return requireModule.has(req)
? requireModule(req)
: Ember.__loader.require(req);
: EmberLoader.require(req);
}

enter(node) {
Expand Down
4 changes: 2 additions & 2 deletions ember_debug/libs/source-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* A lot of the code is inspired by/taken from
* https://github.com/evanw/node-source-map-support
*/
import { A } from 'ember-debug/utils/ember/array';
import EmberObject, { computed } from 'ember-debug/utils/ember/object';
import { A } from '@ember/array';
import EmberObject, { computed } from '@ember/object';
import { Promise, resolve } from 'ember-debug/utils/rsvp';

const notFoundError = new Error('Source map url not found');
Expand Down
6 changes: 3 additions & 3 deletions ember_debug/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import DeprecationDebug from 'ember-debug/deprecation-debug';
import Session from 'ember-debug/services/session';

import Ember from 'ember-debug/utils/ember';
import Application from 'ember-debug/utils/ember/application';
import EmberObject, { computed } from 'ember-debug/utils/ember/object';
import { or } from 'ember-debug/utils/ember/object/computed';
import Application from '@ember/application';
import EmberObject, { computed } from '@ember/object';
import { or } from '@ember/object/computed';
import {
guidFor,
setGuidPrefix,
Expand Down
2 changes: 1 addition & 1 deletion ember_debug/models/profile-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

@class ProfileNode
**/
import { get } from 'ember-debug/utils/ember/object';
import { get } from '@ember/object';
import { guidFor } from 'ember-debug/utils/ember/object/internals';
const ProfileNode = function (start, payload, parent, now) {
let name;
Expand Down
6 changes: 3 additions & 3 deletions ember_debug/models/promise.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { typeOf } from 'ember-debug/utils/type-check';

import { A } from 'ember-debug/utils/ember/array';
import EmberObject, { computed } from 'ember-debug/utils/ember/object';
import { equal, or } from 'ember-debug/utils/ember/object/computed';
import { A } from '@ember/array';
import EmberObject, { computed } from '@ember/object';
import { equal, or } from '@ember/object/computed';

const dateComputed = function () {
return computed({
Expand Down
26 changes: 11 additions & 15 deletions ember_debug/object-inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,22 @@ import {
typeOf,
} from 'ember-debug/utils/type-check';
import { compareVersion } from 'ember-debug/utils/version';
import Ember from 'ember-debug/utils/ember';
import ArrayProxy from 'ember-debug/utils/ember/array/proxy';
import { inspect as emberInspect } from 'ember-debug/utils/ember/debug';
import EmberObject, {
computed,
get,
set,
} from 'ember-debug/utils/ember/object';
import { oneWay } from 'ember-debug/utils/ember/object/computed';
import { inspect as emberInspect } from '@ember/debug';
import { computed } from '@ember/object';
import Ember, { get, set, EmberObject } from 'ember-debug/utils/ember';
import { oneWay } from '@ember/object/computed';
import { cacheFor, guidFor } from 'ember-debug/utils/ember/object/internals';
import { _backburner, join } from 'ember-debug/utils/ember/runloop';
import { isNone } from 'ember-debug/utils/ember/utils';
import { isNone } from '@ember/utils';
import emberNames from './utils/ember-object-names';
import getObjectName from './utils/get-object-name';
import { EmberLoader } from 'ember-debug/utils/ember/loader';

const { meta: emberMeta, VERSION, CoreObject, ObjectProxy } = Ember;

const GlimmerComponent = (() => {
try {
return requireModule('@glimmer/component').default;
return EmberLoader.require('@glimmer/component').default;
} catch (e) {
// ignore, return undefined
}
Expand All @@ -37,7 +33,7 @@ let tagValue, tagValidate, track, tagForProperty;

try {
// Try to load the most recent library
let GlimmerValidator = Ember.__loader.require('@glimmer/validator');
let GlimmerValidator = EmberLoader.require('@glimmer/validator');

tagValue = GlimmerValidator.value || GlimmerValidator.valueForTag;
tagValidate = GlimmerValidator.validate || GlimmerValidator.validateTag;
Expand Down Expand Up @@ -74,7 +70,7 @@ try {
} catch (e) {
try {
// Fallback to the previous implementation
let GlimmerReference = Ember.__loader.require('@glimmer/reference');
let GlimmerReference = EmberLoader.require('@glimmer/reference');

tagValue = GlimmerReference.value;
tagValidate = GlimmerReference.validate;
Expand All @@ -84,7 +80,7 @@ try {
}

try {
let metal = Ember.__loader.require('@ember/-internals/metal');
let metal = EmberLoader.require('@ember/-internals/metal');

tagForProperty = metal.tagForProperty;
// If track was not already loaded, use metal's version (the previous version)
Expand Down Expand Up @@ -713,7 +709,7 @@ export default DebugPort.extend({
}

if (
object instanceof ArrayProxy &&
object instanceof Ember.ArrayProxy &&
object.content &&
!object._showProxyDetails
) {
Expand Down
14 changes: 14 additions & 0 deletions ember_debug/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "ember-debug",
"version": "4.9.1",
"devDependencies": {
"@ember/string": "^3.1.1",
"ember-source": "~4.12.0",
"dag-map": "^2.0.2",
"route-recognizer": "0.3.4",
"ember-cli": "~4.9.2"
},
"engines": {
"node": "14.* || 16.* || >= 18"
}
}
6 changes: 3 additions & 3 deletions ember_debug/port.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import EmberObject, { computed } from 'ember-debug/utils/ember/object';
import { or, readOnly } from 'ember-debug/utils/ember/object/computed';
import Evented from 'ember-debug/utils/ember/object/evented';
import EmberObject, { computed } from '@ember/object';
import { or, readOnly } from '@ember/object/computed';
import Evented from '@ember/object/evented';
import { guidFor } from 'ember-debug/utils/ember/object/internals';
import { run } from 'ember-debug/utils/ember/runloop';

Expand Down
6 changes: 3 additions & 3 deletions ember_debug/promise-debug.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import DebugPort from './debug-port';
import PromiseAssembler from 'ember-debug/libs/promise-assembler';

import { A } from 'ember-debug/utils/ember/array';
import { computed } from 'ember-debug/utils/ember/object';
import { readOnly } from 'ember-debug/utils/ember/object/computed';
import { A } from '@ember/array';
import { computed } from '@ember/object';
import { readOnly } from '@ember/object/computed';
import { debounce } from 'ember-debug/utils/ember/runloop';
import RSVP from 'ember-debug/utils/rsvp';

Expand Down
4 changes: 2 additions & 2 deletions ember_debug/route-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import classify from 'ember-debug/utils/classify';
import dasherize from 'ember-debug/utils/dasherize';

import Ember from 'ember-debug/utils/ember';
import { computed, observer } from 'ember-debug/utils/ember/object';
import { readOnly } from 'ember-debug/utils/ember/object/computed';
import { computed, observer } from '@ember/object';
import { readOnly } from '@ember/object/computed';
import { later } from 'ember-debug/utils/ember/runloop';

const { hasOwnProperty } = Object.prototype;
Expand Down
2 changes: 1 addition & 1 deletion ember_debug/services/session.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import EmberObject from 'ember-debug/utils/ember/object';
import EmberObject from '@ember/object';

const Session = EmberObject.extend({
setItem(/*key, val*/) {},
Expand Down
Loading