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

import as a ES2015 module #46

Open
john916zhang opened this issue Jun 29, 2020 · 4 comments
Open

import as a ES2015 module #46

john916zhang opened this issue Jun 29, 2020 · 4 comments

Comments

@john916zhang
Copy link

Thanks for developing this wonderful library. Just a quick question. How to import this library as a ES2015 module?

var bcv_parser = require("bible-passage-reference-parser/js/en_bcv_parser").bcv_parser;

I'd like to use ES2015'simport instead of CommonJS's require.

@RyanQuey
Copy link

You can just do e.g.,

import { bcv_parser as eng_bcv_parser } from "bible-passage-reference-parser/js/en_bcv_parser"

@cco3
Copy link

cco3 commented Nov 3, 2022

This is becoming more brittle in some environments:

'bcv_parser' is not exported by node_modules/bible-passage-reference-parser/js/en_bcv_parser.js

@openbibleinfo
Copy link
Owner

@cco3 It looks like the best approach to maintain both the old and the new import styles is to create a new directory with files that use the new style and add a statement to the package.json file. Does that sound like the right approach?

@cco3
Copy link

cco3 commented Nov 4, 2022

Yes, basically just use new-style imports and run it through something like vite or rollup to create outputs in a dist directory which are referenced in package.json.

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

4 participants