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

Implement the optimizeDeps() helper #1623

Merged
merged 4 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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