Skip to content

Commit

Permalink
Add root-level import (#936)
Browse files Browse the repository at this point in the history
* Add root-level import

* Fix error message

* Tweak copy

* Add comment
  • Loading branch information
thecrypticace committed Feb 17, 2023
1 parent 60bcd8e commit 33deb7b
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 2 deletions.
1 change: 1 addition & 0 deletions react/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*
!*.js
!.gitignore
!package.json
!outline
Expand Down
16 changes: 16 additions & 0 deletions react/index.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// The only reason this file exists is to appease Vite's optimizeDeps feature which requires a root-level import.

export default new Proxy(
{},
{
get: (_, property) => {
if (property === '__esModule') {
return {}
}

throw new Error(
`Importing from \`@heroicons/react\` directly is not supported. Please import from either \`@heroicons/react/20/solid\`, \`@heroicons/react/24/solid\`, or \`@heroicons/react/24/outline\` instead.`
)
},
}
)
16 changes: 16 additions & 0 deletions react/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// The only reason this file exists is to appease Vite's optimizeDeps feature which requires a root-level import.

module.exports = new Proxy(
{},
{
get: (_, property) => {
if (property === '__esModule') {
return {}
}

throw new Error(
`Importing from \`@heroicons/react\` directly is not supported. Please import from either \`@heroicons/react/20/solid\`, \`@heroicons/react/24/solid\`, or \`@heroicons/react/24/outline\` instead.`
)
},
}
)
6 changes: 5 additions & 1 deletion react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
],
"sideEffects": false,
"exports": {
".": {
"import": "./index.esm.js",
"require": "./index.js"
},
"./package.json": {
"default": "./package.json"
},
Expand Down Expand Up @@ -114,4 +118,4 @@
"peerDependencies": {
"react": ">= 16"
}
}
}
1 change: 1 addition & 0 deletions vue/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*
!*.js
!.gitignore
!package.json
16 changes: 16 additions & 0 deletions vue/index.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// The only reason this file exists is to appease Vite's optimizeDeps feature which requires a root-level import.

export default new Proxy(
{},
{
get: (_, property) => {
if (property === '__esModule') {
return {}
}

throw new Error(
`Importing from \`@heroicons/vue\` directly is not supported. Please import from either \`@heroicons/vue/20/solid\`, \`@heroicons/vue/24/solid\`, or \`@heroicons/vue/24/outline\` instead.`
)
},
}
)
16 changes: 16 additions & 0 deletions vue/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// The only reason this file exists is to appease Vite's optimizeDeps feature which requires a root-level import.

module.exports = new Proxy(
{},
{
get: (_, property) => {
if (property === '__esModule') {
return {}
}

throw new Error(
`Importing from \`@heroicons/vue\` directly is not supported. Please import from either \`@heroicons/vue/20/solid\`, \`@heroicons/vue/24/solid\`, or \`@heroicons/vue/24/outline\` instead.`
)
},
}
)
6 changes: 5 additions & 1 deletion vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
],
"sideEffects": false,
"exports": {
".": {
"import": "./index.esm.js",
"require": "./index.js"
},
"./package.json": {
"default": "./package.json"
},
Expand Down Expand Up @@ -114,4 +118,4 @@
"peerDependencies": {
"vue": ">= 3"
}
}
}

0 comments on commit 33deb7b

Please sign in to comment.