Skip to content

Commit

Permalink
Merge pull request #1623 from lolmaus/optimize-deps
Browse files Browse the repository at this point in the history
Implement the optimizeDeps() helper
  • Loading branch information
mansona authored Oct 11, 2023
2 parents 157dd62 + 2f5317f commit 0a697b4
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
/tests/vite-app/
/packages/vite/index.mjs
/packages/vite/index.d.ts
/packages/vite/src/**/*.js
/packages/vite/src/**/*.d.ts
/packages/vite/**/*.js
/packages/vite/**/*.d.ts


# unconventional js
Expand Down
8 changes: 3 additions & 5 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# No need to run prettier here
*.md
*.md
*.yml
*.yaml
*.html
Expand Down Expand Up @@ -35,10 +35,8 @@
/packages/addon-dev/**/*.d.ts
/tests/fixtures/
/packages/vite/index.mjs
/packages/vite/index.d.ts
/packages/vite/src/**/*.js
/packages/vite/src/**/*.d.ts

/packages/vite/**/*.js
/packages/vite/**/*.d.ts

# unconventional js
/blueprints/*/files/
Expand Down
6 changes: 3 additions & 3 deletions packages/vite/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
/src/**/*.js
/src/**/*.d.ts
/src/**/*.map
/*/tests/**/*.js
/*/tests/**/*.d.ts
/*/tests/**/*.map
/tests/**/*.js
/tests/**/*.d.ts
/tests/**/*.map
3 changes: 2 additions & 1 deletion packages/vite/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export * from './src/resolver.js';
export * from './src/hbs.js';
export * from './src/scripts.js';
export * from './src/template-tag.js';
export * from './src/addons.js';
export * from './src/addons.js';
export * from './src/optimize-deps.js';
3 changes: 2 additions & 1 deletion packages/vite/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export * from './src/resolver.js';
export * from './src/hbs.js';
export * from './src/scripts.js';
export * from './src/template-tag.js';
export * from './src/addons.js';
export * from './src/addons.js';
export * from './src/optimize-deps.js';
4 changes: 4 additions & 0 deletions packages/vite/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
testEnvironment: 'node',
testMatch: ['<rootDir>/tests/**/*.test.js'],
};
3 changes: 3 additions & 0 deletions packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"@embroider/core": "workspace:^",
"vite": "^4.3.9"
},
"scripts": {
"test": "jest"
},
"dependencies": {
"@rollup/pluginutils": "^4.1.1",
"assert-never": "^1.2.1",
Expand Down
10 changes: 10 additions & 0 deletions packages/vite/src/optimize-deps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export interface OptimizeDeps {
exclude?: string[];
[key: string]: unknown;
}

export function optimizeDeps(): OptimizeDeps {
return {
exclude: ['@embroider/macros'],
};
}
13 changes: 13 additions & 0 deletions packages/vite/tests/optimize-deps.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { optimizeDeps } from '../src/optimize-deps';

describe('optimizeDeps', function () {
test('should produce default output when invoked without arguments', function () {
const actual = optimizeDeps();

const expected = {
exclude: ['@embroider/macros'],
};

expect(actual).toEqual(expected);
});
});
13 changes: 9 additions & 4 deletions tests/vite-app/vite.config.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { defineConfig } from "vite";
import { resolver, hbs, scripts, templateTag, addons } from "@embroider/vite";
import {
resolver,
hbs,
scripts,
templateTag,
addons,
optimizeDeps,
} from "@embroider/vite";
import { resolve } from "path";
import { babel } from "@rollup/plugin-babel";

Expand All @@ -23,9 +30,7 @@ export default defineConfig({
extensions: [".gjs", ".js", ".hbs"],
}),
],
optimizeDeps: {
exclude: addons(__dirname),
},
optimizeDeps: optimizeDeps(),
server: {
watch: {
ignored: ["!**/node_modules/.embroider/rewritten-app/**"],
Expand Down

0 comments on commit 0a697b4

Please sign in to comment.