Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pkgroll #38

Open
rtritto opened this issue Dec 27, 2024 · 6 comments
Open

Update pkgroll #38

rtritto opened this issue Dec 27, 2024 · 6 comments

Comments

@rtritto
Copy link
Contributor

rtritto commented Dec 27, 2024

pkgroll with v2.6.0 adds @rollup/plugin-dynamic-import-vars for dynamic imports.

At

const file = await import(fullPath);

@rollup/plugin-dynamic-import-vars will throw VariableDynamicImportError (rollup/plugins#1831).

There is another solution?

@kravetsone
Copy link
Owner

looks like we should pin pkgroll for now)

@rtritto
Copy link
Contributor Author

rtritto commented Dec 27, 2024

Agree, pin pkgroll to v2.5.1

@rtritto
Copy link
Contributor Author

rtritto commented Jan 3, 2025

Related to @rollup/plugin-dynamic-import-vars, another issue is the required file extension:

const entryDir = '/api'
const file = 'users/index.ts'
import(`.${entryDir}/${file}`)
VariableDynamicImportError: invalid import "import(`.${entryDir}/${file}`)". A file extension must be included in the static part of the import. For example: import(`./foo/${bar}.js`).
    at dynamicImportToGlob (C:\project\.yarn\__virtual__\@rollup-plugin-dynamic-import-vars-virtual-469ce0e48e\5\Users\USER\AppData\Local\Yarn\Berry\cache\@rollup-plugin-dynamic-import-vars-npm-2.1.5-a03e1726af-10c0.zip\node_modules\@rollup\plugin-dynamic-import-vars\dist\cjs\index.js:128:11)
    at Object.enter (C:\project\.yarn\__virtual__\@rollup-plugin-dynamic-import-vars-virtual-469ce0e48e\5\Users\USER\AppData\Local\Yarn\Berry\cache\@rollup-plugin-dynamic-import-vars-npm-2.1.5-a03e1726af-10c0.zip\node_modules\@rollup\plugin-dynamic-import-vars\dist\cjs\index.js:169:26)
    at SyncWalker.visit (C:\Users\USER\AppData\Local\Yarn\Berry\cache\estree-walker-npm-2.0.2-dfab42f65c-10c0.zip\node_modules\estree-walker\dist\umd\estree-walker.js:116:17)
    at SyncWalker.visit (C:\Users\USER\AppData\Local\Yarn\Berry\cache\estree-walker-npm-2.0.2-dfab42f65c-10c0.zip\node_modules\estree-walker\dist\umd\estree-walker.js:153:12)
    at SyncWalker.visit (C:\Users\USER\AppData\Local\Yarn\Berry\cache\estree-walker-npm-2.0.2-dfab42f65c-10c0.zip\node_modules\estree-walker\dist\umd\estree-walker.js:153:12)
    at SyncWalker.visit (C:\Users\USER\AppData\Local\Yarn\Berry\cache\estree-walker-npm-2.0.2-dfab42f65c-10c0.zip\node_modules\estree-walker\dist\umd\estree-walker.js:153:12)
    at SyncWalker.visit (C:\Users\USER\AppData\Local\Yarn\Berry\cache\estree-walker-npm-2.0.2-dfab42f65c-10c0.zip\node_modules\estree-walker\dist\umd\estree-walker.js:146:19)
    at SyncWalker.visit (C:\Users\USER\AppData\Local\Yarn\Berry\cache\estree-walker-npm-2.0.2-dfab42f65c-10c0.zip\node_modules\estree-walker\dist\umd\estree-walker.js:146:19)
    at SyncWalker.visit (C:\Users\USER\AppData\Local\Yarn\Berry\cache\estree-walker-npm-2.0.2-dfab42f65c-10c0.zip\node_modules\estree-walker\dist\umd\estree-walker.js:153:12)
    at SyncWalker.visit (C:\Users\USER\AppData\Local\Yarn\Berry\cache\estree-walker-npm-2.0.2-dfab42f65c-10c0.zip\node_modules\estree-walker\dist\umd\estree-walker.js:146:19) {
  id: 'C:\\project\\src\\index.ts',
  hook: 'transform',
  code: 'PLUGIN_ERROR',
  plugin: 'rollup-plugin-dynamic-import-variables',
  watchFiles: [
    'C:\\project\\src\\index.ts'
  ]
}

Workaround:

const entryDir = '/api'
const file = 'users/index.ts'
import(`.${entryDir}/${file.replace(/.ts$/, '')}.ts`)

@rtritto
Copy link
Contributor Author

rtritto commented Jan 3, 2025

Should we ask help to pkgroll or @rollup/plugin-dynamic-import-vars?

@kravetsone
Copy link
Owner

I guess we should
Because we want to bundle it
We don't know which what will be imported
We need bypass this plugin

@kravetsone
Copy link
Owner

privatenumber/pkgroll#104

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants