Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

fix(nuxt-module): node v14 compatibility #1180

Merged
merged 3 commits into from
Oct 15, 2020
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
8 changes: 8 additions & 0 deletions packages/nuxt-module/__tests__/module.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,14 @@ describe("nuxt-module - ShopwarePWAModule runModule", () => {
expect(moduleObject.options.build.babel.presets).toBeTruthy();
});

it("should contain babel plugins to deal with es2020", async () => {
await runModule(moduleObject, {});
expect(moduleObject.options.build.babel.plugins).toEqual([
"@babel/plugin-proposal-optional-chaining",
"@babel/plugin-proposal-nullish-coalescing-operator",
]);
});

it("interfaces should return default empty object", () => {
expect(InterfacesDefault).toEqual({});
});
Expand Down
2 changes: 2 additions & 0 deletions packages/nuxt-module/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
},
"license": "MIT",
"dependencies": {
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.10.4",
"@babel/plugin-proposal-optional-chaining": "^7.11.0",
"@nuxt/types": "^2.14.6",
"@nuxt/typescript-build": "^2.0.3",
"@nuxt/typescript-runtime": "^2.0.0",
Expand Down
8 changes: 8 additions & 0 deletions packages/nuxt-module/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,14 @@ export async function runModule(
];
};

// Fix optional chaining until resolved Nuxt issue: https://github.com/nuxt/nuxt.js/issues/7722
// same fix with nullish coalescing and other Babel loader issues can be resolved here by adding
// package to dependencies and loading plugin here
moduleObject.options.build.babel.plugins = [
"@babel/plugin-proposal-optional-chaining",
"@babel/plugin-proposal-nullish-coalescing-operator",
];

moduleObject.options.build.filenames =
moduleObject.options.build.filenames || {};
moduleObject.options.build.filenames.chunk = ({ isDev }) =>
Expand Down