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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

extensions option not passed to parser #2584

Closed
garthenweb opened this issue Jan 27, 2019 · 2 comments
Closed

extensions option not passed to parser #2584

garthenweb opened this issue Jan 27, 2019 · 2 comments

Comments

@garthenweb
Copy link
Contributor

garthenweb commented Jan 27, 2019

馃悰 bug report

I tried to override an asset via extensions options. It did not work because the options passed to the Parser are normalized before, and losing this information. See https://github.com/parcel-bundler/parcel/blob/master/packages/core/parcel-bundler/src/Bundler.js#L36

Maybe this is intended and not a bug, I expeted this to work. Let me know your thoughts.

馃帥 Configuration (.babelrc, package.json, cli command)

const bundler = new Bundler('index.html', {
  extensions: {
    '.js': JSAsset,
    '.jsx': JSAsset,
    '.es6': JSAsset,
    '.jsm': JSAsset,
    '.mjs': JSAsset,
  }
})

馃 Expected Behavior

Should allow overriding the Asset via extensions option.

馃槸 Current Behavior

Does not override the asset but uses the default asset.

馃拋 Possible Solution

For now, the following works as expected. But looks like I am using private functions now.

bundler.parser.registerExtension('js', JSAsset)
bundler.parser.registerExtension('jsx', JSAsset)
bundler.parser.registerExtension('es6', JSAsset)
bundler.parser.registerExtension('jsm', JSAsset)
bundler.parser.registerExtension('mjs', JSAsset)

I guess it would be possible to just return extensions from the normalizeOptions call.

馃敠 Context

I try to unblock myself and fix #2583 locally for parcel v1.11.

馃捇 Code Sample

See the configuration section.

馃實 Your Environment

Software Version(s)
Parcel 1.11
Node 10.14.2
npm/Yarn 6.5.0/ 1.12.3
Operating System Windows (WSL)
@garthenweb
Copy link
Contributor Author

Small update about the bundler.parser.registerExtension: Looks like its not working. Sometimes the registered file is used, sometimes not.

@garthenweb
Copy link
Contributor Author

Closing as v2 will have a different api for things like this.

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

No branches or pull requests

2 participants