Skip to content
This repository was archived by the owner on Jan 31, 2023. It is now read-only.

fix: Fix non-top-level requires #37

Merged
merged 1 commit into from
Feb 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.2.1
12.8.1
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const defaultOptions = {
babelrc: false,
plugins: [
...[
'@babel/plugin-transform-modules-commonjs',
'babel-plugin-add-module-exports',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-object-rest-spread',
].map(require.resolve),
Expand Down
167 changes: 100 additions & 67 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@
"semantic-release": "15.13.15",
"sinon": "7.2.3",
"sinon-chai": "3.3.0",
"snap-shot-it": "6.2.9"
"snap-shot-it": "7.9.2"
},
"dependencies": {
"@babel/core": "7.4.5",
"@babel/plugin-proposal-class-properties": "7.3.0",
"@babel/plugin-proposal-object-rest-spread": "7.3.2",
"@babel/plugin-transform-modules-commonjs": "7.8.3",
"@babel/plugin-transform-runtime": "7.2.0",
"@babel/preset-env": "7.4.5",
"@babel/preset-react": "7.0.0",
"@babel/runtime": "7.3.1",
"babel-plugin-add-module-exports": "1.0.2",
"babelify": "10.0.0",
"bluebird": "3.5.3",
"browserify": "16.2.3",
Expand Down
7 changes: 7 additions & 0 deletions test/e2e/e2e_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,11 @@ describe('imports and exports', () => {
eval(output)
})
})

it('handles non-top-level require', () => {
return bundle('require_spec.js').then((output) => {
// check that bundled tests work
eval(output)
})
})
})
2 changes: 1 addition & 1 deletion test/fixtures/dom_spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const dom = require('./dom').default
const dom = require('./dom')

context('imports default string', function () {
it('works', () => {
Expand Down
14 changes: 14 additions & 0 deletions test/fixtures/require_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
context('non-top-level requires', function () {
const math = require('./math')
const dom = require('./dom')

it('imports proper types of values', () => {
expect(math.add, 'add').to.be.a('function')
expect(dom, 'dom').to.be.a('string')
})

it('values are correct', function () {
expect(math.add(1, 2)).to.eq(3)
expect(dom, 'dom').to.equal('dom')
})
})