-
Notifications
You must be signed in to change notification settings - Fork 4
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
fix(dynamicInstantiate): works on Windows #59
Conversation
This code was copied from the patched loader from my other project. This has been tested with the code shown in #45 description, under the following combinations:
I also fixed |
Any chance you can get the GitHub actions tests to include Windows as the base OS as part of this PR? |
Windows builds have been added. |
strategy: | ||
matrix: | ||
node: ['13.9', '13.10', '13.11'] | ||
os: ['ubuntu-latest', 'windows-latest'] | ||
node: ['13.9', '13.10', '13.11', '14.x'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch on that one.
strategy: | ||
matrix: | ||
node: ['13.9', '13.10', '13.11'] | ||
os: ['ubuntu-latest', 'windows-latest'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was hoping this was possible, my other option was to just duplicate the entire tests section with Ubuntu and Windows.
const urlParts = url.split('/node_modules/'); | ||
|
||
const pathParts = moduleUrl.pathname.split('node_modules/'); | ||
const specifier = pathParts.pop()!; | ||
const nodeModulesBase = pathParts.join('node_modules/'); | ||
// Extract the module name after node_modules. | ||
const moduleName = urlParts.pop()!; | ||
|
||
const nodeModuleUrl = new URL('node_modules', pathToFileURL(nodeModulesBase)); | ||
// With NPM, this is just top-level node_modules. | ||
// With PNPM, this is the innermost node_modules. | ||
const nodeModulesPath = urlParts.join('/node_modules/'); | ||
|
||
// Create a Node.JS Require using the `node_modules` folder as the base URL. | ||
const require = createRequire(nodeModuleUrl); | ||
// Create a require function next to node_module, and import the CommonJS module. | ||
const require = createRequire(`${nodeModulesPath}/noop.js`); | ||
let dynModule = require(moduleName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll be honest, having hard time figuring out the fuckery going on here, but it works, so I guess it's good.
🎉 This PR is included in version 1.4.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
closes #39