-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1488 from embroider-build/app-import-node-modules
- Loading branch information
Showing
2 changed files
with
61 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { expectFilesAt, ExpectFile } from '@embroider/test-support/file-assertions/qunit'; | ||
import { PreparedApp } from 'scenario-tester'; | ||
import { throwOnWarnings } from '@embroider/core'; | ||
import { appScenarios, baseAddon } from './scenarios'; | ||
import QUnit from 'qunit'; | ||
import { merge } from 'lodash'; | ||
const { module: Qmodule, test } = QUnit; | ||
|
||
appScenarios | ||
.map('compat-addon-import', project => { | ||
let addon1 = baseAddon(); | ||
addon1.pkg.name = 'my-addon1'; | ||
|
||
merge(addon1.files, { | ||
'index.js': ` | ||
module.exports = { | ||
name: require('./package.json').name, | ||
included(app) { | ||
this.import('node_modules/third-party1/index.js', { | ||
using: [{ transformation: 'amd' }], | ||
type: 'test' | ||
}); | ||
} | ||
} | ||
`, | ||
}); | ||
|
||
addon1.addDependency('third-party1', '1.2.3').files = { | ||
'index.js': 'module.exports = function() { console.log("hello world"); }', | ||
}; | ||
|
||
project.addDependency(addon1); | ||
}) | ||
.forEachScenario(scenario => { | ||
Qmodule(scenario.name, function (hooks) { | ||
throwOnWarnings(hooks); | ||
|
||
let app: PreparedApp; | ||
|
||
let expectFile: ExpectFile; | ||
|
||
hooks.before(async assert => { | ||
app = await scenario.prepare(); | ||
let result = await app.execute('ember build', { env: { STAGE1_ONLY: 'true' } }); | ||
assert.equal(result.exitCode, 0, result.output); | ||
}); | ||
|
||
hooks.beforeEach(assert => { | ||
expectFile = expectFilesAt(app.dir, { qunit: assert }); | ||
}); | ||
|
||
test('synthesized-vendor has imported file in node modules', function () { | ||
expectFile( | ||
'./node_modules/.embroider/rewritten-packages/@embroider/synthesized-vendor/node_modules/third-party1/index.js' | ||
).matches(`(function(define){ | ||
module.exports = function() { console.log(\"hello world\"); } | ||
})((function(){ function newDefine(){ var args = Array.prototype.slice.call(arguments); return define.apply(null, args); }; newDefine.amd = true; return newDefine; })());`); | ||
}); | ||
}); | ||
}); |