Skip to content

Commit

Permalink
Merge pull request #10172 from bertdeblock/optimize-require-statements
Browse files Browse the repository at this point in the history
[PERFORMANCE] Lazy require heavier packages
  • Loading branch information
bertdeblock committed Feb 11, 2023
2 parents 690ed75 + 4cbd925 commit 9644ac0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
5 changes: 3 additions & 2 deletions lib/commands/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ const fs = require('fs');
const temp = require('temp');
temp.track();

require('express').static.mime.define({ 'application/wasm': ['wasm'] });

let defaultPort = 7357;

module.exports = Command.extend({
Expand Down Expand Up @@ -81,6 +79,9 @@ module.exports = Command.extend({
init() {
this._super.apply(this, arguments);

// Make sure Testem supports the Wasm MIME type:
require('express').static.mime.define({ 'application/wasm': ['wasm'] });

this.Builder = this.Builder || Builder;
this.Watcher = this.Watcher || Watcher;

Expand Down
2 changes: 1 addition & 1 deletion lib/models/blueprint.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const EOL = require('os').EOL;
const bowEpParser = require('bower-endpoint-parser');
const logger = require('heimdalljs-logger')('ember-cli:blueprint');
const normalizeEntityName = require('ember-cli-normalize-entity-name');
const { removeTypes } = require('remove-types');
const isAddon = require('../utilities/is-addon');
const { deprecate } = require('../debug');

Expand Down Expand Up @@ -532,6 +531,7 @@ let Blueprint = CoreObject.extend({
async convertToJS(fileInfo) {
let rendered = await fileInfo.render();

const { removeTypes } = require('remove-types');
const transformed = await removeTypes(rendered);

fileInfo.rendered = transformed;
Expand Down
10 changes: 6 additions & 4 deletions lib/tasks/interactive-new.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
'use strict';

const inquirer = require('inquirer');
const { isLangCode } = require('is-language-code');
const osLocale = require('os-locale');

const Task = require('../models/task');
const isValidProjectName = require('../utilities/valid-project-name');

const DEFAULT_LOCALE = 'en-US';

class InteractiveNewTask extends Task {
async run(newCommandOptions, _testAnswers) {
const inquirer = require('inquirer');

let prompt = inquirer.createPromptModule();
let questions = await this.getQuestions(newCommandOptions);
let answers = await prompt(questions, _testAnswers);
Expand All @@ -24,6 +22,8 @@ class InteractiveNewTask extends Task {
}

async getQuestions(newCommandOptions = {}) {
const { isLangCode } = require('is-language-code');

return [
{
name: 'blueprint',
Expand Down Expand Up @@ -145,6 +145,8 @@ class InteractiveNewTask extends Task {
}

getUserLocale() {
const osLocale = require('os-locale');

return osLocale();
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/tasks/transforms/amd/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict';

const shimAmd = require('./amd-shim');

class AmdTransformAddon {
/**
* This addon is used to register a custom AMD transform for app and addons to use.
Expand All @@ -15,6 +13,8 @@ class AmdTransformAddon {
}

importTransforms() {
const shimAmd = require('./amd-shim');

return {
amd: {
transform: (tree, options) => {
Expand Down

0 comments on commit 9644ac0

Please sign in to comment.