-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(build): enable named esm module import on node.js >= 14 (#1872)
Co-authored-by: Kia King Ishii <[email protected]>
- Loading branch information
1 parent
658359f
commit acddab2
Showing
5 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import Vuex from '../dist/vuex.common.js' | ||
|
||
const { | ||
Store, | ||
install, | ||
version, | ||
mapState, | ||
mapMutations, | ||
mapGetters, | ||
mapActions, | ||
createNamespacedHelpers, | ||
createLogger | ||
} = Vuex | ||
|
||
export { | ||
Vuex as default, | ||
Store, | ||
install, | ||
version, | ||
mapState, | ||
mapMutations, | ||
mapGetters, | ||
mapActions, | ||
createNamespacedHelpers, | ||
createLogger | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import assert from 'assert' | ||
|
||
import { createRequire } from 'module' | ||
|
||
import Vuex, { | ||
Store, | ||
install, | ||
version, | ||
mapState, | ||
mapMutations, | ||
mapGetters, | ||
mapActions, | ||
createNamespacedHelpers, | ||
createLogger | ||
} from 'vuex' | ||
|
||
const require = createRequire(import.meta.url) | ||
|
||
const cjs = require('vuex') | ||
|
||
assert.equal(Vuex, cjs) | ||
assert.equal(Store, cjs.Store) | ||
assert.equal(install, cjs.install) | ||
assert.equal(version, cjs.version) | ||
assert.equal(mapState, cjs.mapState) | ||
assert.equal(mapMutations, cjs.mapMutations) | ||
assert.equal(mapGetters, cjs.mapGetters) | ||
assert.equal(mapActions, cjs.mapActions) | ||
assert.equal(createNamespacedHelpers, cjs.createNamespacedHelpers) | ||
assert.equal(createLogger, cjs.createLogger) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// only test esm entry points on Node.14 or higher | ||
const [major] = process.versions.node.split('.') | ||
|
||
if (+major >= 14) { | ||
(async function () { | ||
await import('./esm-import.mjs') | ||
})().catch(console.error) | ||
} |