Skip to content

Commit c773bdf

Browse files
authored
Use mjs and avoid mixing CJS (require) with ESM. Do not overwrite config.resolve.alias.vue if pre-set. (#56)
* LDP-1093 - Implement module improvements * LDP-1093 - Revert some changes
1 parent cb8e150 commit c773bdf

File tree

6 files changed

+56
-37
lines changed

6 files changed

+56
-37
lines changed

example/nuxt.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const { resolve } = require('path')
1+
import { resolve } from 'path'
22

3-
module.exports = {
3+
export default {
44
components: true,
55
modules: [
66
resolve(__dirname, '..')

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ module.exports = {
1313
'^@/(.*)$': '<rootDir>/lib/$1'
1414
},
1515
transform: {
16-
'^.+\\.js$': 'babel-jest'
16+
'^.+\\.m|js$': 'babel-jest'
1717
}
1818
}

lib/module.js renamed to lib/module.mjs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import { resolve } from 'path'
12
import chalk from 'chalk'
2-
const { resolve } = require('path')
33

4-
module.exports = async function (moduleOptions) {
4+
import { name, version } from '../package.json'
5+
6+
async function drupalCe (moduleOptions) {
57
const defaultOptions = {
68
baseURL: process.env.DRUPAL_BASE_URL || 'http://localhost:8888',
79
menuEndpoint: 'api/menu_items/$$$NAME$$$',
@@ -30,7 +32,7 @@ module.exports = async function (moduleOptions) {
3032
// Include the vue compiler in the build unless configured otherwise.
3133
if (options.addVueCompiler) {
3234
nuxt.options.build.extend = (config, context) => {
33-
config.resolve.alias.vue = 'vue/dist/vue.common'
35+
config.resolve.alias.vue = config.resolve.alias.vue || 'vue/dist/vue.common'
3436
}
3537
}
3638

@@ -49,10 +51,13 @@ module.exports = async function (moduleOptions) {
4951
}
5052

5153
this.addPlugin({
52-
src: resolve(__dirname, 'plugin.js'),
54+
src: resolve(__dirname, 'plugin.mjs'),
5355
options
5456
})
57+
5558
await this.requireModule('@nuxtjs/axios')
5659
}
5760

58-
module.exports.meta = require('../package.json')
61+
drupalCe.meta = { name, version }
62+
63+
export default drupalCe
File renamed without changes.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nuxtjs-drupal-ce",
3-
"version": "1.0.0-beta10",
3+
"version": "1.0.0-beta11",
44
"description": "A Nuxt.js module to easily connect Drupal via custom elements.",
55
"repository": "drunomics/nuxtjs-drupal-ce",
66
"license": "MIT",
@@ -22,15 +22,15 @@
2222
"lib",
2323
"scaffold"
2424
],
25-
"main": "lib/module.js",
25+
"main": "lib/module.mjs",
2626
"scripts": {
2727
"dev": "nuxt example",
2828
"lint": "eslint --ext .js,.vue .",
2929
"release": "npm run test && standard-version && git push --follow-tags && npm publish",
3030
"test": "npm run lint && jest"
3131
},
3232
"dependencies": {
33-
"@nuxtjs/axios": "^5.12.2"
33+
"@nuxtjs/axios": "^5.13.6"
3434
},
3535
"devDependencies": {
3636
"@babel/core": "latest",

yarn.lock

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,16 +1551,16 @@
15511551
webpack-node-externals "^2.5.2"
15521552
webpackbar "^4.0.0"
15531553

1554-
"@nuxtjs/axios@^5.12.2":
1555-
version "5.12.3"
1556-
resolved "https://registry.yarnpkg.com/@nuxtjs/axios/-/axios-5.12.3.tgz#0c3d19f0a28cdf90b425898919f90414022beeee"
1557-
integrity sha512-3hvr14dU0h61s4XF+HT/IgqCOq4608dMVFt9dHhNyZ479Y/Fiv59lAIJNx1NAwFnFNEMFHZ2FlWwc47bls89Fg==
1554+
"@nuxtjs/axios@^5.13.6":
1555+
version "5.13.6"
1556+
resolved "https://registry.yarnpkg.com/@nuxtjs/axios/-/axios-5.13.6.tgz#6f4bbd98a3a7799a5d2c0726c6ad2a98aa111881"
1557+
integrity sha512-XS+pOE0xsDODs1zAIbo95A0LKlilvJi8YW0NoXYuq3/jjxGgWDxizZ6Yx0AIIjZOoGsXJOPc0/BcnSEUQ2mFBA==
15581558
dependencies:
1559-
"@nuxtjs/proxy" "^2.0.1"
1560-
axios "^0.21.0"
1559+
"@nuxtjs/proxy" "^2.1.0"
1560+
axios "^0.21.1"
15611561
axios-retry "^3.1.9"
1562-
consola "^2.15.0"
1563-
defu "^3.2.2"
1562+
consola "^2.15.3"
1563+
defu "^5.0.0"
15641564

15651565
"@nuxtjs/eslint-config@latest":
15661566
version "5.0.0"
@@ -1576,13 +1576,12 @@
15761576
eslint-plugin-unicorn "^23.0.0"
15771577
eslint-plugin-vue "^7.1.0"
15781578

1579-
"@nuxtjs/proxy@^2.0.1":
1580-
version "2.0.1"
1581-
resolved "https://registry.yarnpkg.com/@nuxtjs/proxy/-/proxy-2.0.1.tgz#2469b6e316311aa8c60d348502a54bfe6d5536aa"
1582-
integrity sha512-RVZ6iYeAuWteot9oer3vTDCOEiTwg37Mqf6yy8vPD0QQaw4z3ykgM++MzfUl85jM14+qNnODZj5EATRoCY009Q==
1579+
"@nuxtjs/proxy@^2.1.0":
1580+
version "2.1.0"
1581+
resolved "https://registry.yarnpkg.com/@nuxtjs/proxy/-/proxy-2.1.0.tgz#fa7715a11d237fa1273503c4e9e137dd1bf5575b"
1582+
integrity sha512-/qtoeqXgZ4Mg6LRg/gDUZQrFpOlOdHrol/vQYMnKu3aN3bP90UfOUB3QSDghUUK7OISAJ0xp8Ld78aHyCTcKCQ==
15831583
dependencies:
1584-
consola "^2.11.3"
1585-
http-proxy-middleware "^1.0.4"
1584+
http-proxy-middleware "^1.0.6"
15861585

15871586
"@nuxtjs/youch@^4.2.3":
15881587
version "4.2.3"
@@ -1684,10 +1683,10 @@
16841683
resolved "https://registry.yarnpkg.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.0.tgz#9140779736aa2655635ee756e2467d787cfe8a2a"
16851684
integrity sha512-c3Xy026kOF7QOTn00hbIllV1dLR9hG9NkSrLQgCVs8NF6sBU+VGWjD3wLPhmh1TYAc7ugCFsvHYMN4VcBN1U1A==
16861685

1687-
"@types/http-proxy@^1.17.4":
1688-
version "1.17.4"
1689-
resolved "https://registry.yarnpkg.com/@types/http-proxy/-/http-proxy-1.17.4.tgz#e7c92e3dbe3e13aa799440ff42e6d3a17a9d045b"
1690-
integrity sha512-IrSHl2u6AWXduUaDLqYpt45tLVCtYv7o4Z0s1KghBCDgIIS9oW5K1H8mZG/A2CfeLdEa7rTd1ACOiHBc1EMT2Q==
1686+
"@types/http-proxy@^1.17.5":
1687+
version "1.17.8"
1688+
resolved "https://registry.yarnpkg.com/@types/http-proxy/-/http-proxy-1.17.8.tgz#968c66903e7e42b483608030ee85800f22d03f55"
1689+
integrity sha512-5kPLG5BKpWYkw/LVOGWpiq3nEVqxiN32rTgI53Sk12/xHFQ2rG3ehI9IO+O3W2QoKeyB92dJkoka8SUm6BX1pA==
16911690
dependencies:
16921691
"@types/node" "*"
16931692

@@ -2487,7 +2486,7 @@ axios-retry@^3.1.9:
24872486
dependencies:
24882487
is-retry-allowed "^1.1.0"
24892488

2490-
axios@^0.21.0:
2489+
axios@^0.21.1:
24912490
version "0.21.4"
24922491
resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575"
24932492
integrity sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==
@@ -3423,11 +3422,16 @@ connect@^3.7.0:
34233422
parseurl "~1.3.3"
34243423
utils-merge "1.0.1"
34253424

3426-
consola@^2.10.0, consola@^2.11.3, consola@^2.15.0, consola@^2.6.0, consola@^2.9.0:
3425+
consola@^2.10.0, consola@^2.15.0, consola@^2.6.0, consola@^2.9.0:
34273426
version "2.15.0"
34283427
resolved "https://registry.yarnpkg.com/consola/-/consola-2.15.0.tgz#40fc4eefa4d2f8ef2e2806147f056ea207fcc0e9"
34293428
integrity sha512-vlcSGgdYS26mPf7qNi+dCisbhiyDnrN1zaRbw3CSuc2wGOMEGGPsp46PdRG5gqXwgtJfjxDkxRNAgRPr1B77vQ==
34303429

3430+
consola@^2.15.3:
3431+
version "2.15.3"
3432+
resolved "https://registry.yarnpkg.com/consola/-/consola-2.15.3.tgz#2e11f98d6a4be71ff72e0bdf07bd23e12cb61550"
3433+
integrity sha512-9vAdYbHj6x2fLKC4+oPH0kFzY/orMZyG2Aj+kNylHxKGJ/Ed4dpNyAQYwJOdqO4zdM7XpVHmyejQDcQHrnuXbw==
3434+
34313435
console-browserify@^1.1.0:
34323436
version "1.2.0"
34333437
resolved "https://registry.yarnpkg.com/console-browserify/-/console-browserify-1.2.0.tgz#67063cef57ceb6cf4993a2ab3a55840ae8c49336"
@@ -4170,6 +4174,11 @@ defu@^3.2.2:
41704174
resolved "https://registry.yarnpkg.com/defu/-/defu-3.2.2.tgz#be20f4cc49b9805d54ee6b610658d53894942e97"
41714175
integrity sha512-8UWj5lNv7HD+kB0e9w77Z7TdQlbUYDVWqITLHNqFIn6khrNHv5WQo38Dcm1f6HeNyZf0U7UbPf6WeZDSdCzGDQ==
41724176

4177+
defu@^5.0.0:
4178+
version "5.0.0"
4179+
resolved "https://registry.yarnpkg.com/defu/-/defu-5.0.0.tgz#5768f0d402a555bfc4c267246b20f82ce8b5a10b"
4180+
integrity sha512-VHg73EDeRXlu7oYWRmmrNp/nl7QkdXUxkQQKig0Zk8daNmm84AbGoC8Be6/VVLJEKxn12hR0UBmz8O+xQiAPKQ==
4181+
41734182
delayed-stream@~1.0.0:
41744183
version "1.0.0"
41754184
resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619"
@@ -5897,15 +5906,15 @@ http-errors@~1.7.2:
58975906
statuses ">= 1.5.0 < 2"
58985907
toidentifier "1.0.0"
58995908

5900-
http-proxy-middleware@^1.0.4:
5901-
version "1.0.6"
5902-
resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-1.0.6.tgz#0618557722f450375d3796d701a8ac5407b3b94e"
5903-
integrity sha512-NyL6ZB6cVni7pl+/IT2W0ni5ME00xR0sN27AQZZrpKn1b+qRh+mLbBxIq9Cq1oGfmTc7BUq4HB77mxwCaxAYNg==
5909+
http-proxy-middleware@^1.0.6:
5910+
version "1.3.1"
5911+
resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-1.3.1.tgz#43700d6d9eecb7419bf086a128d0f7205d9eb665"
5912+
integrity sha512-13eVVDYS4z79w7f1+NPllJtOQFx/FdUW4btIvVRMaRlUY9VGstAbo5MOhLEuUgZFRHn3x50ufn25zkj/boZnEg==
59045913
dependencies:
5905-
"@types/http-proxy" "^1.17.4"
5914+
"@types/http-proxy" "^1.17.5"
59065915
http-proxy "^1.18.1"
59075916
is-glob "^4.0.1"
5908-
lodash "^4.17.20"
5917+
is-plain-obj "^3.0.0"
59095918
micromatch "^4.0.2"
59105919

59115920
http-proxy@^1.18.1:
@@ -6357,6 +6366,11 @@ is-plain-obj@^1.0.0, is-plain-obj@^1.1.0:
63576366
resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e"
63586367
integrity sha1-caUMhCnfync8kqOQpKA7OfzVHT4=
63596368

6369+
is-plain-obj@^3.0.0:
6370+
version "3.0.0"
6371+
resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-3.0.0.tgz#af6f2ea14ac5a646183a5bbdb5baabbc156ad9d7"
6372+
integrity sha512-gwsOE28k+23GP1B6vFl1oVh/WOzmawBrKwo5Ev6wMKzPkaXaCDIQKzLnvsA42DRlbVTWorkgTKIviAKCWkfUwA==
6373+
63606374
is-plain-object@^2.0.3, is-plain-object@^2.0.4:
63616375
version "2.0.4"
63626376
resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677"

0 commit comments

Comments
 (0)