diff --git a/README.md b/README.md index 77e504650..f17687b97 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ Day.js has great support for internationalization. But none of them will be included in your build unless you use it. ```javascript -import 'dayjs/locale/es' // load on demand +import 'dayjs/locale/es.js' // load on demand dayjs.locale('es') // use Spanish locale globally @@ -90,7 +90,7 @@ dayjs('2018-05-05').locale('zh-cn').format() // use Chinese Simplified locale in A plugin is an independent module that can be added to Day.js to extend functionality or add new features. ```javascript -import advancedFormat from 'dayjs/plugin/advancedFormat' // load on demand +import advancedFormat from 'dayjs/plugin/advancedFormat.js' // load on demand dayjs.extend(advancedFormat) // use plugin diff --git a/babel.config.js b/babel.config.js index 2531938f6..778b8a811 100644 --- a/babel.config.js +++ b/babel.config.js @@ -14,6 +14,9 @@ module.exports = { loose: true } ] + ], + plugins: [ + ['add-import-extension', { extension: 'js' }] ] } } diff --git a/package.json b/package.json index e2baf268a..4e54b1b7c 100644 --- a/package.json +++ b/package.json @@ -58,6 +58,7 @@ "@semantic-release/github": "^11.0.4", "babel-core": "^7.0.0-bridge.0", "babel-jest": "^22.4.3", + "babel-plugin-add-import-extension": "^1.6.0", "babel-plugin-external-helpers": "^6.22.0", "cross-env": "^5.1.6", "eslint": "^4.19.1",