Skip to content

Commit

Permalink
build with vite
Browse files Browse the repository at this point in the history
  • Loading branch information
patricklx committed Aug 29, 2023
1 parent 97f2097 commit a554d0b
Show file tree
Hide file tree
Showing 39 changed files with 636 additions and 231 deletions.
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
16 changes: 13 additions & 3 deletions ember_debug/libs/render-tree.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
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';

const Ember = requireModule('ember');

class InElementSupportProvider {
constructor(owner) {
Expand Down Expand Up @@ -36,7 +37,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 All @@ -63,6 +64,10 @@ class InElementSupportProvider {
}

patch() {
if (this.debugRenderTree.__inspector_patched) {
this.debugRenderTree.__inspector_patched = this;
return;
}
const self = this;

const captureNode = this.debugRenderTree.captureNode;
Expand Down Expand Up @@ -130,9 +135,14 @@ class InElementSupportProvider {
pushRemoteElement,
didAppendNode,
};

this.debugRenderTree.__inspector_patched = this;
}

teardown() {
if (this.debugRenderTree.__inspector_patched !== this) {
return;
}
if (!this.debugRenderTreeFunctions) {
return;
}
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
15 changes: 5 additions & 10 deletions ember_debug/object-inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,12 @@ import {
} 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 EmberObject, { computed, get, set } from '@ember/object';
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';

Expand Down Expand Up @@ -713,7 +708,7 @@ export default DebugPort.extend({
}

if (
object instanceof ArrayProxy &&
object instanceof Ember.ArrayProxy &&
object.content &&
!object._showProxyDetails
) {
Expand Down
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
12 changes: 6 additions & 6 deletions ember_debug/utils/ember-object-names.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Ember from 'ember-debug/utils/ember';
import MutableArray from 'ember-debug/utils/ember/array/mutable';
import Component from 'ember-debug/utils/ember/component';
import Observable from 'ember-debug/utils/ember/object/observable';
import Evented from 'ember-debug/utils/ember/object/evented';
import PromiseProxyMixin from 'ember-debug/utils/ember/object/promise-proxy-mixin';
import EmberObject from 'ember-debug/utils/ember/object';
import MutableArray from '@ember/array/mutable';
import Component from '@ember/component';
import Observable from '@ember/object/observable';
import Evented from '@ember/object/evented';
import PromiseProxyMixin from '@ember/object/promise-proxy-mixin';
import EmberObject from '@ember/object';
import { compareVersion } from 'ember-debug/utils/version';

const {
Expand Down
11 changes: 0 additions & 11 deletions ember_debug/utils/ember/application.js

This file was deleted.

11 changes: 0 additions & 11 deletions ember_debug/utils/ember/array.js

This file was deleted.

11 changes: 0 additions & 11 deletions ember_debug/utils/ember/array/mutable.js

This file was deleted.

11 changes: 0 additions & 11 deletions ember_debug/utils/ember/array/proxy.js

This file was deleted.

Loading

0 comments on commit a554d0b

Please sign in to comment.