Skip to content

Commit

Permalink
fix(vite): remove need for second commonjs plugin instance
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlafroscia committed Apr 13, 2021
1 parent c88fddf commit 8f873e1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 23 deletions.
1 change: 0 additions & 1 deletion packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"dependencies": {
"@embroider/rollup-plugin-hbs": "*",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-commonjs": "^18.0.0",
"vite": "^2.0.0"
},
"peerDependencies": {
Expand Down
9 changes: 6 additions & 3 deletions packages/vite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import { HTMLEntrypoint, Packager, Variant, applyVariantToBabelConfig } from '@e
import { build, BuildOptions, InlineConfig } from 'vite';
import templateCompilerPlugin from '@embroider/rollup-plugin-hbs';
import { babel } from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';

type RollupOptions = Required<BuildOptions['rollupOptions']>;
type AllowedRollupOptions = Omit<RollupOptions, 'input'>;

type AllowedBuildOptions = Omit<BuildOptions, 'outDir' | 'rollupOptions'> & {
type AllowedBuildOptions = Omit<BuildOptions, 'commonjsOptions' | 'outDir' | 'rollupOptions'> & {
rollupOptions?: AllowedRollupOptions;
};

Expand Down Expand Up @@ -76,7 +75,7 @@ export class Vite extends Packager<Options> {
// Add the Babel config produced by Embroider
...this.getBabelConfig(meta.babel.filename),
}),
commonjs(),

...(this.viteConfig.plugins ?? []),
],
root: this.pathToVanillaApp,
Expand All @@ -91,6 +90,10 @@ export class Vite extends Packager<Options> {
...this.viteConfig.build?.rollupOptions,
input: entrypoints.map(entry => join(this.pathToVanillaApp, entry.filename)),
},
commonjsOptions: {
include: [/.*/],
extensions: meta['resolvable-extensions'],
},
},
});

Expand Down
20 changes: 1 addition & 19 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1694,19 +1694,6 @@
"@babel/helper-module-imports" "^7.10.4"
"@rollup/pluginutils" "^3.1.0"

"@rollup/plugin-commonjs@^18.0.0":
version "18.0.0"
resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-18.0.0.tgz#50dc7518b5aa9e66a270e529ea85115d269825c4"
integrity sha512-fj92shhg8luw7XbA0HowAqz90oo7qtLGwqTKbyZ8pmOyH8ui5e+u0wPEgeHLH3djcVma6gUCUrjY6w5R2o1u6g==
dependencies:
"@rollup/pluginutils" "^3.1.0"
commondir "^1.0.1"
estree-walker "^2.0.1"
glob "^7.1.6"
is-reference "^1.2.1"
magic-string "^0.25.7"
resolve "^1.17.0"

"@rollup/pluginutils@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b"
Expand Down Expand Up @@ -9211,11 +9198,6 @@ estree-walker@^1.0.1:
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-1.0.1.tgz#31bc5d612c96b704106b477e6dd5d8aa138cb700"
integrity sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==

estree-walker@^2.0.1:
version "2.0.2"
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-2.0.2.tgz#52f010178c2a4c117a7757cfe942adb7d2da4cac"
integrity sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==

esutils@^2.0.0, esutils@^2.0.2:
version "2.0.3"
resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64"
Expand Down Expand Up @@ -11556,7 +11538,7 @@ is-redirect@^1.0.0:
resolved "https://registry.yarnpkg.com/is-redirect/-/is-redirect-1.0.0.tgz#1d03dded53bd8db0f30c26e4f95d36fc7c87dc24"
integrity sha1-HQPd7VO9jbDzDCbk+V02/HyH3CQ=

is-reference@^1.1.0, is-reference@^1.2.1:
is-reference@^1.1.0:
version "1.2.1"
resolved "https://registry.yarnpkg.com/is-reference/-/is-reference-1.2.1.tgz#8b2dac0b371f4bc994fdeaba9eb542d03002d0b7"
integrity sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==
Expand Down

0 comments on commit 8f873e1

Please sign in to comment.